This is the mail archive of the
gdb@sources.redhat.com
mailing list for the GDB project.
Re: Problem debugging statically linked c++ program with GDB 6.0
- From: Bob Rossi <bob at brasko dot net>
- To: Holger Sesterhenn <Holger dot Sesterhenn at smgwtest dot aachen dot utimaco dot de>
- Cc: gdb at sources dot redhat dot com
- Date: Fri, 2 Apr 2004 08:26:05 -0500
- Subject: Re: Problem debugging statically linked c++ program with GDB 6.0
- References: <406D578A.6010408@smgwtest.aachen.utimaco.de>
On Fri, Apr 02, 2004 at 02:07:38PM +0200, Holger Sesterhenn wrote:
> Hi,
>
> I have a bug in my statically linked c++ program and would like to use
> DDD with GDB to see whats wrong. I use <string> from the stdlibc++.
> DDD/GDB shows a SIGSGV if I call a member function e.g. c_str() to take
> a look at the value of the string.
>
> I have written a little program to reproduce the problem (don't need
> DDD). If the program is linked dynamically, everything works as expected!
>
> If somebody can confirm the problem I would submit a bug report.
> Searching the bug database I did not find any hint.
>
> Running Linux 2.4.21 (IA86/32), compiled gcc 3.3.3, glibc 2.3.2 and gdb
> 6.0 myself (chrooted). The problem can be reproduced with a plain SuSE
> 9.0 installation (gcc 3.3.1, glibc 2.3.2, gdb 5.3.92).
I don't know if this is helpful, however, GDB crashes for me even when I
link dynamically. It will only evaluate the expression sometimes for me.
Because of this, I have added the snippet below to my .gdbinit file
# prints a C++ string
define pc
set $string_length=$arg0.length()
set print elements $string_length
print $arg0.dat
set print elements 0
end
document pc
Prints a C++ string
end
This seems to work ok, even though it's not the perfect solution.
For some reason calling the length() function never seems to crash for
me.
Bob Rossi