This is the mail archive of the gdb@sources.redhat.com 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]

Re: Problem debugging statically linked c++ program with GDB 6.0


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


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