This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH] Map registers to remote numbers when encoding an ax_reg or ax_reg_mask operation
- From: Antoine Tremblay <antoine dot tremblay at ericsson dot com>
- To: <gdb-patches at sourceware dot org>
- Cc: Antoine Tremblay <antoine dot tremblay at ericsson dot com>
- Date: Thu, 25 Feb 2016 08:25:45 -0500
- Subject: [PATCH] Map registers to remote numbers when encoding an ax_reg or ax_reg_mask operation
- Authentication-results: sourceware.org; auth=none
When encoding the agent expression operation ax_reg or ax_reg_mask, the
register number used is internal to GDB. However GDBServer expects a tdesc
based number.
This usually does not cause a problem since at the moment, for raw
registers GDBServer R trace action ignores the register mask and just
collects all registers.
It can be a problem, however with pseudo registers on some platforms if the
tdesc number doesn't match the GDB internal register number.
This is the case with ARM, the upcoming ARM tracepoint support, fails
these test cases without this patch:
gdb.trace/collection.exp: collect register locals collectively:*
GDBSever would exit with: unhandled register size
Since the register number is not mapped.
This patch fixes these issues by calling gdbarch_remote_register_number
before encoding the register number in the ax_reg or ax_reg_mask operation.
Tested on x86 native-gdbserver no regressions observed.
---
gdb/ax-general.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/gdb/ax-general.c b/gdb/ax-general.c
index 30f90e8..eb0e6fc 100644
--- a/gdb/ax-general.c
+++ b/gdb/ax-general.c
@@ -308,6 +308,9 @@ ax_reg (struct agent_expr *x, int reg)
}
else
{
+ /* Get the remote register number. */
+ reg = gdbarch_remote_register_number (x->gdbarch, reg);
+
/* Make sure the register number is in range. */
if (reg < 0 || reg > 0xffff)
error (_("GDB bug: ax-general.c (ax_reg): "
@@ -456,7 +459,11 @@ ax_reg_mask (struct agent_expr *ax, int reg)
}
else
{
- int byte = reg / 8;
+ int byte = 0;
+
+ /* Get the remote register number. */
+ reg = gdbarch_remote_register_number (ax->gdbarch, reg);
+ byte = reg / 8;
/* Grow the bit mask if necessary. */
if (byte >= ax->reg_mask_len)
--
2.6.4