diff options
author | Pedro Alves <palves@redhat.com> | 2014-02-12 12:27:49 +0000 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2014-02-12 12:27:49 +0000 |
commit | 76fd5f745a0ba0b163fada011bece5084b3079c7 (patch) | |
tree | 81b838f220b4ac077e59e7e7631bcc4b59643c24 /gdb/h8300-tdep.c | |
parent | 8f0084065d30812b428df35a82f5edb51e92460d (diff) | |
download | gdb-76fd5f745a0ba0b163fada011bece5084b3079c7.zip gdb-76fd5f745a0ba0b163fada011bece5084b3079c7.tar.gz gdb-76fd5f745a0ba0b163fada011bece5084b3079c7.tar.bz2 |
H8/300: Fix gdb<->sim register mapping.
Currently, printing the H8/300 ccr register when debugging with the
sim is broken:
(gdb) target sim
...
(gdb) load
...
(gdb) start
...
Breakpoint 1, foo (i=0x0 <foo>) at main.c:4
4 {
(gdb) info registers ccr
Register 13 is not available
'13' is the ccr pseudo-register. This pseudo-register provides an
8-bit view into the raw ccr register (regno=8).
The problem is that the H8/300 port does not define a
register_sim_regno gdbarch hook, and thus when fetching the raw
register off of the sim, we end up in legacy_register_sim_regno trying
to figure out the sim register number for the raw CCR register:
int
legacy_register_sim_regno (struct gdbarch *gdbarch, int regnum)
{
/* Only makes sense to supply raw registers. */
gdb_assert (regnum >= 0 && regnum < gdbarch_num_regs (gdbarch));
/* NOTE: cagney/2002-05-13: The old code did it this way and it is
suspected that some GDB/SIM combinations may rely on this
behavour. The default should be one2one_register_sim_regno
(below). */
if (gdbarch_register_name (gdbarch, regnum) != NULL
&& gdbarch_register_name (gdbarch, regnum)[0] != '\0')
return regnum;
else
return LEGACY_SIM_REGNO_IGNORE;
}
Because the raw ccr register does not have a name (so that it is
hidden from the user), that returns LEGACY_SIM_REGNO_IGNORE. That
means that we never actually read the value of the raw ccr register.
Before the <unavailable> support, this must have meant that ccr was
_always_ read as 0... At least, I'm not seeing how this ever worked.
The fix for that is adding a gdbarch_register_sim_regno hook that maps
all raw registers. Looking at sim/h8300/sim-main.h, I believe the
sim's register numbers are compatible with gdb's, so no actual
convertion is necessary.
gdb/
2014-02-12 Pedro Alves <palves@redhat.com>
* h8300-tdep.c (h8300_register_sim_regno): New function.
(h8300_gdbarch_init): Install h8300_register_sim_regno as
gdbarch_register_sim_regno hook.
Diffstat (limited to 'gdb/h8300-tdep.c')
-rw-r--r-- | gdb/h8300-tdep.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/gdb/h8300-tdep.c b/gdb/h8300-tdep.c index ffffbc9..4193287 100644 --- a/gdb/h8300-tdep.c +++ b/gdb/h8300-tdep.c @@ -939,6 +939,22 @@ h8300h_return_value (struct gdbarch *gdbarch, struct value *function, static struct cmd_list_element *setmachinelist; +/* Implementation of 'register_sim_regno' gdbarch method. */ + +static int +h8300_register_sim_regno (struct gdbarch *gdbarch, int regnum) +{ + /* Only makes sense to supply raw registers. */ + gdb_assert (regnum >= 0 && regnum < gdbarch_num_regs (gdbarch)); + + /* We hide the raw ccr from the user by making it nameless. Because + the default register_sim_regno hook returns + LEGACY_SIM_REGNO_IGNORE for unnamed registers, we need to + override it. The sim register numbering is compatible with + gdb's. */ + return regnum; +} + static const char * h8300_register_name (struct gdbarch *gdbarch, int regno) { @@ -1230,6 +1246,8 @@ h8300_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) gdbarch = gdbarch_alloc (&info, 0); + set_gdbarch_register_sim_regno (gdbarch, h8300_register_sim_regno); + switch (info.bfd_arch_info->mach) { case bfd_mach_h8300: |