[4/5] Fix range-type "return" command on ARM

Message ID 20231020-arm-params-v1-4-19d4c89c11b6@adacore.com
State New
Headers
Series ARM function-calling / return fixes |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm success Testing passed

Commit Message

Tom Tromey Oct. 20, 2023, 7:15 p.m. UTC
  On big-endian ARM, "return"ing from a function that returned a range
type did not work.  This patch strips the range type to treat the
function as though it were returning the underlying type instead.
---
 gdb/arm-tdep.c | 3 +++
 1 file changed, 3 insertions(+)
  

Comments

Luis Machado Oct. 23, 2023, 1:15 p.m. UTC | #1
On 10/20/23 20:15, Tom Tromey wrote:
> On big-endian ARM, "return"ing from a function that returned a range
> type did not work.  This patch strips the range type to treat the
> function as though it were returning the underlying type instead.
> ---
>  gdb/arm-tdep.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
> index 493e5b84758..62412d92f85 100644
> --- a/gdb/arm-tdep.c
> +++ b/gdb/arm-tdep.c
> @@ -9132,6 +9132,9 @@ arm_store_return_value (struct type *type, struct regcache *regs,
>    struct gdbarch *gdbarch = regs->arch ();
>    enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
>  
> +  while (type->code () == TYPE_CODE_RANGE)
> +    type = check_typedef (type->target_type ());
> +
>    if (type->code () == TYPE_CODE_FLT)
>      {
>        gdb_byte buf[ARM_FP_REGISTER_SIZE];
> 

Thanks. This is OK.

Approved-By: Luis Machado <luis.machado@arm.com>
  

Patch

diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index 493e5b84758..62412d92f85 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -9132,6 +9132,9 @@  arm_store_return_value (struct type *type, struct regcache *regs,
   struct gdbarch *gdbarch = regs->arch ();
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
 
+  while (type->code () == TYPE_CODE_RANGE)
+    type = check_typedef (type->target_type ());
+
   if (type->code () == TYPE_CODE_FLT)
     {
       gdb_byte buf[ARM_FP_REGISTER_SIZE];