public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug debug/33044]  New: Local variables in C++ constructor not visible for debugging
@ 2007-08-10 15:11 seppo at totalviewtech dot com
  2007-08-10 21:08 ` [Bug debug/33044] " pinskia at gcc dot gnu dot org
                   ` (14 more replies)
  0 siblings, 15 replies; 17+ messages in thread
From: seppo at totalviewtech dot com @ 2007-08-10 15:11 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2008-08-29 16:10 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-10 15:11 [Bug debug/33044] New: Local variables in C++ constructor not visible for debugging seppo at totalviewtech dot com
2007-08-10 21:08 ` [Bug debug/33044] " pinskia at gcc dot gnu dot org
2007-08-10 21:13 ` pinskia at gcc dot gnu dot org
2007-08-10 21:15 ` pinskia at gcc dot gnu dot org
2007-08-14 20:33 ` seppo at totalviewtech dot com
2007-08-14 22:40 ` pinskia at gcc dot gnu dot org
2007-08-24 13:15 ` nikolay at totalviewtech dot com
2007-08-24 13:52 ` [Bug debug/33044] Local static variable " seppo at totalviewtech dot com
2007-08-24 16:14 ` pinskia at gcc dot gnu dot org
2007-08-24 16:45 ` nikolay at totalviewtech dot com
2007-08-24 16:51   ` Andrew Pinski
2007-08-24 16:51 ` pinskia at gmail dot com
2008-01-13 16:03 ` rguenth at gcc dot gnu dot org
2008-08-27 23:27 ` le dot ben dot smith at gmail dot com
2008-08-29  9:59 ` dodji at gcc dot gnu dot org
2008-08-29 14:42 ` dodji at gcc dot gnu dot org
2008-08-29 16:10 ` jason at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).