This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug debug/33044] Local static variable in C++ constructor not visible for debugging
- From: "dodji at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 29 Aug 2008 09:58:43 -0000
- Subject: [Bug debug/33044] Local static variable in C++ constructor not visible for debugging
- References: <bug-33044-14963@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #12 from dodji at gcc dot gnu dot org 2008-08-29 09:58 -------
This is an update of what we get with gcc-4_3-branch.
For the program (line numbers added for better legibility):
1 #include <stdio.h>
2 class A {
3 public:
4 A (int a, int b);
5 int a_;
6 int b_;
7 int c_;
8 };
9
10 A::A (int a, int b) : a_ (a), b_ (b), c_ (0)
11 {
12 int iii;
13 iii = 42;
14 c_ = a_ * b_;
15 c_ += iii;
16 static const int foofoo[6][4] = { {0,1,2,3},
17 {1,2,3,4},
18 {2,3,4,5},
19 {3,4,5,6},
20 {4,5,6,7},
21 {5,6,7,8} };
22
23 printf("c_ = %d\n", c_);
24 printf("foofoo = %d\n", foofoo);
25 }
26
27 int main (int, char* *)
28 {
29 int a = 34, b = 56;
30 A x (a, b);
31 return x.a_ + x.b_;
32 }
33
I get the dwarf info below:
[...]
<1><c5>: Abbrev Number: 11 (DW_TAG_subprogram) <-- //This is the A::A
constructor at line 10.
<c6> DW_AT_specification: <0xa6>
<ca> DW_AT_decl_line : 10
<cb> DW_AT_inline : 0 (not inlined)
<cc> DW_AT_sibling : <0x102>
<2><d0>: Abbrev Number: 12 (DW_TAG_formal_parameter)
<d1> DW_AT_name : (indirect string, offset: 0x47): this
<d5> DW_AT_type : <0x102>
<d9> DW_AT_artificial : 1
<2><da>: Abbrev Number: 13 (DW_TAG_formal_parameter)
<db> DW_AT_name : a
<dd> DW_AT_decl_file : 1
<de> DW_AT_decl_line : 10
<df> DW_AT_type : <0x57>
<2><e3>: Abbrev Number: 13 (DW_TAG_formal_parameter)
<e4> DW_AT_name : b
<e6> DW_AT_decl_file : 1
<e7> DW_AT_decl_line : 10
<e8> DW_AT_type : <0x57>
<2><ec>: Abbrev Number: 14 (DW_TAG_variable) <--- this if the foofoo variable
<ed> DW_AT_name : (indirect string, offset: 0x0): foofoo
<f1> DW_AT_decl_file : 1
<f2> DW_AT_decl_line : 16
<f3> DW_AT_type : <0x214>
<f7> DW_AT_location : 9 byte block: 3 20 8 40 0 0 0 0 0
(DW_OP_addr: 400820)
[...]
So we see here that the foofoo variable is generated with an DW_AT_location,
inside the A::A constructor we are interested in.
However, in GDB, at line 23:
(gdb) bt
#0 A (this=0x7fff6616bd80, a=34, b=56) at test-PR33044.cc:23
#1 0x0000000000400645 in main () at test-PR33044.cc:30
I get:
(gdb) p foofoo
No symbol "foofoo" in current context.
As Andrew pointed, gcc can generate several copies (two, or three) of a given
constructor. Those copies don't necessarily have the same signatures, of
course. So A::A(int, int) might yield to an additional copy of the constructor
being generated.
The debugging for A::A(int, int) info is only generated for the "initial"
constructor. Not for the additional copy.
So my question now is what happens when GDB actually breaks in the additional
copy ? Can it detect that it broke in a constructor that is "only" a copy of
the "real" one ? Or does it expect that all the copies be associated with
debugging info ?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33044