开发者

Problems watching non-trivial expressions in visual studio debugger

开发者 https://www.devze.com 2023-04-06 04:45 出处:网络
Basically my problem is that I expect Visual Studio (2010 Professional) to be able to evaluate any Visual C++ expression in the watch window that it handles in the code I\'m debugging, but apparently

Basically my problem is that I expect Visual Studio (2010 Professional) to be able to evaluate any Visual C++ expression in the watch window that it handles in the code I'm debugging, but apparently there's something preventing this from happening. For example, when dealing with CStrings, evaluating the method IsEmpty on the CString in the watch window gives me a Member function not found error, as does a basic equality comparison (in the code being debugged obviously no problems).

Am I missing something here, or is what I'm asking for too much? Obvious solution would be to put debugging statements in my code for whatever CStr开发者_如何转开发ing operation I'm looking for, but I would prefer not to have to do this.

Update/Example:

CString blah = _T("blah");

Calling blah.IsEmpty() in my code works fine, but in the watch window of the debugger I get the error above (CXX0052). The contents of the variable blah can be seen the watch window.


I could reproduce your problem, and, indeed, the VS watch window shows Member function not found alongside with the error code CXX0052.

Problems watching non-trivial expressions in visual studio debugger

In the MSDN documentation I found that this problem arises due to a call of a inlined function, the CString::IsEmpty() member function is probably somehow inlined (this is what the Watch Window evaluator sees), to solve the problem, first open your project Configuration and disable inlining

Problems watching non-trivial expressions in visual studio debugger

Second, still in the project Configuration, choose Use MFC in a Static Library (somehow the Watch Window keep seeing the called function as an inlined one if you use it as shared library, maybe this is because in the Shared Library the code is inlined and the Watch Window evaluator don't use the Debug builds of such runtime libraries).

Problems watching non-trivial expressions in visual studio debugger

Third, clean and Rebuild your Solution.

After that, the problem should be fixed (remember to refresh the expression if you see the value grayed out in the watch panel) during debugging. Remember to switch back to your original Debug options or better, create a new Debug profile to keep this settings.

Problems watching non-trivial expressions in visual studio debugger

0

精彩评论

暂无评论...
验证码 换一张
取 消