[2/5] Fix "finish" with range types on ARM

Message ID 20231020-arm-params-v1-2-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 ARM (I tested big-endian but it may not matter), "finish" can
sometimes print the wrong result when the return type is a range type.
Range types should really be treated as their underlying type
(normally integer, but sometimes fixed-point).  This patch implements
this.
---
 gdb/arm-tdep.c | 3 +++
 1 file changed, 3 insertions(+)
  

Comments

Luis Machado Oct. 23, 2023, 1:14 p.m. UTC | #1
On 10/20/23 20:15, Tom Tromey wrote:
> On ARM (I tested big-endian but it may not matter), "finish" can
> sometimes print the wrong result when the return type is a range type.
> Range types should really be treated as their underlying type
> (normally integer, but sometimes fixed-point).  This patch implements
> this.
> ---
>  gdb/arm-tdep.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
> index 97d7c5140d2..ab0df0f16a8 100644
> --- a/gdb/arm-tdep.c
> +++ b/gdb/arm-tdep.c
> @@ -8915,6 +8915,9 @@ arm_extract_return_value (struct type *type, struct regcache *regs,
>    enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
>    arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
>  
> +  while (type->code () == TYPE_CODE_RANGE)
> +    type = check_typedef (type->target_type ());
> +
>    if (TYPE_CODE_FLT == type->code ())
>      {
>        switch (tdep->fp_model)
> 

Thanks for the patch. 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 97d7c5140d2..ab0df0f16a8 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -8915,6 +8915,9 @@  arm_extract_return_value (struct type *type, struct regcache *regs,
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
 
+  while (type->code () == TYPE_CODE_RANGE)
+    type = check_typedef (type->target_type ());
+
   if (TYPE_CODE_FLT == type->code ())
     {
       switch (tdep->fp_model)