This is the mail archive of the mailing list for the GDB project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[BUG] breakpoints in constructor

Hi folks,

gdb 6.6 (still, *sigh*) fails to set break points in constructors within
C++ objects.

Here's a source code to test this with:

/* snip */

class A {
  int x;
  A(int i)
    x = i;
  int getA(void) const
    return x;

int main(int argc,char **argv)
  A a(5);

  return a.getA();

/* snip */

Compile this with:

thor@mersenne:~/src> g++-4.1 -O0 -fno-inline -ggdb3 gdbtest.cpp -o gdbtest

just to be on the safe side that we get all the debugging needed and no
optimization that could confuse the debugger.

Then, launch gdb and set a breakpoint:

thor@mersenne:~/src> gdb gdbtest
GNU gdb 6.6
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu"...
Using host libthread_db library "/lib/tls/".
(gdb) break A::A
(gdb) run
Starting program: /homes/mathphys/thor/src/gdbtest 

Program exited with code 05.
(gdb) quit

No breakpoint hit, the code just continues to run. This makes it pretty
hard to debug C++ code, especially with RAII classes where all the interesting
stuff happens in the constructor.

Any thoughts?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]