* FYI: DW_FORM_ref_addr -vs- DWARF 3
@ 2010-03-04 22:00 Tom Tromey
2010-03-05 4:58 ` Joel Brobecker
0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2010-03-04 22:00 UTC (permalink / raw)
To: gdb-patches
I'm checking this in. I will probably push it into 7.1 as well; let me
know what you think of this.
DWARF 3 changed DW_FORM_ref_addr to use an offset-sized value instead of
an address-sized value. GDB does not cope with this, which can cause
crashes. For a real-life example:
https://bugzilla.redhat.com/show_bug.cgi?id=552619
I found this in the archives, after writing my patch:
http://sourceware.org/ml/gdb-patches/2006-06/msg00286.html
I guess it was never reviewed? I dunno. Anyway, I prefer my patch.
Built and regression tested on x86-64 (compile farm).
I also verified it before- and after- on the test program I have.
Tom
2010-03-04 Tom Tromey <tromey@redhat.com>
* dwarf2read.c (skip_one_die) <DW_FORM_ref_addr>: Use offset size
in DWARF 3 and later.
(read_attribute_value) <DW_FORM_ref_addr>: Likewise.
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index a05c946..b2558f0 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -2881,8 +2881,15 @@ skip_one_die (gdb_byte *buffer, gdb_byte *info_ptr,
skip_attribute:
switch (form)
{
- case DW_FORM_addr:
case DW_FORM_ref_addr:
+ /* In DWARF 2, DW_FORM_ref_addr is address sized; in DWARF 3
+ and later it is offset sized. */
+ if (cu->header.version == 2)
+ info_ptr += cu->header.addr_size;
+ else
+ info_ptr += cu->header.offset_size;
+ break;
+ case DW_FORM_addr:
info_ptr += cu->header.addr_size;
break;
case DW_FORM_data1:
@@ -7016,8 +7023,14 @@ read_attribute_value (struct attribute *attr, unsigned form,
attr->form = form;
switch (form)
{
- case DW_FORM_addr:
case DW_FORM_ref_addr:
+ if (cu->header.version == 2)
+ DW_ADDR (attr) = read_address (abfd, info_ptr, cu, &bytes_read);
+ else
+ DW_ADDR (attr) = read_offset (abfd, info_ptr, &cu->header, &bytes_read);
+ info_ptr += bytes_read;
+ break;
+ case DW_FORM_addr:
DW_ADDR (attr) = read_address (abfd, info_ptr, cu, &bytes_read);
info_ptr += bytes_read;
break;
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: FYI: DW_FORM_ref_addr -vs- DWARF 3
2010-03-04 22:00 FYI: DW_FORM_ref_addr -vs- DWARF 3 Tom Tromey
@ 2010-03-05 4:58 ` Joel Brobecker
2010-03-05 16:02 ` Tom Tromey
0 siblings, 1 reply; 3+ messages in thread
From: Joel Brobecker @ 2010-03-05 4:58 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
Hi Tom,
> 2010-03-04 Tom Tromey <tromey@redhat.com>
>
> * dwarf2read.c (skip_one_die) <DW_FORM_ref_addr>: Use offset size
> in DWARF 3 and later.
> (read_attribute_value) <DW_FORM_ref_addr>: Likewise.
This patch looks fine to me for head and branch. I don't know which
version I prefer, between Jim's and yours, but yours is smaller :).
--
Joel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: FYI: DW_FORM_ref_addr -vs- DWARF 3
2010-03-05 4:58 ` Joel Brobecker
@ 2010-03-05 16:02 ` Tom Tromey
0 siblings, 0 replies; 3+ messages in thread
From: Tom Tromey @ 2010-03-05 16:02 UTC (permalink / raw)
To: Joel Brobecker; +Cc: gdb-patches
>>>>> "Joel" == Joel Brobecker <brobecker@adacore.com> writes:
Joel> Hi Tom,
>> 2010-03-04 Tom Tromey <tromey@redhat.com>
>>
>> * dwarf2read.c (skip_one_die) <DW_FORM_ref_addr>: Use offset size
>> in DWARF 3 and later.
>> (read_attribute_value) <DW_FORM_ref_addr>: Likewise.
Joel> This patch looks fine to me for head and branch. I don't know which
Joel> version I prefer, between Jim's and yours, but yours is smaller :).
:) Thanks, I checked this in to the 7.1 branch as well.
Tom
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-03-05 16:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-04 22:00 FYI: DW_FORM_ref_addr -vs- DWARF 3 Tom Tromey
2010-03-05 4:58 ` Joel Brobecker
2010-03-05 16:02 ` Tom Tromey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox