From: David Carlton <carlton@math.stanford.edu>
To: gdb <gdb@sources.redhat.com>
Cc: carlton@math.stanford.edu
Subject: DWARF-2, static data members
Date: Fri, 09 Aug 2002 15:10:00 -0000 [thread overview]
Message-ID: <15700.15818.829204.767503@jackfruit.Stanford.EDU> (raw)
I was looking through dwarf2read.c and through the DWARF 2 standard (I
have a PDF of an "Industry Review Draft" from July 27, 1993, and I've
also looked at the PDF for the DWARF 3 draft 7 from October 29, 2001),
and it seems, judging from GDB's code, GCC and GDB both have the wrong
idea about what tags should be present in static data members of C++
classes.
Specifically, the code in read_structure_scope() and
dwarf2_add_field() (both within dwarf2read.c) both treat static data
members as being characterized by children that have the tag
DW_TAG_variable. But I don't see that within the relevant section of
the DWARF 2 standard (5.5 Structure, Union, and Class Type Entries):
e.g. 5.5.4 Structure Data Member Entries simply says that
A data member (as opposed to a member function) is represented by a
debugging information with the tag DW_TAG_member.
and there's no indication that that doesn't apply to static data
members. Or in 5.5.1 General Structure Description, it says in a
comment that
Data member declarations occuring within the declaration of a
structure, union or class type are considered to be "definitions" of
those members, with the exception of C++ "static" data members,
whose definitions appear outside of the declaration of the enclosing
structure, union or class type.
From this, it seems to me that static data members should be
represented by children of the class that have the tag DW_TAG_member
but that have the flag DW_AT_declaration set.
Also relevant is the section 4.1 Data Object Entries, which _does_
talk about DW_TAG_variable; what it says there is that
The definitions of C++ static data members of structures or classes
are represented by variable entries flagged as external.
Note here that it says "definitions"; the bit I previously quoted made
it clear that declarations occurring within a class _aren't_ the
definitions of the variables. And further on, we have
If the variable entry represents the defining declaration for a C++
static data member of a structure, class or union, the entry has a
DW_AT_specification attribute, whose value is a reference to the
debugging information entry representing the declaration of this
data member. The referenced entry will be a child of some class,
structure or union type entry.
Again, this makes it clear that the definition (which is presumably a
DW_TAG_variable) is different from the declaration (which is
presumably a DW_TAG_member). And I've gone through the DWARF 3 draft,
and it says the same thing.
Having said all that, when I run GDB on some code with static data
members that I'd compiled with GCC 3.1, the appropriate branches were
taken. Which means that either there's something I _really_ don't
understand about GDB's code (always a possibility!) or else GCC is
making the same misinterpretation and GDB.
Nonetheless, I think they should both be fixed. It seems to me that
the safe thing to do would be to modify GDB so that it treats members
that either are DW_TAG_variable or DW_TAG_member + DW_AT_declaration
as static data members; that way it will be safe both with code
compiled by current versions of GCC and by code compiled with
hypothetical future versions of GCC that have this misinterpretation
fixed (as well as other compilers out there that might do the right
thing). I'd be happy to try to make this change if other people agree
with me.
David Carlton
carlton@math.stanford.edu
next reply other threads:[~2002-08-09 22:10 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-08-09 15:10 David Carlton [this message]
2002-08-13 13:48 ` Jim Blandy
2002-08-13 14:05 ` David Carlton
2002-08-13 15:29 ` Jim Blandy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=15700.15818.829204.767503@jackfruit.Stanford.EDU \
--to=carlton@math.stanford.edu \
--cc=gdb@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox