* [RFA] x86-64 dwarf2 regnum mapping
@ 2002-04-30 5:28 Michal Ludvig
2002-05-02 1:30 ` Michal Ludvig
0 siblings, 1 reply; 5+ messages in thread
From: Michal Ludvig @ 2002-04-30 5:28 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 433 bytes --]
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
--
* SuSE CR, s.r.o * mludvig@suse.cz
* +420 2 9654 5373 * http://www.suse.cz
[-- Attachment #2: dwarf2regnum.diff --]
[-- Type: text/plain, Size: 2994 bytes --]
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;
}
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFA] x86-64 dwarf2 regnum mapping
2002-04-30 5:28 [RFA] x86-64 dwarf2 regnum mapping Michal Ludvig
@ 2002-05-02 1:30 ` Michal Ludvig
2002-05-02 8:16 ` Andrew Cagney
2002-05-02 11:14 ` Michael Snyder
0 siblings, 2 replies; 5+ messages in thread
From: Michal Ludvig @ 2002-05-02 1:30 UTC (permalink / raw)
To: gdb-patches
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;
> }
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFA] x86-64 dwarf2 regnum mapping
2002-05-02 1:30 ` Michal Ludvig
@ 2002-05-02 8:16 ` Andrew Cagney
2002-05-02 11:14 ` Michael Snyder
1 sibling, 0 replies; 5+ messages in thread
From: Andrew Cagney @ 2002-05-02 8:16 UTC (permalink / raw)
To: Michal Ludvig; +Cc: gdb-patches
> No response? Can I commit?
Sorry, yes, definitly.
Andrew
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFA] x86-64 dwarf2 regnum mapping
2002-05-02 1:30 ` Michal Ludvig
2002-05-02 8:16 ` Andrew Cagney
@ 2002-05-02 11:14 ` Michael Snyder
2002-05-03 3:54 ` Michal Ludvig
1 sibling, 1 reply; 5+ messages in thread
From: Michael Snyder @ 2002-05-02 11:14 UTC (permalink / raw)
To: Michal Ludvig; +Cc: gdb-patches
Michal Ludvig wrote:
> > 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?
I imagine because one file was cloned from the other.
> Can I rename it?
Probably a good idea. Please do.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFA] x86-64 dwarf2 regnum mapping
2002-05-02 11:14 ` Michael Snyder
@ 2002-05-03 3:54 ` Michal Ludvig
0 siblings, 0 replies; 5+ messages in thread
From: Michal Ludvig @ 2002-05-03 3:54 UTC (permalink / raw)
To: Michael Snyder; +Cc: gdb-patches
Michael Snyder wrote:
> Michal Ludvig wrote:
>> > 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?
> I imagine because one file was cloned from the other.
>>Can I rename it?
> Probably a good idea. Please do.
OK, done.
Michal Ludvig
--
* SuSE CR, s.r.o * mludvig@suse.cz
* +420 2 9654 5373 * http://www.suse.cz
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2002-05-03 10:54 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-04-30 5:28 [RFA] x86-64 dwarf2 regnum mapping Michal Ludvig
2002-05-02 1:30 ` Michal Ludvig
2002-05-02 8:16 ` Andrew Cagney
2002-05-02 11:14 ` Michael Snyder
2002-05-03 3:54 ` Michal Ludvig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox