當我們要在IIS PRD環境下分析異常,并且對問題毫無頭緒,又沒有權限直接上打Log的代碼。這個時候就是Debug Diagnostics Tool & Windbg大顯神威的時候了。
Debug Diagnostics Tool
安裝方法各位大俠請自行百度,重點說一下抓轉儲文件。
一開始是選擇抓取的程序,我當然要抓IIS的應用程序池嘍。。。
設定要抓取的文件個數,點擊Exceptions可以設定在發生什么異常時候抓取。
我當然是要抓高大上的.Net異常嘍。。。
接下來是設置保存的位置。
為了演示隨便搞了一個會拋出異常的頁面:
看一下生成的轉儲文件長個毛樣子哇:
Windbg
下面該windbg出手了,這個網上教程比較多,直接說重點了:
~#:查看問題線程,~線程id s:切換線程,!clrstack -l:查看當前堆棧并打印局部變量。
0:023> ~#. 23 Id: 790.1280 Suspend: 1 Teb: 000007ff`ffec6000 Unfrozen Start: clr!Thread::intermediateThreadProc (000007fe`ef57dafc) Priority: 0 Priority class: 32 Affinity: f0:023> ~23 sKERNELBASE!RaiseException+0x39:000007fe`fdfaaaad 4881c4c8000000 add rsp,0C8h0:023> !clrstack -lOS Thread Id: 0x1280 (23) Child SP ip Call Site000000000d3ad610 000007fefdfaaaad [FaultingExceptionFrame: 000000000d3ad610] 000000000d3adb60 000007fe8fe415cc *** WARNING: Unable to verify checksum for App_Web_ix1d1jtk.dll_Default.Page_Load(System.Object, System.EventArgs) [c:/inetpub/wwwroot/Default.aspx.cs @ 17] LOCALS: 0x000000000d3adb80 = 0x00000000fff4d4e8 0x000000000d3adb88 = 0x0000000000000000 0x000000000d3adb8c = 0x0000000000000001
呵呵,0x00000000fff4d4e8這個地址就是我們代碼里面隨便new的對象:sssssss奧,來DO一下看看這個對象吧:
0:023> !do 0x00000000fff4d4e8Name: TestStaticMethodTable: 000007fe8fe2c3d8EEClass: 000007fe8fe18bc8Size: 24(0x18) bytesFile: C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary asp.net Files/root/e22c2559/92c7e946/App_Web_ix1d1jtk.dllFields: MT Field Offset Type VT Attr Value Name000007feee4f0e08 400000d 28 System.String 0 static 0000000400031900 abc
再來看一下他的字符串成員abc
0:023> !do 0000000400031900Name: System.StringMethodTable: 000007feee4f0e08EEClass: 000007feede14860Size: 48(0x30) bytesFile: C:/Windows/Microsoft.Net/assembly/GAC_64/mscorlib/v4.0_4.0.0.0__b77a5c561934e089/mscorlib.dllString: 11111111111Fields: MT Field Offset Type VT Attr Value Name000007feee4f3980 40000ab 8 System.Int32 1 instance 11 m_stringLength000007feee4f20f0 40000ac c System.Char 1 instance 31 m_firstChar000007feee4f0e08 40000ad 18 System.String 0 shared static Empty
|
新聞熱點
疑難解答