按前面介绍的方法在异常时停下来,!DumpStack可以查看方法调用堆栈
!DumpStack
OS Thread Id: 0xa3c (29)
Child-SP RetAddr Call Site
000000000505df80 000007feef989413 KERNELBASE!RaiseException+0x3d
000000000505e050 000007feefec3310 mscorwks!StrongNameFreeBuffer+0x53b7
000000000505e140 000007ff001a064b mscorwks!CorLaunchApplication+0xee90
000000000505e2f0 000007ff001a05a6 WebApplication1!WebApplication1._Default.Go(Int32, System.String)+0x7b
000000000505e330 000007fede0f3ec9 WebApplication1!WebApplication1._Default.Page_Load(System.Object, System.EventArgs)+0x46
然后用!Name2EE查看某一个方法的MethodDescription
0:029> !Name2EE WebApplication1!WebApplication1._Default.Go
Module: 000007ff00168d70 (WebApplication1.DLL)
Token: 0x0000000006000002
MethodDesc: 000007ff00169358
Name: WebApplication1._Default.Go(Int32, System.String)
JITTED Code Address: 000007ff001a05d0
然后用!DumpIL查看某一个方法的IL代码
0:029> !DumpIL 000007ff00169358
ilAddr = 0000000060f42060
IL_0000: nop
IL_0001: ldarg.1
IL_0002: stloc.0
IL_0003: ldstr "hello"
IL_0008: newobj System.NullReferenceException::.ctor
IL_000d: throw
用!U可以查看生成的汇编源代码
0:029> !U 000007ff00169358
Normal JIT generated code
WebApplication1._Default.Go(Int32, System.String)
Begin 000007ff001a05d0, size 83
000007ff`001a05d0 4c89442418 mov qword ptr [rsp+18h],r8
000007ff`001a05d5 89542410 mov dword ptr [rsp+10h],edx
000007ff`001a05d9 48894c2408 mov qword ptr [rsp+8],rcx
000007ff`001a05de 53 push rbx
000007ff`001a05df 4883ec30 sub rsp,30h
000007ff`001a05e3 c744242000000000 mov dword ptr [rsp+20h],0
000007ff`001a05eb 48b870901600ff070000 mov rax,7FF00169070h
000007ff`001a05f5 8b00 mov eax,dword ptr [rax]
000007ff`001a05f7 85c0 test eax,eax
000007ff`001a05f9 7405 je 000007ff`001a0600
000007ff`001a05fb e8c0f4b3ef call mscorwks!CorMarkThreadInThreadPool+0x3f30 (000007fe`efcdfac0) (JitHelp: CORINFO_HELP_DBG_IS_JUST_MY_CODE)
000007ff`001a0600 90 nop
000007ff`001a0601 8b442448 mov eax,dword ptr [rsp+48h]
000007ff`001a0605 89442420 mov dword ptr [rsp+20h],eax
000007ff`001a0609 48ba708d1600ff070000 mov rdx,7FF00168D70h
000007ff`001a0613 b90d000070 mov ecx,7000000Dh
000007ff`001a0618 e8f3a8c9ef call mscorwks!PreBindAssembly+0x5a5d0 (000007fe`efe3af10) (JitHelp: CORINFO_HELP_STRCNS)
000007ff`001a061d 488bd8 mov rbx,rax
*** WARNING: Unable to verify checksum for C:\Windows\assembly\NativeImages_v2.0.50727_64\mscorlib\969da204960244f3570058daa0aa3256\mscorlib.ni.dll
*** ERROR: Module load completed but symbols could not be loaded for C:\Windows\assembly\NativeImages_v2.0.50727_64\mscorlib\969da204960244f3570058daa0aa3256\mscorlib.ni.dll
000007ff`001a0620 48b978301aeefe070000 mov rcx,offset mscorlib_ni+0x453078 (000007fe`ee1a3078)
000007ff`001a062a e8c1e18def call mscorwks!IEE+0xbfa4 (000007fe`efa7e7f0) (JitHelp: CORINFO_HELP_NEWSFAST)
000007ff`001a062f 4889442428 mov qword ptr [rsp+28h],rax
000007ff`001a0634 488bd3 mov rdx,rbx
000007ff`001a0637 488b4c2428 mov rcx,qword ptr [rsp+28h]
000007ff`001a063c e87ff952ee call mscorlib_ni+0x97ffc0 (000007fe`ee6cffc0) (System.NullReferenceException..ctor(System.String), mdToken: 06000c25)
000007ff`001a0641 488b4c2428 mov rcx,qword ptr [rsp+28h]
000007ff`001a0646 e8952bd2ef call mscorwks!CorLaunchApplication+0xed60 (000007fe`efec31e0) (JitHelp: CORINFO_HELP_THROW)
000007ff`001a064b 90 nop
000007ff`001a064c 4883c430 add rsp,30h
000007ff`001a0650 5b pop rbx
000007ff`001a0651 f3c3 rep ret