c# - Debugging .dmp files from WinDbg in Visual Studio 2008 for .Net managed apps -
i trying find how take crash dump of .net managed executable , open resulting .dmp file in visual studio 2008. want see in source code exception thrown, call stack , value of variables in functions on stack.
to simplify problem, i've written mini-app crashes:
...
class program { static void main(string[] args) { int = 2; //variable want see value when debugging if (!file.exists(@"c:\crasher\bin\debug\file.txt")) //doesn't exist throw new filenotfoundexception(); //unhandled exception thrown } }
...
i did debug build , ran outside visual studio. in windbg, clicked "attach process" , selected app. typed in windbg command window:
.dump /ma c:\crasher\bin\debug\dump.dmp
then opened .dmp file in visual studio. went tools->options->debugging->symbols , added following:
http://msdl.microsoft.com/download/symbols (saved local folder)
this gives me symbols of dlls listed in modules window (e.g. kernel32.dll, gdi32.dll - think of them listed native) exception of mscorlib.ni.dll. microsoft symbol server gives me symbols builds , .pdbs mscorlib.dll not mscorlib.ni.dll.
when try load .pdb .exe itself, tells me not match app. think because .exe managed , don't yet have symbols of native code beneath - i.e. if symbols build , pdb mscorlib.ni.dll work.
is reasoning correct? missing else?
either way, why mscorlib.ni.dll not available on microsoft symbol server, can symbol information , there else should know debugging managed code through crash dumps in visual studio.
many - appreciated.
phil whittington
as jason evans says in comment, not supported in vs2008, can in windbg.
the easiest way correct dump crash use adplus (which included in debugging tools windows). there various options, crash dump based on process name,
>adplus -crash -o c:\dumpdirectory -pn app.exe
this give 2 dumps. 1 first chance exception , 1 second. in case virtually identical, more realistic scenario first chance exception dump show state of application when exception thrown (i.e. before exception handling occur). second chance exception dump show state of unhandled exception.
to exception, open crash dump , load sos typing .loadby sos mscorwks
.
then use !pe
command print exception on current thread (which faulting thread in case). this:
0:000> !pe exception object: 024a5114 exception type: system.io.filenotfoundexception message: unable find specified file. innerexception: <none> stacktrace (generated): sp ip function 0020f0f0 005100d6 testbench!testbench.program.main()+0x66 stacktracestring: <none> hresult: 80070002
to list local variable a
use !clrstack -l
, keep in mind locals available in release mode builds due optimizations.
0:000> !clrstack -l os thread id: 0x1a50 (0) esp eip 0020f04c 7571b727 [helpermethodframe: 0020f04c] 0020f0f0 005100d6 testbench.program.main() locals: 0x0020f0fc = 0x00000002 <--- value of 0x0020f0f8 = 0x00000000 0020f328 51141b5c [gcframe: 0020f328]
Comments
Post a Comment