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.
+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.
+
2014-02-12 Sanimir Agovic <sanimir.agovic@intel.com>
* nios2-tdep.c (nios2_stub_frame_base): Remove global.
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)
{
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: