http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54181
Bug #: 54181 Summary: partial DW_TAG_class_type generated with DW_AT_byte_size and without DW_AT_declaration Classification: Unclassified Product: gcc Version: 4.7.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: debug AssignedTo: unassig...@gcc.gnu.org ReportedBy: m...@gcc.gnu.org Take the following program: :::::::::::::: header.hxx :::::::::::::: #include <malloc.h> class Heap { private: char *_memory; size_t _size; public: Heap(); void* allocate (size_t size); static size_t header_size(); }; :::::::::::::: heap.cxx :::::::::::::: #include "header.hxx" size_t Heap::header_size () { return 42; } Heap::Heap() { _size = header_size () + 32; _memory = (char *) malloc (_size); } void* Heap::allocate(size_t size) { _size += size; return _memory + header_size(); } :::::::::::::: main.cxx :::::::::::::: #include "header.hxx" int size (int resize) { return (int)Heap::header_size() - resize; } int main (int argc, char **argv) { return size (argc); } Compile it with g++ 4.7.1: $ g++ -g -O2 -c main.cxx $ g++ -g -O2 -c heap.cxx $ g++ -g main.o heap.o -o prog Inspect it with: $ eu-readelf --debug-dump=info prog [...] [ b] compile_unit producer (strp) "GNU C++ 4.7.1 20120629 (Red Hat 4.7.1-1) -fpreprocessed -mtune=generic -march=x86-64 -g -O2" language (data1) C++ (4) name (strp) "main.cxx" comp_dir (strp) "/home/mark/src/tests/cxx-decl" ranges (sec_offset) range list [ 0] low_pc (addr) 000000000000000000 stmt_list (sec_offset) 0 [...] [ 289] class_type name (strp) "Heap" byte_size (data1) 16 decl_file (data1) 6 decl_line (data1) 3 sibling (ref4) [ 2a6] [ 295] subprogram external (flag_present) Yes name (strp) "header_size" decl_file (data1) 6 decl_line (data1) 11 linkage_name (strp) "_ZN4Heap11header_sizeEv" type (ref4) [ 30] accessibility (data1) public (1) declaration (flag_present) Yes [ 38e] compile_unit producer (strp) "GNU C++ 4.7.1 20120629 (Red Hat 4.7.1-1) -fpreprocessed -mtune=generic -march=x86-64 -g -O2" language (data1) C++ (4) name (strp) "heap.cxx" comp_dir (strp) "/home/mark/src/tests/cxx-decl" low_pc (addr) 0x00000000004005b0 <_ZN4Heap11header_sizeEv> high_pc (addr) 0x00000000004005ec stmt_list (sec_offset) 220 [...] [ 610] class_type name (strp) "Heap" byte_size (data1) 16 decl_file (data1) 5 decl_line (data1) 3 sibling (ref4) [ 67e] [ 61c] member name (strp) "_memory" decl_file (data1) 5 decl_line (data1) 6 type (ref4) [ 412] data_member_location (data1) 0 [ 628] member name (strp) "_size" decl_file (data1) 5 decl_line (data1) 7 type (ref4) [ 3b7] data_member_location (data1) 8 [ 634] subprogram external (flag_present) Yes name (strp) "Heap" decl_file (data1) 5 decl_line (data1) 9 accessibility (data1) public (1) declaration (flag_present) Yes object_pointer (ref4) [ 644] sibling (ref4) [ 64a] [ 644] formal_parameter type (ref4) [ 67e] artificial (flag_present) Yes [ 64a] subprogram external (flag_present) Yes name (strp) "allocate" decl_file (data1) 5 decl_line (data1) 10 linkage_name (strp) "_ZN4Heap8allocateEm" type (ref4) [ 410] accessibility (data1) public (1) declaration (flag_present) Yes object_pointer (ref4) [ 662] sibling (ref4) [ 66d] [ 662] formal_parameter type (ref4) [ 67e] artificial (flag_present) Yes [ 667] formal_parameter type (ref4) [ 3b7] [ 66d] subprogram external (flag_present) Yes name (strp) "header_size" decl_file (data1) 5 decl_line (data1) 11 linkage_name (strp) "_ZN4Heap11header_sizeEv" type (ref4) [ 3b7] accessibility (data1) public (1) declaration (flag_present) Yes Note how the first one in the main.cxx compile_unit is incomplete. It only contains the header_size subprogram member (since that is the only member used in main.cxx). By just looking at the class_type DIE we cannot tell which one we need, since both [ 289] and [ 610] look identical, both have a byte_size attribute and neither is marked as declaration. Shouldn't DIE [ 289] somehow be marked as partial? Either by not setting DW_AT_byte_size and/or adding DW_AT_declaration? This causes systemtap bug http://sourceware.org/bugzilla/show_bug.cgi?id=14434 "dwflpp sometimes caches incomplete class_type".