VS2010 debugger: in a class, 'this' is not showing it's members. Why? - visual-studio-2010

I'm trying to debug a C++ class. It's a class that gets SWIGged for Python, then I attach debugger to python.exe. No problems there. Breakpoints are hit fine.
But in the 'Locals' window 'this' is completely empty apart from its _vfptr (which does not look right either, just values, no function names). 'this' should have a few member variables!
Function parameters are showing fine. Functions appear to, well, function properly.
Trying to 'Watch' or 'Quickwatch' a variable from the editor window gives 'inaccessible!'.
What foul Visual Studio crime have I committed? This was working fine earlier on!

Related

Visual studio debugger cannot find any identifier even though the symbols are loaded

I'm trying to debug a program in Visual Studio for which I have the symbols, but not the source code (it's a Unity game, the source in question is for the UnityPlayer.dll. I do have the source for the actual exe file).
The symbols load correctly, I can break into the debugger and can see call stacks with function names, as I expect to.
However, when I try to add a function breakpoint, it does not work: the breakpoint gets added, but it shows a little error icon in the Breakpoint window, and it's never hit.
If I double-click on a stack frame, I can get to the disassembly window, and the "Address" bar correctly shows the function name. However, if I try to enter any symbol name in the bar - including just copying the one it's already showing - I get an error message saying "identifier "whatever" is undefined". It's as if some part of Visual Studio is not aware of the loaded symbols.
One suspicious thing I noticed is that in the call stack window, all frames not in the actual exe file are shown with the "Unknown" language. I have no idea what is causing this.
Here's a picture to hopefully make this a little clearer:
What can I do to fix this, or at least work around the issue somehow? I've encountered this on VS 2017 and tried updating it to the latest version, and installing VS 2019, but nothing helped.
Notice in the names it's showing you, you get the parameter types too. Like, it's showing you FMOD_OS_Time_Sleep(unsigned int) and not just FMOD_OS_Time_Sleep. This is because the name is mangled, random looking characters are added on either side of the name to encode how many parameters it takes, and what types those parameters are.
One possibility is that it's expecting you to put in the mangled representation of the name. You can also try putting in the name exactly as it appears in the call stack, I would try both with UnityPlayer.dll! and without. Failing that, run strings on the dll to get the mangled representation of the function name and try that.

Backtracking during debugging in Visual Studio

Let's say I have function A(//Code: To Catch Some Error) in a class and that function A() is being called in 100 different pages.
I have put one breakpoint at that function A().
When I run the solution in the visual studio, this breakpoint is being hit.
Q: Is there any way to find from which page did this function A() was called before hitting the breakpoint?
Your best option is looking at the call stack. When you hit a breakpoint Visual Studio will by default include Call Stack window among the windows that appear below your main code window. You will see a list of nested function calls that took you to the breakpoint. Double-clicking on any of the functions should open it in the debugger, assuming you have the source code for it (some of them will be system functions).

Problems watching non-trivial expressions in visual studio debugger

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 CString 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.
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
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).
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.

Where is where is microsoft.office.tools.word.factory?

I'm in VS2010, in a new Word Add-In project. This is my first attempt at Word development using VSTO. The example I'm trying has this line:
Document vstoDoc = Globals.Factory.GetVstoObject(this.Application.ActiveDocument);
But when I add this line Visual Studio says it can't find "Factory". Indeed, it's not in Intellisense.
I've got references to:
Accessibility
Microsoft.Office.Interop.Word
Microsoft.Office.Tools.Common.v9.0
Microsoft.Office.Tools.v9.0
Microsoft.Office.Tools.Word.v9.0
Microsoft.VisualStudio.Tools.Applications.Runtime.v9.0
Office
and all the usual System references.
Where am I going wrong and why can't I get to "Factory"?
stdole
That example looks a bit weird to me. Never seen that sort of reference before.
Generally, with Vsto, you hook into EVENTS on, say, the main Word App object.
Then, from within the event, you usually are passed a reference to the particular DOC object that the event is occurring for (say, being opened or saved, etc). In that way, there shouldn't be any need for using the "globals" object or the "factory" object, whereever they might be.
What method is that code in? A little more context might help.
I think the recommended way of doing this is:
Globals.ThisAddin.Application.ActiveDocument

Cannot complete a basic task in QT4

I cannot open a new window in QT. I new in QT so I think I am missing something. I only write the code below and settings windows just shows itself and closes. I have commented out destructor but still problem persists.
SettingsWindow s;
s.show();
What do I do wrong ? By the way I cannot either debug it, debuger does not stop when it reaches to the first line for example.
Thanks
This can't possibly be the only code you wrote.
However, judging from your description the first thing that comes to mind is probably a missing call to QApplication::exec(). Somewhere in the code you haven't shown here there's an instance of QApplication, probably named app. After calling show on your window, make sure there's a call to exec.
Since you are using a non-pointer var, your window is destroy when it go our of scope (at the end of the function). If you use a pointer when exiting the function the memory is not deleted so you Windows will still be shown. But you will not be able to clean memory when closing the window if you can't anymore access to your pointer.
Maybe you need to create your window as member of the calling class in order to be able to destroy the window AND clean memory once you don't need anymore to display it (for example in the calling class destructor).

Resources