SUMMARY: In gcc 3.2.3 (and other versions) the DWARF information created by gcc does not create DW_AT_location attribute for local (static) variables inside a C++ constructor.
WHAT:: The reproducer below shows TWO problems related to debug information available regarding variables inside a C++ a constructor. One type is (1) a local variable inside a constructor and second type is (2) a local _static_ variable inside a constructor. Sometimes TV is able to see the case (1) but only in the Program Browser (PB); but case (2) is never correctly shown in TV, neither when Diving, Stack Frame or in PB. For some versions of gcc TV can show type (1) in the PB, but for all gcc versions TV fails to show type (2) at all. This problem is not related to TV alone, GDB fails to see these variables as well. On gcc 3.2.3, TV can see type (1) only in PB, but type (2) is not visible to TV at all (only in symtable). With PGI-7.0.5 (and some other non-gcc compilers) TV can see everything alright. REPRODUCE/TEST:: See attached c++ file. dbreak 25 drun dprint iii dprint foofoo WHY:: In some gcc versions there is no DWARF information whatsoever related to types (1) and (2). In gcc 3.2.3 (and others, e.g. 4.0.3) the DWARF information created by gcc does not create DW_AT_location attribute for neither type (1) and (2), e.g. less tx_local.gcc3.2.3.txt <2><1760>: Abbrev Number: 41 (DW_TAG_variable) DW_AT_name : foofoo DW_AT_decl_file : 1 DW_AT_decl_line : 28 DW_AT_type : <178a> less tx_local.pgi7.0.5.txt <1><1048>: Abbrev Number: 14 (DW_TAG_variable) DW_AT_name : foofoo DW_AT_type : <1864> DW_AT_location : 5 byte block: 3 30 e0 4 8 (DW_OP_addr: 804e030; ) Therefore TV (or gdb) does not have enough information to resolve these variables. These variables do exist in the symtable, e.g.: d1.<> sgrep foofoo {kind loader_symbol} {id 1|795} {full_pathname ##/nfs/netapp0/user/home/seppo/tx_local.out_gcc3.2.3#tx_local_var_cpp_constructor.cxx/_ZZN1AC1Eii\ E6foofoo} {artificial 0} {scope_owner 1|220} {loader_name _ZZN1AC1EiiE6foofoo} \ {loader_file_path tx_local_var_cpp_constructor.cxx} {location {{ldam 0x900007a0\ }}} {address_class module_static_var} {length 96} {weak 0} XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX #include <stdio.h> class A { public: A (int a, int b); int a_; int b_; int c_; }; A::A (int a, int b) : a_ (a), b_ (b), c_ (0) { int iii; iii = 42; c_ = a_ * b_; c_ += iii; static const int foofoo[6][4] = { {0,1,2,3}, {1,2,3,4}, {2,3,4,5}, {3,4,5,6}, {4,5,6,7}, {5,6,7,8} }; printf("c_ = %d\n", c_); printf("foofoo = %d\n", foofoo); } int main (int, char* *) { int a = 34, b = 56; A x (a, b); return x.a_ + x.b_; } XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -- Summary: Local variables in C++ constructor not visible for debugging Product: gcc Version: 3.2.3 Status: UNCONFIRMED Severity: critical Priority: P3 Component: debug AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: seppo at totalviewtech dot com GCC build triplet: linux-x86 (2.6.16.13-4-smp) http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33044