-
October 14th, 2003, 02:15 AM
#1
std:string & debugging
Hi,
When I debug my code containing std:string, many times I see garbage in the std:string in the debuuger but is I call to c_str I see the correct value
I mean
If I have string smyString
I see smyString at the debugger as garbage
then I do (for example)
char szMyString[100]
strcpy(szMyString,sMyString.c_str())
I see szMyString just fine in the debugger
that mostly happens when I have chars like & { at the debbuger } but not only
Any explanation?
Do I have to worry about that?
Thanks
avi123
-
October 14th, 2003, 03:20 AM
#2
std::string is a class that has its own representation for the underlying string somewhere, but you debugger doesn't necessarily know about it. So, no you should not worrry about this "garbage".
Unfortunately, this makes debugging a bit harder, but it's rather a question of the debugger, not std::string. Also, different environments deal differently with this. For example in my VC6 STLPort configuration, it's quite ugly (and a hack is to watch s._M_start), but in VC.NET 2002 std::strings show up correctly under the debugger. So your mileage may vary.
Get this small utility to do basic syntax highlighting in vBulletin forums (like Codeguru) easily.
Supports C++ and VB out of the box, but can be configured for other languages.
-
October 14th, 2003, 03:35 AM
#3
What garbage??? show an example in code, the expansion is controlled by the autoexp.dat in your <install dir>\common\msdev98\bin
-
October 14th, 2003, 01:37 PM
#4
I added:
std::basic_string<*> =Ptr=<_Bx._Ptr,s> Buf=<_Bx._Buf,s>
to my autoexp.dat for the Dinkumware's upgraded STL for MSVC++ 6.0. It works well for me. Sometimes the data is in the _Ptr variable, other times in the _Buf. It can be a hassle expanding it always in the watch or variables windows.
-
October 14th, 2003, 05:19 PM
#5
Originally posted by Mick
What garbage??? show an example in code, the expansion is controlled by the autoexp.dat in your <install dir>\common\msdev98\bin
Now there is something I didn't know. Thanks, that will come in handy
Get this small utility to do basic syntax highlighting in vBulletin forums (like Codeguru) easily.
Supports C++ and VB out of the box, but can be configured for other languages.
-
October 14th, 2003, 07:56 PM
#6
Originally posted by Yves M
Now there is something I didn't know. Thanks, that will come in handy
Yea they don't come out and tell you those types of things...bad boys....
But I've posted a couple of times on it, and so have a couple of other people....
You can also ignore things like stepping over std::string or CString code....
like adding:
Code:
[ExecutionControl]
CString::* =NoStepInto
-
October 15th, 2003, 02:50 AM
#7
jlou
Is there a specail location that should I add this :
std::basic_string<*> =Ptr=<_Bx._Ptr,s> Buf=<_Bx._Buf,s>
Should I do something else or just add it?
Thanks
-
October 15th, 2003, 02:57 AM
#8
when I want to save this file (autoexp.dat) I get this error meesage:
"You are about to save the doucument in a Text - Only format, which will remove all formatting. Are you sure you want to to this?"
I opened this file with notepad IS that the right way?
Thanks
-
October 15th, 2003, 11:48 AM
#9
I just added that line to the end of the file. And yes, it is perfectly fine to use Notepad or Wordpad and save in text-only format.
Note that this may not work for you if you have a different STL than I do.
Last edited by jlou; October 15th, 2003 at 11:53 AM.
-
June 10th, 2004, 06:54 AM
#10
Hi,
std::basic_string<*> =Ptr=<_Bx._Ptr,s> Buf=<_Bx._Buf,s>
It doesn't work for me
I have no idea what stl am I using, how can I know that
anyway I have added this at the end of the file and still I see ??? when the data is in the _ptr and not in the _Buf
thanks
-
June 10th, 2004, 11:25 AM
#11
What compiler/platform do you have? Maybe somebody with the same implementation can give you their version. Also, you said that it doesn't work when it is in _ptr, mine uses _Ptr, make sure the case matches in your autoexp.dat and in the watch window. Does it work when the string is in _Buf?
If you wanted to just figure out what to put, expand a string variable in the watch window when you are debugging. When I expand mine, I have to expand the string first, and then expand the _Bx member. The string is then either in _Ptr or _Buf. If you just find the location of the string when it's not working for you, that would help in creating the right line in the autoexp.dat.
-
June 10th, 2004, 12:27 PM
#12
I'm using VS.NET platform,
Thanks for your advice I'll check it when I'll get back to work
Thanks
avi
-
June 10th, 2004, 01:34 PM
#13
Originally posted by avi123
I'm using VS.NET platform,
Thanks for your advice I'll check it when I'll get back to work
Thanks
avi
Which version?
Are you using VC++ 7.0(2002) or VC++ 7.1 (2003)?
-
June 12th, 2004, 04:39 AM
#14
-
June 12th, 2004, 06:50 AM
#15
Originally posted by avi123
VS.NET 2003
I just tested it out, and I have no problems watching the data in std::string with .Net 2003.
Are you using the STL library that comes with .Net?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|