I am getting an access violation error in an unmanaged dll I am writing, but when I try to debug It in a c# application it will only get the last frame of the call stack in Visual Studio's debug window.
I have debug->exceptions->System.AccessViolationException set to break the debugger when it is thrown.
myunmanaged.dll!ViolatingFunc() Line 100 + 0xc bytes
- - - -
[external code] //myunmanaged.dll!function that I want to see
- - - -
somecsharp.exe!com.somewhere.Form1.CallFuncThatCallsViolator();
I was hoping to walk up the unmanaged stack to see where the data gets turned to garbeldegook. Is this possible?
Answered
Enabling unmanaged debugging is step 1, but to get me all the way there I enabled microsoft symbols.
that made my stack trace look more like this:
myunmanaged.dll!ViolatingFunc()
- - - -
myunmanaged.dll!SomeFunc2()
- - - -
myunmanaged.dll!SomeFunc()
- - - -
[managed to unmanaged code transition]
- - - -
somecsharp.exe!com.somewhere.Form1.CallFuncThatCallsViolator();
Yes it is. You need to debug your application in 'Mixed-mode'. Right click on the project, select the 'Debug' tab and check 'Enable unmanaged code debugging'. You will see managed and native frames.
Edit: As ChrisO mentions not having MS symbols can make native debugging weird. Add the following to your symbols path for Windows symbols: http://msdl.microsoft.com/download/symbols
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With