[RFA] x86-64 dwarf2 regnum mapping
Michal Ludvig
mludvig@suse.cz
Thu May 2 01:30:00 GMT 2002
No response? Can I commit?
Michal Ludvig
Michal Ludvig wrote:
> Hi,
> This patch adds mapping from dwarf2 register numbers to gdb ones.
> Surprisingly enough this important part was missing...
> Can I commit to mainline and branch?
>
> BTW Is there a reason why the place where all those
> set_gdbarch_whatever
> functions are called is named i386_gdbarch_init and not
> x86_64_gdbarch_init? Can I rename it?
>
> Michal Ludvig
>
>
> ------------------------------------------------------------------------
>
> 2002-04-30 Michal Ludvig <mludvig@suse.cz>
>
> * x86-64-tdep.c (x86_64_dwarf2gdb_regno_map),
> (x86_64_dwarf2gdb_regno_map_length),
> (x86_64_dwarf2_reg_to_regnum): Added.
> (i386_gdbarch_init): Added registration of
> x86_64_dwarf2_reg_to_regnum.
>
> Index: x86-64-tdep.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/x86-64-tdep.c,v
> retrieving revision 1.15
> diff -c -3 -p -r1.15 x86-64-tdep.c
> *** x86-64-tdep.c 29 Apr 2002 18:27:31 -0000 1.15
> --- x86-64-tdep.c 30 Apr 2002 12:04:15 -0000
> ***************
> *** 37,42 ****
> --- 37,43 ----
> #define RDX_REGNUM 3
> #define RDI_REGNUM 5
> #define EFLAGS_REGNUM 17
> + #define ST0_REGNUM 22
> #define XMM1_REGNUM 39
>
> struct register_info
> *************** static struct register_info x86_64_regis
> *** 106,111 ****
> --- 107,139 ----
> /* 54 */ {4, "mxcsr", &builtin_type_int32}
> };
>
> + /* This array is a mapping from Dwarf-2 register
> + numbering to GDB's one. Dwarf-2 numbering is
> + defined in x86-64 ABI, section 3.6. */
> + static int x86_64_dwarf2gdb_regno_map[] = {
> + 0, 1, 2, 3, /* RAX - RDX */
> + 6, 4, 5, 7, /* RBP, RSI, RDI, RSP */
> + 8, 9, 10, 11, /* R8 - R11 */
> + 12, 13, 14, 15, /* R12 - R15 */
> + -1, /* RA - not mapped */
> + XMM1_REGNUM - 1, XMM1_REGNUM, /* XMM0 ... */
> + XMM1_REGNUM + 1, XMM1_REGNUM + 2,
> + XMM1_REGNUM + 3, XMM1_REGNUM + 4,
> + XMM1_REGNUM + 5, XMM1_REGNUM + 6,
> + XMM1_REGNUM + 7, XMM1_REGNUM + 8,
> + XMM1_REGNUM + 9, XMM1_REGNUM + 10,
> + XMM1_REGNUM + 11, XMM1_REGNUM + 12,
> + XMM1_REGNUM + 13, XMM1_REGNUM + 14, /* ... XMM15 */
> + ST0_REGNUM + 0, ST0_REGNUM + 1, /* ST0 ... */
> + ST0_REGNUM + 2, ST0_REGNUM + 3,
> + ST0_REGNUM + 4, ST0_REGNUM + 5,
> + ST0_REGNUM + 6, ST0_REGNUM + 7 /* ... ST7 */
> + };
> +
> + static int x86_64_dwarf2gdb_regno_map_length =
> + sizeof (x86_64_dwarf2gdb_regno_map) /
> + sizeof (x86_64_dwarf2gdb_regno_map[0]);
> +
> /* Number of all registers */
> #define X86_64_NUM_REGS (sizeof (x86_64_register_info_table) / \
> sizeof (x86_64_register_info_table[0]))
> *************** x86_64_register_convert_to_raw (struct t
> *** 198,203 ****
> --- 226,244 ----
> memcpy (to, from, FPU_REG_RAW_SIZE);
> }
>
> + /* Dwarf-2 <-> GDB register numbers mapping. */
> + int
> + x86_64_dwarf2_reg_to_regnum (int dw_reg)
> + {
> + if (dw_reg < 0 || dw_reg > x86_64_dwarf2gdb_regno_map_length)
> + {
> + warning ("Dwarf-2 uses unmapped register #%d\n", dw_reg);
> + return dw_reg;
> + }
> +
> + return x86_64_dwarf2gdb_regno_map[dw_reg];
> + }
> +
> /* This is the variable that is set with "set disassembly-flavour", and
> its legitimate values. */
> static const char att_flavour[] = "att";
> *************** i386_gdbarch_init (struct gdbarch_info i
> *** 1075,1080 ****
> --- 1116,1123 ----
>
> /* Use dwarf2 debug frame informations. */
> set_gdbarch_dwarf2_build_frame_info (gdbarch,
dwarf2_build_frame_info);
> + set_gdbarch_dwarf2_reg_to_regnum (gdbarch,
x86_64_dwarf2_reg_to_regnum);
> +
> return gdbarch;
> }
>
More information about the Gdb-patches
mailing list