This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA 2/4] dwarf2_physname
On 02/01/2010 02:19 PM, Daniel Jacobowitz wrote:
What're we trying to answer? For instance, is it the distinction
between local variables and global variables? This is interesting
because I believe that function-local classes get the enclosing
function as a prefix, but obviously function-local automatic variables
should not.
Yes, it was specifically to deal with class static members. Reminder:
namespace
{
namespace G
{
int Gx;
};
};
gcc will output:
DW_TAG_namespace
-- DW_TAG_namespace
-- DW_AT_name = "G"
---- DW_TAG_variable
---- DW_AT_name = "Gx"
DW_TAG_variable
-- DW_AT_location
-- DW_AT_specification = DW_TAG_variable above
This seems to be correct as far as my interpretation of the DWARF3 spec
(Dec 20, 2005), Section 4.1 #6 (pg 60).
I'm not sure how DW_TAG_member comes into this either, that doesn't
entirely make sense for non-static class members. Be careful about
this one: GCC sometimes incorrectly uses DW_TAG_variable, when the
DWARF standard says they should be DW_TAG_member.
DW_TAG_member does not run through this branch, unless, as you say, gcc
incorrectly emits DW_TAG_variable instead of DW_TAG_member. I have only
seen gcc output DW_TAG_variable for member data in two situations: 1)
static class members (which I think is correct) and 2) const class
members where the class is not instantiated.
To elaborate on #2:
Consider the following class:
class A
{
public:
static const int a_constant = 3;
};
int
main (int argc, char* argv[])
{
return A::a_constant;
}
Gcc will *NOT* output anything about A::a_constant *except* for a
DW_TAG_variable describing it (DW_AT_name = "a_constant"). No
DW_AT_specification (as I think there should be). In fact,
DW_TAG_class_type for A is completely omitted. The only clue that gdb
gets (either dwarf2_physname or CVS HEAD) is in DW_AT_MIPS_linkage_name.
This is obviously a gcc bug.
Do you have another example where gcc does this that you'd like me to
look at?
Or maybe I'm simply not answering your question? [A kind of forest/tree
thing...]
Keith