[patch 2/2] Implement gdbarch hook user_register_name on ARM

Yao Qi
2010-12-15T10:48:07Z

[-- Attachment #1: Type: text/plain, Size: 418 bytes --]

On 12/15/2010 06:22 PM, Yao Qi wrote:
> Once this patch is applied, we leave more flexibility to backend to
> determine what is the correct register number given a register alias.

This patch is to implement user_register_name on ARM. With this, we can
handle alias "fp" according to the current frame's mode (ARM or Thumb).

Regression testing is still running on ARM. Comments are welcome.

--
Yao (é½å°§)

[-- Attachment #2: gdbarch_user_register_name_p2.patch --]
[-- Type: text/x-patch, Size: 1611 bytes --]

2010-12-15 Yao Qi <yao@codesourcery.com>

* arm-tdep.c (arm_user_register_name): New.
(arm_gdbarch_init): Install arm_user_register_nam on gdbarch hook
user_register_name.

diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index 636c1de..618f82f 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -2918,6 +2918,27 @@ arm_neon_quad_type (struct gdbarch *gdbarch)
return tdep->neon_quad_type;
}

+static int
+arm_user_register_name (struct gdbarch *gdbarch, const char *regname, int len)
+{
+ if ((len < 0 && strcmp ("fp", regname))
+ || (len == strlen ("fp")
+ && strncmp ("fp", regname, len) == 0))
+ {
+ /* `fp' register means different registers on ARM and Thumb. Return
+ the correct `fp' register number according the state of current
+ frame. */
+ struct frame_info *frame = get_selected_frame (NULL);
+ if (arm_frame_is_thumb (frame))
+ return THUMB_FP_REGNUM;
+ else
+ return ARM_FP_REGNUM;
+ }
+ else
+ /* Leave search to other registers to default implementation. */
+ return default_user_register_name (gdbarch, regname, len);
+}
+
/* Return the GDB type object for the "standard" data type of data in
register N. */

@@ -7462,6 +7483,7 @@ arm_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_pc_regnum (gdbarch, ARM_PC_REGNUM);
set_gdbarch_num_regs (gdbarch, ARM_NUM_REGS);
set_gdbarch_register_type (gdbarch, arm_register_type);
+ set_gdbarch_user_register_name (gdbarch, arm_user_register_name);

/* This "info float" is FPA-specific. Use the generic version if we
do not have FPA. */