Map registers to remote numbers when encoding an ax_reg or ax_reg_mask operation
authorAntoine Tremblay <antoine.tremblay@ericsson.com>
Wed, 24 Feb 2016 20:00:17 +0000 (15:00 -0500)
committerAntoine Tremblay <antoine.tremblay@ericsson.com>
Thu, 25 Feb 2016 14:34:30 +0000 (09:34 -0500)
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/ChangeLog:

* ax-general.c (ax_reg): Call gdbarch_remote_register_number.
(ax_reg_mask): Likewise.

gdb/ChangeLog
gdb/ax-general.c

index 0d6ea60bf7274d0e692384bf88f641ad6e09074c..dc123996c544ce3a978ab9333bf40f16d0d6754c 100644 (file)
@@ -1,3 +1,8 @@
+2016-02-25  Antoine Tremblay  <antoine.tremblay@ericsson.com>
+
+       * ax-general.c (ax_reg): Call gdbarch_remote_register_number.
+       (ax_reg_mask): Likewise.
+
 2016-02-24  Pedro Alves  <palves@redhat.com>
 
        * linux-nat.c (save_sigtrap) Delete.
index 30f90e897120d1d4a6c9818ddca8e2bd5046d342..7f27a458a98089713b48605e289e49b75b0140c1 100644 (file)
@@ -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;
+
+      /* 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)
This page took 0.027515 seconds and 4 git commands to generate.