This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA/DWARF] constant class of DW_AT_high_pc is offset for version >=4 only.
- From: Mark Wielaard <mjw at redhat dot com>
- To: Joel Brobecker <brobecker at adacore dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Tue, 18 Feb 2014 17:02:49 +0100
- Subject: Re: [RFA/DWARF] constant class of DW_AT_high_pc is offset for version >=4 only.
- Authentication-results: sourceware.org; auth=none
- References: <1392478818-30320-1-git-send-email-brobecker at adacore dot com> <20140218133000 dot GA15835 at adacore dot com>
On Tue, 2014-02-18 at 14:30 +0100, Joel Brobecker wrote:
> 1. The introduction of attr_value_as_address, to be used
> in place of DW_ADDR when dealing with address attributes.
> I left a few uses of this macro in the situations where
> we actually know that the form is an address form.
This accepts any form as address/unsigned. I would at least check that
it is either DW_FORM_data4 or DW_FORM_data8 (even better would be to
check the CU address width too, although that would require to pass
around cu too, which might not be practical). Also I would add a comment
that this is really to work around buggy producers.
> 2. Instead of duplicating everywhere the conditions for
> non-address forms in the handling of DW_AT_high_pc
> attributes, I used the attr_form_is_constant function
> instead. It's not stricly the same, but I think it is
> closer to the DWARF reference.
It is closer when used like you do, combined with a check for
cu->header.version >= 4.
> @@ -4201,7 +4217,7 @@ dwarf2_find_base_address (struct die_info *die, struct dwarf2_cu *cu)
> attr = dwarf2_attr (die, DW_AT_entry_pc, cu);
> if (attr)
> {
> - cu->base_address = DW_ADDR (attr);
> + cu->base_address = attr_value_as_address (attr);
> cu->base_known = 1;
> }
Note that this might break for DWARF5. See http://dwarfstd.org/ShowIssue.php?issue=120719.1
In general I would only use attr_value_as_address for attributes (low_pc
and high_pc) which you know a buggy producer might encode with
DW_FORM_data[48].
Cheers,
Mark.