Package: gdb Version: 6.8-3 Severity: important gdb incorrectly prints some objects passed to functions as value.
i.e. for a c-string holder, data pointer is displayed as pointing on itself (or this), although it points to a valid allocated mem zone. I put a demonstrating program below : bdu...@linux1:/tmp$ cat test.cpp #include <iostream> #include <cstring> using namespace std; class PTString { char * data; public: PTString(const char * s) { data = strdup(s); } PTString(const PTString& p) { data = strdup(p.data); } operator const char * () const { return data; } }; void Do(PTString aStr) { PTString lStr = aStr; int a = 1; ++a; } int main() { PTString test = "foo"; Do(test); cout << test << endl; return 0; } when I run gdb on it, aStr displays incorrectly (I had to cut garbage to write in console-based editor) but if I cast aStr.data to a char**, it works around the problem, as gdb thinks data is pointing on itself, it dereferences it to real memory zone. See below. bdu...@linux1:/tmp$ g++ -g2 test.cpp bdu...@linux1:/tmp$ gdb a.out GNU gdb 6.8-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 "i486-linux-gnu"... (gdb) b Do Breakpoint 1 at 0x8048726: file test.cpp, line 24. (gdb) r Starting program: /tmp/a.out Breakpoint 1, Do (aStr={data = 0xbf8af8a0 "\030\020[...garbage cut...]\001"}) at test.cpp:24 24 PTString lStr = aStr; (gdb) n 26 int a = 1; (gdb) p lStr $1 = {data = 0x9d81028 "foo"} (gdb) p *(char **)(aStr.data) $2 = 0x9d81018 "foo" (gdb) p aStr.data $3 = 0xbf8af8a0 "\030\020[...garbage cut...]\001" (gdb) c Continuing. foo Program exited normally. -- System Information: Debian Release: 5.0.2 APT prefers stable APT policy: (500, 'stable') Architecture: i386 (i686) Kernel: Linux 2.6.26-2-686 (SMP w/1 CPU core) Locale: LANG=en_US, LC_CTYPE=en_US (charmap=ISO-8859-1) Shell: /bin/sh linked to /bin/bash Versions of packages gdb depends on: ii libc6 2.7-18 GNU C Library: Shared libraries ii libexpat1 2.0.1-4 XML parsing C library - runtime li ii libncurses5 5.7+20081213-1 shared libraries for terminal hand ii libreadline5 5.2-3.1 GNU readline and history libraries gdb recommends no packages. Versions of packages gdb suggests: pn gdb-doc <none> (no description available) -- no debconf information -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org