This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
[BUG] breakpoints in constructor
- From: Thomas Richter <thor at mail dot math dot tu-berlin dot de>
- To: gdb at sourceware dot org
- Date: Tue, 13 Feb 2007 17:06:04 +0100 (CET)
- Subject: [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;
public:
A(int i)
{
x = i;
}
~A(void)
{
}
//
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/libthread_db.so.1".
(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?
Greetings,
Thomas