Problem Viewing Strings in Debugger (VS 2008)

Hello all,

I've been having some problems lately where I cannot view the value of a std::string while I am debugging my program.

I am working in Visual Studio 2008 and developing a 64-bit executable. When I debug my project, I can put

1
2
3
4
5
6
7
8
int main(int argc, char* argv[]) 
{
    string strLogFile = "C:\\Log\\run1.txt";
    
    // rest of code //

    return 0;
}


and as soon as the first line is executed, if I mouse over the variable strLogFile, it says that it is a <Bad Ptr>. If I put it in one of the Watch windows, it has:
1
2
Name         Value      Type
strLogFile   <Bad Ptr>  std::basic_string<char,std::char_traits<char>,std::allocator<char> >


If I create an entirely new project that has just the code below in it.

1
2
3
4
5
6
int main(int argc, char* argv[]) 
{
    string strLogFile = "C:\\Log\\run1.txt";
    
    return 0;
}


I can compile it as 64-bit application and when I debug it, I'm able to see the string value when I mouse over strLogFile.

I am at a loss for why this works in every project but the one I'm working on. I've tried deleting the .ncb file and .pdb file(s).

Any light that could be shed on this would be greatly appreciated.

Thanks :)
Are you compiling for release? There should be three text boxes under the menu bar. One says the build configuration, the other the target platform, and the third is a search box.
If you're compiling for release, the debugger reports garbage.
Last edited on
@helios

Unfortunately that is not the case :( I have Debug selected. Debug is also selected as the Active solution configuration: and Configuration field in the Configuration Manager.

Is the compiler adding debugging information to the executable?
@helios

I believe so. In the Property Pages dialog

Debugging

Debugger to Launch:  Local windows Debugger
Command:  $(TargetPath)
Command Arguments:  (n/a)
Working Directory:  (n/a)
Attach:  No
Debugger Type:  Auto
Environment:  (n/a)
Merge Environment:  Yes


C/C++ -> General

Debug Information Format:  Program Database (/Zi)


Linker -> Debugging

Generate Debug Info:  Yes (/DEBUG)
Debuggable Assembly:  No Debuggable attribute emitted.


Is it one of these that adds the debugging information, or am I completely off base :(

Thanks for your help so far :)
Then I have no idea what it could be. I'd create a new project and move all the sources there.
@helios

Ok thanks for all your help. I'll try that :)
Topic archived. No new replies allowed.