* [PATCH] Fix dwarf register column to gdb register mapping
@ 2008-09-13 23:32 John David Anglin
2008-09-14 1:01 ` Randolph Chung
0 siblings, 1 reply; 4+ messages in thread
From: John David Anglin @ 2008-09-13 23:32 UTC (permalink / raw)
To: gdb-patches; +Cc: randolph
The following revises hppa_dwarf_reg_to_regnum and hppa64_dwarf_reg_to_regnum
to implement my understanding of the mapping needed on hppa. The dwarf
columns essentially correspond one-to-one to the GCC internal register
numbering. I think someone must have been looking at the dbx numbering
when these routines were first implemented. The numbering used by gdb
for hppa is in hppa-tdep.h.
The sniffer stuff is obsolete.
Tested on hppa64-hp-hpux11.11 and hppa-unknown-linux-gnu.
Ok?
Dave
--
J. David Anglin dave.anglin@nrc-cnrc.gc.ca
National Research Council of Canada (613) 990-0752 (FAX: 952-6602)
2008-09-13 John David Anglin <dave.anglin@nrc-cnrc.gc.ca>
* hppa-linux-tdep.c (hppa_dwarf_reg_to_regnum): Remove "#if 0" "#endif".
Fix mapping of dwarf columns to gdb registers.
(hppa_linux_init_abi): Call set_gdbarch_dwarf2_reg_to_regnum. Delete
disabled code.
* hppa-tdep.c (hppa64_dwarf_reg_to_regnum): Fix mapping of dwarf columns
to gdb registers.
Index: hppa-linux-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/hppa-linux-tdep.c,v
retrieving revision 1.31
diff -u -3 -p -r1.31 hppa-linux-tdep.c
--- hppa-linux-tdep.c 21 Aug 2008 13:19:18 -0000 1.31
+++ hppa-linux-tdep.c 13 Sep 2008 22:51:35 -0000
@@ -34,24 +34,26 @@
#include "elf/common.h"
-#if 0
/* Convert DWARF register number REG to the appropriate register
number used by GDB. */
static int
-hppa_dwarf_reg_to_regnum (int reg)
+hppa_dwarf_reg_to_regnum (struct gdbarch *gdbarch, int reg)
{
- /* registers 0 - 31 are the same in both sets */
- if (reg < 32)
+ /* r1-r31 are the same in both sets (column for r0 is not used) */
+ if (reg >= 1 && reg < 32)
return reg;
- /* dwarf regs 32 to 85 are fpregs 4 - 31 */
- if (reg >= 32 && reg <= 85)
+ /* Dwarf registers 32 to 87 are the floating point registers fr4 to fr31. */
+ if (reg >= 32 && reg < 88)
return HPPA_FP4_REGNUM + (reg - 32);
+ /* Dwarf register 88 is the sar register. */
+ if (reg == 88)
+ return HPPA_SAR_REGNUM;
+
warning (_("Unmapped DWARF Register #%d encountered."), reg);
return -1;
}
-#endif
static void
hppa_linux_target_write_pc (struct regcache *regcache, CORE_ADDR v)
@@ -545,12 +548,7 @@ hppa_linux_init_abi (struct gdbarch_info
set_gdbarch_regset_from_core_section
(gdbarch, hppa_linux_regset_from_core_section);
-#if 0
- /* Dwarf-2 unwinding support. Not yet working. */
set_gdbarch_dwarf2_reg_to_regnum (gdbarch, hppa_dwarf_reg_to_regnum);
- frame_unwind_append_sniffer (gdbarch, dwarf2_frame_sniffer);
- frame_base_append_sniffer (gdbarch, dwarf2_frame_base_sniffer);
-#endif
/* Enable TLS support. */
set_gdbarch_fetch_tls_load_module_address (gdbarch,
Index: hppa-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/hppa-tdep.c,v
retrieving revision 1.260
diff -u -3 -p -r1.260 hppa-tdep.c
--- hppa-tdep.c 11 Sep 2008 14:23:15 -0000 1.260
+++ hppa-tdep.c 13 Sep 2008 22:51:35 -0000
@@ -661,13 +661,17 @@ hppa64_register_name (struct gdbarch *gd
static int
hppa64_dwarf_reg_to_regnum (struct gdbarch *gdbarch, int reg)
{
- /* r0-r31 and sar map one-to-one. */
- if (reg <= 32)
+ /* r1-r31 are the same in both sets (column for r0 is not used). */
+ if (reg >= 1 && reg < 32)
return reg;
- /* fr4-fr31 are mapped from 72 in steps of 2. */
- if (reg >= 72 || reg < 72 + 28 * 2)
- return HPPA64_FP4_REGNUM + (reg - 72) / 2;
+ /* fr4-fr31 are mapped to 72, 74, 76 ... */
+ if (reg >= 32 && reg < 60)
+ return HPPA64_FP4_REGNUM + 2 * (reg - 32);
+
+ /* Dwarf register 60 is the sar register. */
+ if (reg == 60)
+ return HPPA_SAR_REGNUM;
error ("Invalid DWARF register num %d.", reg);
return -1;
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] Fix dwarf register column to gdb register mapping
2008-09-13 23:32 [PATCH] Fix dwarf register column to gdb register mapping John David Anglin
@ 2008-09-14 1:01 ` Randolph Chung
2008-09-14 19:35 ` John David Anglin
0 siblings, 1 reply; 4+ messages in thread
From: Randolph Chung @ 2008-09-14 1:01 UTC (permalink / raw)
To: John David Anglin; +Cc: gdb-patches
When I enabled the dwarf debugging support in gdb before i caused
various errors and warnings about incorrect cfi. Do you still see that
with this enabled? Is it compiler dependent? Because of those warnings
and errors I had disabled the dwarf stuff on hppa before.
Looks good to me otherwise. Thanks for fixing it.
randolph
On Sat, Sep 13, 2008 at 4:32 PM, John David Anglin
<dave@hiauly1.hia.nrc.ca> wrote:
> The following revises hppa_dwarf_reg_to_regnum and hppa64_dwarf_reg_to_regnum
> to implement my understanding of the mapping needed on hppa. The dwarf
> columns essentially correspond one-to-one to the GCC internal register
> numbering. I think someone must have been looking at the dbx numbering
> when these routines were first implemented. The numbering used by gdb
> for hppa is in hppa-tdep.h.
>
> The sniffer stuff is obsolete.
>
> Tested on hppa64-hp-hpux11.11 and hppa-unknown-linux-gnu.
>
> Ok?
>
> Dave
> --
> J. David Anglin dave.anglin@nrc-cnrc.gc.ca
> National Research Council of Canada (613) 990-0752 (FAX: 952-6602)
>
> 2008-09-13 John David Anglin <dave.anglin@nrc-cnrc.gc.ca>
>
> * hppa-linux-tdep.c (hppa_dwarf_reg_to_regnum): Remove "#if 0" "#endif".
> Fix mapping of dwarf columns to gdb registers.
> (hppa_linux_init_abi): Call set_gdbarch_dwarf2_reg_to_regnum. Delete
> disabled code.
> * hppa-tdep.c (hppa64_dwarf_reg_to_regnum): Fix mapping of dwarf columns
> to gdb registers.
>
> Index: hppa-linux-tdep.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/hppa-linux-tdep.c,v
> retrieving revision 1.31
> diff -u -3 -p -r1.31 hppa-linux-tdep.c
> --- hppa-linux-tdep.c 21 Aug 2008 13:19:18 -0000 1.31
> +++ hppa-linux-tdep.c 13 Sep 2008 22:51:35 -0000
> @@ -34,24 +34,26 @@
>
> #include "elf/common.h"
>
> -#if 0
> /* Convert DWARF register number REG to the appropriate register
> number used by GDB. */
> static int
> -hppa_dwarf_reg_to_regnum (int reg)
> +hppa_dwarf_reg_to_regnum (struct gdbarch *gdbarch, int reg)
> {
> - /* registers 0 - 31 are the same in both sets */
> - if (reg < 32)
> + /* r1-r31 are the same in both sets (column for r0 is not used) */
> + if (reg >= 1 && reg < 32)
> return reg;
>
> - /* dwarf regs 32 to 85 are fpregs 4 - 31 */
> - if (reg >= 32 && reg <= 85)
> + /* Dwarf registers 32 to 87 are the floating point registers fr4 to fr31. */
> + if (reg >= 32 && reg < 88)
> return HPPA_FP4_REGNUM + (reg - 32);
>
> + /* Dwarf register 88 is the sar register. */
> + if (reg == 88)
> + return HPPA_SAR_REGNUM;
> +
> warning (_("Unmapped DWARF Register #%d encountered."), reg);
> return -1;
> }
> -#endif
>
> static void
> hppa_linux_target_write_pc (struct regcache *regcache, CORE_ADDR v)
> @@ -545,12 +548,7 @@ hppa_linux_init_abi (struct gdbarch_info
> set_gdbarch_regset_from_core_section
> (gdbarch, hppa_linux_regset_from_core_section);
>
> -#if 0
> - /* Dwarf-2 unwinding support. Not yet working. */
> set_gdbarch_dwarf2_reg_to_regnum (gdbarch, hppa_dwarf_reg_to_regnum);
> - frame_unwind_append_sniffer (gdbarch, dwarf2_frame_sniffer);
> - frame_base_append_sniffer (gdbarch, dwarf2_frame_base_sniffer);
> -#endif
>
> /* Enable TLS support. */
> set_gdbarch_fetch_tls_load_module_address (gdbarch,
> Index: hppa-tdep.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/hppa-tdep.c,v
> retrieving revision 1.260
> diff -u -3 -p -r1.260 hppa-tdep.c
> --- hppa-tdep.c 11 Sep 2008 14:23:15 -0000 1.260
> +++ hppa-tdep.c 13 Sep 2008 22:51:35 -0000
> @@ -661,13 +661,17 @@ hppa64_register_name (struct gdbarch *gd
> static int
> hppa64_dwarf_reg_to_regnum (struct gdbarch *gdbarch, int reg)
> {
> - /* r0-r31 and sar map one-to-one. */
> - if (reg <= 32)
> + /* r1-r31 are the same in both sets (column for r0 is not used). */
> + if (reg >= 1 && reg < 32)
> return reg;
>
> - /* fr4-fr31 are mapped from 72 in steps of 2. */
> - if (reg >= 72 || reg < 72 + 28 * 2)
> - return HPPA64_FP4_REGNUM + (reg - 72) / 2;
> + /* fr4-fr31 are mapped to 72, 74, 76 ... */
> + if (reg >= 32 && reg < 60)
> + return HPPA64_FP4_REGNUM + 2 * (reg - 32);
> +
> + /* Dwarf register 60 is the sar register. */
> + if (reg == 60)
> + return HPPA_SAR_REGNUM;
>
> error ("Invalid DWARF register num %d.", reg);
> return -1;
>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] Fix dwarf register column to gdb register mapping
2008-09-14 1:01 ` Randolph Chung
@ 2008-09-14 19:35 ` John David Anglin
0 siblings, 0 replies; 4+ messages in thread
From: John David Anglin @ 2008-09-14 19:35 UTC (permalink / raw)
To: Randolph Chung; +Cc: gdb-patches
> When I enabled the dwarf debugging support in gdb before i caused
> various errors and warnings about incorrect cfi. Do you still see that
> with this enabled? Is it compiler dependent? Because of those warnings
> and errors I had disabled the dwarf stuff on hppa before.
Investigating some more, I see there's a problem with the floating
point registers. A break on wack_double demonstrates the problem
on both hppa64-hpux and hppa-linux:
Starting program: /home/dave/xxx
Breakpoint 1, wack_double (u=warning: Unmapped DWARF Register #108 encountered.
../../src/gdb/regcache.c:164: internal-error: register_type: Assertion `regnum >= 0 && regnum < descr->nr_cooked_registers' failed.
Same problem for a break on add_double.
.debug_frame for wack_double appears ok when I dump it with readelf -wf:
0000002c 00000020 00000000 FDE cie=00000000 pc=00000028..0000008c
DW_CFA_advance_loc: 8 to 00000030
DW_CFA_register: r3 in r1
DW_CFA_offset_extended_sf: r2 at cfa-20
DW_CFA_advance_loc: 4 to 00000034
DW_CFA_def_cfa_register: r3
DW_CFA_advance_loc: 4 to 00000038
DW_CFA_offset: r3 at cfa+0
DW_CFA_advance_loc: 8 to 00000040
DW_CFA_offset: r49 at cfa+20
DW_CFA_offset: r48 at cfa+16
DW_CFA_nop
DW_CFA_nop
It gets the correct columns for the floating register saves. So, I
think it's gdb which has the problem. It's possible it is confused
by the fact that the stores are done using r1.
I'm going to look at the effect of disabling dwarf register numbers
on hppa64-hpux.
Dave
--
J. David Anglin dave.anglin@nrc-cnrc.gc.ca
National Research Council of Canada (613) 990-0752 (FAX: 952-6602)
double
add_double (register double u, register double v)
{
return u + v;
}
double
wack_double (register double u, register double v)
{
register double l = u, r = v;
l = add_double (l, r);
return l + r;
}
int
main ()
{
wack_double (-1, -2);
return 0;
}
^ permalink raw reply [flat|nested] 4+ messages in thread
[parent not found: <no.id>]
* Re: [PATCH] Fix dwarf register column to gdb register mapping
[not found] <no.id>
@ 2008-09-15 2:08 ` John David Anglin
0 siblings, 0 replies; 4+ messages in thread
From: John David Anglin @ 2008-09-15 2:08 UTC (permalink / raw)
To: John David Anglin; +Cc: randolph, gdb-patches
> > When I enabled the dwarf debugging support in gdb before i caused
> > various errors and warnings about incorrect cfi. Do you still see that
> > with this enabled? Is it compiler dependent? Because of those warnings
> > and errors I had disabled the dwarf stuff on hppa before.
>
> Investigating some more, I see there's a problem with the floating
> point registers. A break on wack_double demonstrates the problem
> on both hppa64-hpux and hppa-linux:
The following change fixes the problem. The confusion was between "dbx"
register numbers and "dwarf" register columns. The hppa64 implementation
was essentially correct except for a botched if statement. I tried to
make it clear in the change that the mapping is for dbx registers.
As far as I can tell, the dwarf debugging support is now enabled by default
and the ifdef'd out code no longer works to disable it. So, the mapping
had to be fixed.
Committed as follows.
Dave
--
J. David Anglin dave.anglin@nrc-cnrc.gc.ca
National Research Council of Canada (613) 990-0752 (FAX: 952-6602)
2008-09-14 John David Anglin <dave.anglin@nrc-cnrc.gc.ca>
* hppa-linux-tdep.c (hppa_dwarf_reg_to_regnum): Remove surrounding
"#if 0" "#endif". Fix mapping of DWARF DBX registers to GDB registers.
Correct arguments and improve comments.
(hppa_linux_init_abi): Call set_gdbarch_dwarf2_reg_to_regnum. Delete
disabled code.
* hppa-tdep.c (hppa64_dwarf_reg_to_regnum): Fix check for floating
point DBX register, change error to warning, and improve comments.
Index: hppa-linux-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/hppa-linux-tdep.c,v
retrieving revision 1.32
diff -u -3 -p -r1.32 hppa-linux-tdep.c
--- hppa-linux-tdep.c 14 Sep 2008 14:08:42 -0000 1.32
+++ hppa-linux-tdep.c 15 Sep 2008 01:33:28 -0000
@@ -34,24 +34,21 @@
#include "elf/common.h"
-#if 0
-/* Convert DWARF register number REG to the appropriate register
- number used by GDB. */
+/* Map DWARF DBX register numbers to GDB register numbers. */
static int
-hppa_dwarf_reg_to_regnum (int reg)
+hppa_dwarf_reg_to_regnum (struct gdbarch *gdbarch, int reg)
{
- /* registers 0 - 31 are the same in both sets */
- if (reg < 32)
+ /* The general registers and the sar are the same in both sets. */
+ if (reg <= 32)
return reg;
- /* dwarf regs 32 to 85 are fpregs 4 - 31 */
- if (reg >= 32 && reg <= 85)
- return HPPA_FP4_REGNUM + (reg - 32);
+ /* fr4-fr31 (left and right halves) are mapped from 72. */
+ if (reg >= 72 && reg <= 72 + 28 * 2)
+ return HPPA_FP4_REGNUM + (reg - 72);
- warning (_("Unmapped DWARF Register #%d encountered."), reg);
+ warning (_("Unmapped DWARF DBX Register #%d encountered."), reg);
return -1;
}
-#endif
static void
hppa_linux_target_write_pc (struct regcache *regcache, CORE_ADDR v)
@@ -545,12 +545,7 @@ hppa_linux_init_abi (struct gdbarch_info
set_gdbarch_regset_from_core_section
(gdbarch, hppa_linux_regset_from_core_section);
-#if 0
- /* Dwarf-2 unwinding support. Not yet working. */
set_gdbarch_dwarf2_reg_to_regnum (gdbarch, hppa_dwarf_reg_to_regnum);
- frame_unwind_append_sniffer (gdbarch, dwarf2_frame_sniffer);
- frame_base_append_sniffer (gdbarch, dwarf2_frame_base_sniffer);
-#endif
/* Enable TLS support. */
set_gdbarch_fetch_tls_load_module_address (gdbarch,
Index: hppa-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/hppa-tdep.c,v
retrieving revision 1.260
diff -u -3 -p -r1.260 hppa-tdep.c
--- hppa-tdep.c 11 Sep 2008 14:23:15 -0000 1.260
+++ hppa-tdep.c 15 Sep 2008 01:33:29 -0000
@@ -658,18 +658,19 @@ hppa64_register_name (struct gdbarch *gd
return names[i];
}
+/* Map dwarf DBX register numbers to GDB register numbers. */
static int
hppa64_dwarf_reg_to_regnum (struct gdbarch *gdbarch, int reg)
{
- /* r0-r31 and sar map one-to-one. */
+ /* The general registers and the sar are the same in both sets. */
if (reg <= 32)
return reg;
/* fr4-fr31 are mapped from 72 in steps of 2. */
- if (reg >= 72 || reg < 72 + 28 * 2)
+ if (reg >= 72 && reg < 72 + 28 * 2 && !(reg & 1))
return HPPA64_FP4_REGNUM + (reg - 72) / 2;
- error ("Invalid DWARF register num %d.", reg);
+ warning (_("Unmapped DWARF DBX Register #%d encountered."), reg);
return -1;
}
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-09-15 2:08 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-09-13 23:32 [PATCH] Fix dwarf register column to gdb register mapping John David Anglin
2008-09-14 1:01 ` Randolph Chung
2008-09-14 19:35 ` John David Anglin
[not found] <no.id>
2008-09-15 2:08 ` John David Anglin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox