Interesting - I found a different problem (but maybe
related) with local string variables.

I didn't try printing, but gdb 5.0 would crash when
single-stepping over that instruction (but it looks like that
worked for you). The program ran full-speed OK.
Maybe it's a software-momentum problem. ;-)

I was using remote debugging (x86 host and arm target)
and it looks like you're using host=target=x86.

I posted the details several weeks ago to this elist but
got no response (maybe people have stopped following
it due to the spam).

I got pulled off onto something else before I could stumble
around in the source code.

One thing I did try that worked for debugging in the past was to
use gdb to debug and single step gdb. You might try that
and maybe you can track down what the problem is.
I'd sure like to know if you get anywhere in case I can get
back to gdb from what I'm doing sometime.

-PaulK


Pierre Sarrazin wrote:

> On my Pentium-based RedHat 6.2 machine, gdb 5.0 cannot print
> the contents of a C++ string variable.  It displays this:
>
>   $1 = {static npos = Cannot access memory at address 0x0
>
> This bug was reported for gdb 4.18 in this message:
>
>   http://www.bg.debian.org/Bugs/db/47/47482-b.html
>
> I compiled and installed g++ 2.95.2 and gdb 5.0 from the sources.
>
> Here are the details.
>
> $ uname -a
> Linux dev.machina.com 2.2.14-5.0 #1 Tue Mar 7 21:07:39 EST 2000 i686 unknown
>
> $ ls /lib/libc-*
> /lib/libc-2.1.3.so
>
> $ g++ -v
> Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.2/specs
> gcc version 2.95.2 19991024 (release)
>
> $ ls -l /usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.2/libstdc++.so
> /usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.2/libstdc++.so
>     -> ../../../libstdc++-libc6.1-2.so.3
>
> $ cat test.cc
> #include <string>
>
> int main()
> {
>   string s;
>
>   s = "a";  // line 7
> }
>
> $ g++ -g -o test test.cc
>
> $ ldd test
>         libstdc++-libc6.1-2.so.3 => /usr/local/lib/libstdc++-libc6.1-2.so.3 
>(0x4001a000)
>         libm.so.6 => /lib/libm.so.6 (0x40061000)
>         libc.so.6 => /lib/libc.so.6 (0x4007e000)
>         /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
>
> $ gdb test
> GNU gdb 5.0
> Copyright 2000 Free Software Foundation, Inc.
> GDB is free software, covered by the GNU General Public License, and you are
> welcome to change it and/or distribute copies of it under certain conditions.
> Type "show copying" to see the conditions.
> There is absolutely no warranty for GDB.  Type "show warranty" for details.
> This GDB was configured as "i686-pc-linux-gnu"...
> (gdb) b 7
> Breakpoint 1 at 0x8049975: file test.cc, line 7.
> (gdb) r
> Starting program: /home/sarrazip/pgm/bug-gdb-string/test
>
> Breakpoint 1, main () at test.cc:7
> 7         s = "a";
> (gdb) p s
> $1 = {static npos = Cannot access memory at address 0x0
> (gdb) n
> 8       }
> (gdb) p s
> $2 = {static npos = Cannot access memory at address 0x0
> (gdb) c
> Continuing.
>
> Program exited normally.
> (gdb) q
>
> --
> Pierre Sarrazin <sarrazip at machinasapiens dot com>

Reply via email to