Skip to main content
GameDev.net gamedev.net
🔒 Locked

Visual C++ .NET - Problem reading STL strings in debugger

Started by MagTDK Jun 13, 2002 at 7:58 AM 7 replies 300+ views
Original Post
MagTDK
MagTDK
I recently switched from Visual C++ 6.0 to Visual C++ .NET and am having problems reading STL string''s from the debugger. Note: The program runs like it should so I know the string values are correct. Here is an example of what I get for the variable "FileName" in my watch window in debug mode: Variable: FileName Value: {0x0012fb28 "˜ÿ$( Ñ"} Type:std::basic_string,std::allocator > In Visual C++ 6.0 I could read what the value of my variable was like so: Value: {0x0012fb28 "MeshImage.bmp"} What can I do to fix this problem?
Corvus
Corvus
In the options screen of your VS.NET you have a tab page called Debugging. Some option there might solve your problem. I had a similar with integers that were represented as hex values.

...or maybe your problem has got something to do with the fact that .NET works with unicode strings...

+++ Corvus +++
+++ Corvus +++
MagTDK
MagTDK

I messed with some of the debug settings, but that didn''t help.

Anyone else have any suggestions?
stimarco
stimarco
HOLMES: "Elementary, my dear Watson! It''s displaying the string as Unicode instead of ASCII!"

WATSON: "But how can you be certain of that, Holmes?"

HOLMES: "Observe, my dear Watson! The STL string is 12 ASCII characters. The debugger is displaying 6 characters. ASCII is 1 byte / char. Unicode is 2 bytes / char."

WATSON: "So if I have you right, MagTDK should set his debugger to display hexadecimal. He should then see a string of 24 hex digits matching the codes of his STL string!"

HOLMES: "Exactly, Watson! Here, have a chocolate frog."





--
Sean Timarco Baggaley
Sean Timarco Baggaley (Est. 1971.)Warning: May contain bollocks.
MagTDK
MagTDK

Actually, the output value should be this: "data\OgroModel.pcx"} instead of what I''m getting in VC.NET: {0x0012fb28 "˜ÿ$( Ñ"}

I set my debugger to display hexadecimal like so: Tools->Options->Debugging->General and then I put a check for hexadecimal display. Is this correct?

I still get the same garbage in my debugger. It''s obvious I''m doing something wrong, I just can''t figure out what. Sorry if I''m starting to sound ignorant, it''s just this new interface in VC++ .NET is completely different from what I''m use to in VC++ 6.0.
stimarco
stimarco
Good point. I just tried those same options and it insists on displaying strings as strings.

*HOWEVER*, you can open a Memory Window. ("Debug -> Windows -> Memory -> Memory [1-4]") Type the name of the pointer(s) in question into the box and see what is displayed.



--
Sean Timarco Baggaley
Sean Timarco Baggaley (Est. 1971.)Warning: May contain bollocks.
Shannon Barber
Shannon Barber
The .Net STL string uses a union of a small buffer and a char* to contain it''s data. If the string is small, I think 12 character, it shows up right there. If it''s bigger, that''s a pointer, and you have to expand one of the other data elements to see the string.
The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
MagTDK
MagTDK

I got it to work, thanks for everyones help.
Corvus
Corvus
no prob

+++ Corvus +++
+++ Corvus +++

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.