Package: gdb
Version: 6.8-3, 6.8.50.20081210.python-1
Severity: normal
It is very hard to debug something in C++ constructors because GDB
failes to see any local variables in it. Consider this tiny example:
<<< main.cpp >>>
-8<-
#include <string>
#include <iostream>
using std::string;
class A
{
string str;
public:
A()
{
string sa = "aa";
string sb = "bb";
str = sa + sb; // debug me
}
void print() const
{
std::cout << str << '\n';
}
};
int main()
{
A a;
a.print();
}
->8-
<<< GDB session >>>
-8<-
$ gdb main.e
GNU gdb (GDB) 6.8.50.20081120-cvs-debian
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show
copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
(gdb) b main.cpp:15
Breakpoint 1 at 0x400d7b: file main.cpp, line 15.
(gdb) run
Starting program:
/home/jackyf/Work/Programming/linux/SmallTests/gdb-debugging-constructor/main.e
Breakpoint 1, A (this=0x7fffffffe500) at main.cpp:15
15 str = sa + sb;
(gdb) print sa
No symbol "sa" in current context.
(gdb) print sb
No symbol "sb" in current context.
(gdb) q
->8-
-- System Information:
Debian Release: 5.0
APT prefers unstable
APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)
Kernel: Linux 2.6.28-rc7jackyf (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
Versions of packages gdb depends on:
ii libc6 2.7-16 GNU C Library: Shared libraries
ii libexpat1 2.0.1-4 XML parsing C library - runtime li
ii libncurses5 5.7+20081129-1 shared libraries for terminal hand
ii libreadline5 5.2-3 GNU readline and history libraries
ii python2.5 2.5.2-14 An interactive high-level object-o
ii zlib1g 1:1.2.3.3.dfsg-12 compression library - runtime
gdb recommends no packages.
Versions of packages gdb suggests:
ii gdb-doc 6.8-1 The GNU Debugger Documentation
-- no debconf information
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]