bug-gdb
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: c++ strings with gdb??


From: Dave
Subject: Re: c++ strings with gdb??
Date: 21 May 2002 21:15:07 -0700

Hi,

Thanks a lot for your reply. 

I have tried the examine the memory. I got '<' when using "x/c
0x24340" but got "<A HREF=\"http:/" when using "x/s 0x24340". I tried
to use "cout" and "cerr" to print the content(s) of "substring" and I
got expected '<'. I met this kind of problem again and again in my
different programs. Some persons in other groups responed to my
message saying they also had this problem when debug the code I
posted.

I suspect the string does not end with null char. So, gdb overshots
when it tries to print out the contents of the string. Not sure
though.

Really appreciate your replies.

address@hidden (Michael Elizabeth Chastain) wrote in message 
news:<address@hidden>...
> Hi Eric,
> 
> Presumably, your string actually has that many characters in it.
> 
> I would suggest looking directly at the memory:
> 
>   (gdb) x/c 0x24340
>   ... then hit the "return" key to see successive characters
> 
> Your C++ string class doesn't have any field named "length" so it
> probably uses null-terminated characters.
> 
> > For refereence to my first post, this string should
> > have only "<", without those trailling chars.
> 
> Well, either gdb is lying, or we are mis-interpreting its output,
> or your string really does all those characters in it.  I recommend
> trying some different things, such as different data display commands
> in gdb, and perhaps adding some printf statements to the program
> (i know, icky) to see the data independently of gdb.
> 
> Michael C



reply via email to

[Prev in Thread] Current Thread [Next in Thread]