Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I cast a memory address to a user defined type in the VS2019 watch window when debugging assembly?

I'm trying to debug a crash in an exe where my own code is in a dll the exe is loading. I have an assembly only callstack in the exe, and managed to trace back to my own code and find addresses of my own objects that I wish to debug.

However I don't seem to be able to cast the memory addresses to my own types in the watch window: I just get 'identifier "(my type)" is undefined'.

I am guessing this just isn't possible when I'm not in a stack of my own code, but it seems like the debugger could know the types if I could give it more information somehow.

I have tried a few of my own types but all give identifier undefined. I also looked into exported symbols for my types to see if there was something there I could use (based on a suggestion in another SO post), however I think the pdb itself contains the type information I need to point the debugger at.

Of course my pdb is loaded for my own dll, but the watch window seems to not want to look at it when not related stack frames.

like image 346
billw Avatar asked Sep 01 '19 16:09

billw


People also ask

How do I add a variable to a watch in Visual Studio?

Select the variable a in the code. Select Debug > QuickWatch, press Shift+F9, or right-click and select QuickWatch.


1 Answers

Try to specify your dll's module name, like (yourDll.dll!mytype*)0x12345678

See also https://docs.microsoft.com/en-us/visualstudio/debugger/context-operator-cpp?view=vs-2019

like image 112
Kjell Gunnar Avatar answered Sep 30 '22 19:09

Kjell Gunnar