This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
RFA: Correctly interpret register numbers in Dwarf2 output
- To: gdb-patches at sources dot redhat dot com
- Subject: RFA: Correctly interpret register numbers in Dwarf2 output
- From: Jim Blandy <jimb at zwingli dot cygnus dot com>
- Date: Mon, 7 May 2001 01:31:56 -0500 (EST)
2001-05-06 Jim Blandy <jimb@redhat.com>
* mn10300-tdep.c (mn10300_dwarf2_reg_to_regnum): New function.
(mn10300_gdbarch_init): Register it as the architecture's
dwarf2_reg_to_regnum method.
*** gdb/mn10300-tdep.c.base Fri May 4 14:54:52 2001
--- gdb/mn10300-tdep.c Sun May 6 20:53:08 2001
***************
*** 857,862 ****
--- 857,891 ----
return 4;
}
+ /* If DWARF2 is a register number appearing in Dwarf2 debug info, then
+ mn10300_dwarf2_reg_to_regnum (DWARF2) is the corresponding GDB
+ register number. Why don't Dwarf2 and GDB use the same numbering?
+ Who knows? But since people have object files lying around with
+ the existing Dwarf2 numbering, and other people have written stubs
+ to work with the existing GDB, neither of them can change. So we
+ just have to cope. */
+ static int
+ mn10300_dwarf2_reg_to_regnum (int dwarf2)
+ {
+ /* This table is supposed to be shaped like the REGISTER_NAMES
+ initializer in gcc/config/mn10300/mn10300.h. Registers which
+ appear in GCC's numbering, but have no counterpart in GDB's
+ world, are marked with a -1. */
+ static int dwarf2_to_gdb[] = {
+ 0, 1, 2, 3, 4, 5, 6, 7, -1, 8,
+ 15, 16, 17, 18, 19, 20, 21, 22
+ };
+ int gdb;
+
+ if (dwarf2 < 0
+ || dwarf2 >= (sizeof (dwarf2_to_gdb) / sizeof (dwarf2_to_gdb[0]))
+ || dwarf2_to_gdb[dwarf2] == -1)
+ internal_error (__FILE__, __LINE__,
+ "bogus register number in debug info: %d", dwarf2);
+
+ return dwarf2_to_gdb[dwarf2];
+ }
+
static void
mn10300_print_register (const char *name, int regnum, int reg_width)
{
***************
*** 1005,1010 ****
--- 1034,1040 ----
set_gdbarch_max_register_virtual_size (gdbarch, 4);
set_gdbarch_register_virtual_size (gdbarch, mn10300_register_virtual_size);
set_gdbarch_register_virtual_type (gdbarch, mn10300_register_virtual_type);
+ set_gdbarch_dwarf2_reg_to_regnum (gdbarch, mn10300_dwarf2_reg_to_regnum);
set_gdbarch_do_registers_info (gdbarch, mn10300_do_registers_info);
set_gdbarch_fp_regnum (gdbarch, 31);