🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gdb.bug
Article #1976

Re: c++ strings with gdb??

#1976
From: Dave
Date: Wed, 22 May 2002 04:15
41 lines
2718 bytes
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.

mec@shout.net (Michael Elizabeth Chastain) wrote in message news:<200205171715.g4HHF5o11057@duracef.shout.net>...
> 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
Technical Details
Message-ID: <99f6e996.0205212015.5e2069fa@posting.google.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!cyclone.bc.net!newsfeed.media.kyoto-u.ac.jp!newsfeed.mesh.ad.jp!osa.uu.net!sea.uu.net!ash.uu.net!spool0901.news.uu.net!wendy-fate.uu.net!not-for-mail
References: <200205171715.g4HHF5o11057@duracef.shout.net>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f5053,3b612bd1c1e2d578
X-Google-Attributes: gidf5053,public
X-Google-ArrivalTime: 2002-05-21 21:15:27 PST
x-uunet-gateway: mr0.ash.ops.us.uu.net from bug-gdb to gnu.gdb.bug; Wed, 22 May 2002 04:15:25 GMT
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!cyclone.bc.net!newsfeed.media.kyoto-u.ac.jp!newsfeed.mesh.ad.jp!osa.uu.net!sea.uu.net!ash.uu.net!spool0901.news.uu.net!wendy-fate.uu.net!not-for-mail
From: davis_eric@yahoo.com (Dave)
Subject: Re: c++ strings with gdb??
Date: 21 May 2002 21:15:07 -0700
Organization: http://groups.google.com/
Message-ID: <99f6e996.0205212015.5e2069fa@posting.google.com>
References: <200205171715.g4HHF5o11057@duracef.shout.net>
NNTP-Posting-Host: 129.97.204.100
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: posting.google.com 1022040908 8707 127.0.0.1 (22 May 2002 04:15:08 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: 22 May 2002 04:15:08 GMT
Approved: bug-gdb-request@mail.gnu.org
Newsgroups: gnu.gdb.bug
Sender: bug-gdb-request@mail.gnu.org
Lines: 41