This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
whether DIE of a "static const int" member has attribute "DW_AT_const_value"
- From: hex <heixia108 at gmail dot com>
- To: gcc at gcc dot gnu dot org
- Date: Wed, 24 Jul 2013 23:11:45 +0800
- Subject: whether DIE of a "static const int" member has attribute "DW_AT_const_value"
Hi all,
I find a strange things: Whether DIE(Debug Information Entry) of a
"static const int" member in a class has the attribute
"DW_AT_const_value" depends on whether there is a virtual function
defined in the class. Is it a expected behavior for GCC? And the
attribute "DW_AT_const_value" matters because GDB could print the
member's address if it does not have the attribute, otherwise GDB
could not.
My test case is as following:
// symbol.cpp
class Test{
private:
const static int hack;
public:
virtual void get(){}
};
const int Test::hack = 3;
int main()
{
Test t;
return 0;
}
Then I run the following steps:
$ g++ -g -o symbol symbol.cpp
$ readelf -wi symbol
The DIE for Test::hack is as follwing:
<2><46>: Abbrev Number: 4 (DW_TAG_member)
<47> DW_AT_name : (indirect string, offset: 0x3a): hack
<4b> DW_AT_decl_file : 1
<4c> DW_AT_decl_line : 8
<4d> DW_AT_MIPS_linkage_name: (indirect string, offset: 0x3f):
_ZN4Test4hackE
<51> DW_AT_type : <0xc3>
<55> DW_AT_external : 1
<56> DW_AT_accessibility: 3 (private)
<57> DW_AT_declaration : 1
<58> DW_AT_const_value : 3
If I delete the function get() from the class, the class turns into:
class Test{
private:
const static int hack;
};
const int Test::hack = 3;
int main()
{
Test t;
return 0;
}
Then the DIE for Test::hack does not have the attribute
"DW_AT_const_value". Is it exptected? Thank you!