This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Simple struct member offset doesn't need a full dwarf location expression
On Tue, 2009-07-07 at 15:04 -0700, Richard Henderson wrote:
> On 07/07/2009 10:09 AM, Mark Wielaard wrote:
> > As explained in PR40659 a simple struct member offset doesn't need a
> > full dwarf location expression, but can just encode the
> > DW_AT_data_member_location as a constant offset according to the Dwarf
> > standard. This saves a little space (one byte per struct field member)
> > and is slightly simpler to handle for debuginfo consumers. It is also
> > the recommended way to encode this according to the examples in the
> > Dwarf standard appendix.
>
> This is true for dwarf3 only.
>
> For dwarf2, section 7.5.4 figure 18 specifies that DW_AT_d_m_l is only
> valid with block/reference forms. Which suggests we want to emit this
> only when dwarf_version > 2.
OK, I had missed that. The following patch it that way, so the condensed
representation is only output when -gdwarf-3 is given. Again the
MIPS_DEBUGGING_INFO case hasn't changed.
2009-07-08 Mark Wielaard <mjw@redhat.com>
PR debug/40659
* dwarf2out.c (add_data_member_location_attribute): When we have
only a constant offset don't emit a new location description using
DW_OP_plus_uconst, but just add the constant with add_AT_int, when
dwarf_version > 2.
This is slightly harder to test though, since neither gdb, nor systemtap
currently support dwarf3 fully, in particular they don't support
DW_OP_call_frame_cfa that is emitted with dwarf_version > 2.
Thanks,
Mark
Index: gcc/dwarf2out.c
===================================================================
--- gcc/dwarf2out.c (revision 149362)
+++ gcc/dwarf2out.c (working copy)
@@ -11487,7 +11487,14 @@
stack. */
op = DW_OP_constu;
#else
- op = DW_OP_plus_uconst;
+ if (dwarf_version > 2)
+ {
+ /* Don't need to output a location expression, just the constant. */
+ add_AT_int (die, DW_AT_data_member_location, offset);
+ return;
+ }
+ else
+ op = DW_OP_plus_uconst;
#endif
loc_descr = new_loc_descr (op, offset, 0);