help: gdb and c++ strings

Murad Nayal
2002-12-06T04:07:46Z

Hello,

I am wondering if anyone here can help me with this. I am porting code
to linux and trying to use gdb to do the debugging. unfortunately this
is complicated by the fact that gdb does not print c++ string variables.

p s
$1 = (
const basic_string<char,std::char_traits<char>,std::allocator<char>
> &) @0xbffff3d0: {static npos = Cannot access memory at address 0x8f4b974

I have come upon an older post to bug-gdb list that mentions this
problem
http://sources.redhat.com/ml/bug-gdb/2000-09/msg00012.html

in response Daniel Berlin suggested that this problem might be related
to the stabs format and that using dwarf-2 format (i.e. g++ -gdwarf-2)
would solve it. however it was mentioned back then that for large
programs this problem persists even when compiling with the -gdwarf-2
flag. this is where I am at right now. I have recompiled gdb from
sources (5.2.1) and recompiled most of the libraries I am using
(including the objects I am trying to debug) using the -gdwarf-2 flag. I
am on a pentium 3 platform using g++ 3.2.1, also compiled from sources.
I am not sure what to try next. can you help?

thanks
Murad Nayal