This is the mail archive of the gdb@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: DWARF-2, static data members


In article <vt2ofc6ze70.fsf@zenia.red-bean.com>, Jim Blandy
<jimb@zenia.red-bean.com> writes:

> I agree with your reading.  There should be *two* entries for a C++
> static data member: one as a variable definition, DW_TAG_variable,
> at the top level, and one as a member definition, DW_TAG_member, as
> a child of the struct/class/union die.

Right.  Though you can presumably skip the DW_TAG_variable entry if
you're compiling a file in which that variable never gets defined or
referred to.  (E.g. if the file you're compiling includes a header
file defining a class that it uses, but the file you're compiling
doesn't happen to use that particular static member of the class
itself.)

> For what it's worth, the paragraph of the Dwarf 2 spec that
> corresponds to paragraph 6. in Section 4.1 of Draft 3 rev 7 (what I
> treat as authoritative for Dwarf 3) doesn't specify what tag the
> type die's child is supposed to have.

Good point: I'd missed that Dwarf 3 is more explicit there.  Dwarf 2
seems to me to be explicit enough, in that the section on class
declarations that says that data members should have the DW_TAG_member
(with no exception for static data members), but it's a good thing
that Dwarf 3 makes that clearer.

> Have you run `readelf -wi' on the executable, or run GCC with
> `-save-temps -dA' and looked at the .s file, to see what GCC is
> actually generating?  I think GCC does generate children of
> struct/class types with the DW_TAG_variable tag.

I'll have to look up what those arguments mean :-), but I did do g++
-S yesterday and went through the .s file by hand.  (Fun, and
educational, though I don't plan to do it too often.)  It really is
generating DW_TAG_variable tags instead of DW_TAG_member tags.

> You might put together a fix for GCC, too --- dwarf2out.c is big,
> but it doesn't seem too bad.  This would allow you to actually test
> your changes.

I'll give it a look.  I did submit a PR for GCC, so at least it's in
their bug database.

David Carlton
carlton@math.stanford.edu


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]