[PATCH 3/4] Enable tracing of pseudo-registers on ARM

Antoine Tremblay
2016-01-07T17:45:17Z

This patch implements the ax_pseudo_register_push_stack and
ax_pseudo_register_collect gdbarch functions so that a pseudo-register can
be traced.

No regressions, tested on ubuntu 14.04 ARMv7 and x86.
With gdbserver-{native,extended} / { -marm -mthumb }

gdb/ChangeLog:

* arm-tdep.c (arm_pseudo_register_to_register): New function.
(arm_ax_pseudo_register_collect): New function.
(arm_ax_pseudo_register_push_stack): New function.
(arm_gdbarch_init): Set
gdbarch_ax_pseudo_register_{collect,push_stack} functions.
---
gdb/arm-tdep.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 63 insertions(+)

diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index 5ee7fb0..562fb2b 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -8752,6 +8752,65 @@ arm_pseudo_write (struct gdbarch *gdbarch, struct regcache *regcache,
}
}

+/* Map the pseudo register number REG to the proper register number. */
+
+static int
+arm_pseudo_register_to_register (struct gdbarch *gdbarch, int reg)
+{
+ int rawnum = 0;
+ int num_regs = gdbarch_num_regs (gdbarch);
+
+ /* Single precision pseudo registers. s0-s31. */
+ if (reg >= num_regs && reg < num_regs + 32)
+ {
+ rawnum = (reg - num_regs) / 2 + 26;
+ }
+ /* Quadruple precision pseudo regisers. q0-q15. */
+ else if (reg >= num_regs + 32 && reg < num_regs + 32 + 16)
+ {
+ rawnum = (reg - num_regs - 32) * 2 + 26;
+ }
+ /* Error bad register number. */
+ else
+ return -1;
+
+ return rawnum;
+}
+
+/* Implementation of the ax_pseudo_register_collect gdbarch function. */
+
+static int
+arm_ax_pseudo_register_collect (struct gdbarch *gdbarch,
+ struct agent_expr *ax, int reg)
+{
+ int rawnum = arm_pseudo_register_to_register (gdbarch, reg);
+
+ /* Error. */
+ if (rawnum < 0)
+ return 1;
+
+ ax_reg_mask (ax, rawnum);
+
+ return 0;
+}
+
+/* Implementation of the ax_pseudo_register_push_stack gdbarch function. */
+
+static int
+arm_ax_pseudo_register_push_stack (struct gdbarch *gdbarch,
+ struct agent_expr *ax, int reg)
+{
+ int rawnum = arm_pseudo_register_to_register (gdbarch, reg);
+
+ /* Error. */
+ if (rawnum < 0)
+ return 1;
+
+ ax_reg (ax, rawnum);
+
+ return 0;
+}
+
static struct value *
value_of_arm_user_reg (struct frame_info *frame, const void *baton)
{
@@ -9413,6 +9472,10 @@ arm_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_num_pseudo_regs (gdbarch, num_pseudos);
set_gdbarch_pseudo_register_read (gdbarch, arm_pseudo_read);
set_gdbarch_pseudo_register_write (gdbarch, arm_pseudo_write);
+ set_gdbarch_ax_pseudo_register_push_stack
+ (gdbarch, arm_ax_pseudo_register_push_stack);
+ set_gdbarch_ax_pseudo_register_collect
+ (gdbarch, arm_ax_pseudo_register_collect);
}

if (tdesc_data)
--
2.6.4