[2/4,ARM] Small refactoring of arm gdbarch initialization

Message ID 20211005144521.1965198-3-luis.machado@linaro.org
State New
Headers show
Series
  • M-profile MVE extension support
Related show

Commit Message

Tom Tromey via Gdb-patches Oct. 5, 2021, 2:45 p.m.
This is in preparation to MVE support, where we will define another
pseudo register. We need to define the pseudo register numbers *after*
accounting for all the registers in the XML description, so move
the call to tdesc_use_registers up.

If we don't do it, GDB's register count won't consider registers contained
in the XML but ignored by GDB, throwing the register numbering off.
---
 gdb/arm-tdep.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

-- 
2.25.1

Comments

Tom Tromey via Gdb-patches Oct. 8, 2021, 4:03 p.m. | #1
Lgtm


Alan

> On 5 Oct 2021, at 15:45, Luis Machado <luis.machado@linaro.org> wrote:

> 

> This is in preparation to MVE support, where we will define another

> pseudo register. We need to define the pseudo register numbers *after*

> accounting for all the registers in the XML description, so move

> the call to tdesc_use_registers up.

> 

> If we don't do it, GDB's register count won't consider registers contained

> in the XML but ignored by GDB, throwing the register numbering off.

> ---

> gdb/arm-tdep.c | 22 +++++++++++-----------

> 1 file changed, 11 insertions(+), 11 deletions(-)

> 

> diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c

> index ab6999ae209..2a6bfb1b3f7 100644

> --- a/gdb/arm-tdep.c

> +++ b/gdb/arm-tdep.c

> @@ -9470,6 +9470,17 @@ arm_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)

>       set_gdbarch_long_double_format (gdbarch, floatformats_ieee_double);

>     }

> 

> +  if (tdesc_data != nullptr)

> +    {

> +      set_tdesc_pseudo_register_name (gdbarch, arm_register_name);

> +

> +      tdesc_use_registers (gdbarch, tdesc, std::move (tdesc_data));

> +

> +      /* Override tdesc_register_type to adjust the types of VFP

> +	 registers for NEON.  */

> +      set_gdbarch_register_type (gdbarch, arm_register_type);

> +    }

> +

>   if (have_vfp_pseudos)

>     {

>       /* NOTE: These are the only pseudo registers used by

> @@ -9484,17 +9495,6 @@ arm_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)

>       set_gdbarch_pseudo_register_write (gdbarch, arm_pseudo_write);

>     }

> 

> -  if (tdesc_data != nullptr)

> -    {

> -      set_tdesc_pseudo_register_name (gdbarch, arm_register_name);

> -

> -      tdesc_use_registers (gdbarch, tdesc, std::move (tdesc_data));

> -

> -      /* Override tdesc_register_type to adjust the types of VFP

> -	 registers for NEON.  */

> -      set_gdbarch_register_type (gdbarch, arm_register_type);

> -    }

> -

>   /* Add standard register aliases.  We add aliases even for those

>      names which are used by the current architecture - it's simpler,

>      and does no harm, since nothing ever lists user registers.  */

> -- 

> 2.25.1

>

Patch

diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index ab6999ae209..2a6bfb1b3f7 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -9470,6 +9470,17 @@  arm_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
       set_gdbarch_long_double_format (gdbarch, floatformats_ieee_double);
     }
 
+  if (tdesc_data != nullptr)
+    {
+      set_tdesc_pseudo_register_name (gdbarch, arm_register_name);
+
+      tdesc_use_registers (gdbarch, tdesc, std::move (tdesc_data));
+
+      /* Override tdesc_register_type to adjust the types of VFP
+	 registers for NEON.  */
+      set_gdbarch_register_type (gdbarch, arm_register_type);
+    }
+
   if (have_vfp_pseudos)
     {
       /* NOTE: These are the only pseudo registers used by
@@ -9484,17 +9495,6 @@  arm_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
       set_gdbarch_pseudo_register_write (gdbarch, arm_pseudo_write);
     }
 
-  if (tdesc_data != nullptr)
-    {
-      set_tdesc_pseudo_register_name (gdbarch, arm_register_name);
-
-      tdesc_use_registers (gdbarch, tdesc, std::move (tdesc_data));
-
-      /* Override tdesc_register_type to adjust the types of VFP
-	 registers for NEON.  */
-      set_gdbarch_register_type (gdbarch, arm_register_type);
-    }
-
   /* Add standard register aliases.  We add aliases even for those
      names which are used by the current architecture - it's simpler,
      and does no harm, since nothing ever lists user registers.  */