天天看點

Windbg基本指令應用總結

.cordll -ve -u -l //reload core dlls

------加載下載下傳系統檔案符号的URL----------

.sympath SRV*C:Symbols*http://msdl.microsoft.com/download/symbols

---------加載.net元件------- ---------------

.loadby sos clr

.load psscor4

-----------------Memory檢視-------------------------

!dumpheap -stat //all .net objects statistics

!dumpheap -mt 000007feed866738 -min 80000 -max 90000 -stat //object size statistic

!dumpheap -mt 000007feed866738    -min 80000 //object in range addres list

!heap -s //shows heap summary

!heap -stat -h 00000000003a0000 //shows the heap statistics for the specified heap

!heap -flt s 1f64 //filters all other blocks of heap and displays the details of blocks having size 1f64

!heap -p -a UsrPtr //displays the call stack for UsrPtr

!traverseheap d:HeapStatus.log //dump heap log, analyze by CLRProfiler

-----------------CPU------------------------------

!threads //show manage and unmanaged threads

!threadpool // show cpu usage and thread pool statistics

!runaway //show running threads and their cpu consuming

!threads -special //show all threads including gc, finalizer etc.

----------------堆棧檢視----------------------------

~*e!mk //show all threads stack

~*kb 2000 //Examine the native callstacks

~*e!clrstack //Examine the .net callstacks 所有線程調用堆棧

!dso //find the objects on the stack

!clrstack 目前線程托管方法調用堆棧

k檢視調用堆棧

!finalizequeue

!gcroot <address of string> 被根化(rooted)到哪裡(即為什麼它們不會被回收)

!eeHeap -gc檢視.net GC 堆的大小

kb 2000産看目前線程本地(原生)調用堆棧

~* kb 2000 得到所有檢視本地資源的callstack 觸發GC的函數(mscorwks!)SVR::GCHeap::GarbageCollectGeneration)

GC 線程gc_heap::gc_thread_stub等待GC完成(GCHeap::WaitUntilGCComplete

------檢視請求的url----

!aspxpages

!clrusage

//gcroot all the objects, find where the object created .foreach (obj {!dumpheap -mt 000007fef4c3da30  -short}) {!gcroot obj; .echo -----}

--------------------異常檢視---------------

!pe 檢視異常

!dso 檢視棧上的對象

!pe [Object]列印出原先的異常,檢視輸出的資訊 !SaveModule <Base address> <Filename> base Address還可以通過lm指令檢視

!syncblk,檢視線程中,鎖的資訊

------------------自動分析----------------------

!analyze

------------------伺服器上dump檔案的方法-----

1.伺服器上使用windows任務管理器,選擇程序建立轉儲檔案即可。

2.Debugging Tools for Windows裡提供了一個好工具, 其路徑與Debugging Tools for Windows的安裝路徑相同,使用的方法如下所示: 在指令行模式下進入工具所在目錄執行: adplus.exe -hang -p 1234 -o d:dump

-p需要抓取檔案的程序ID

-o檔案輸出的路徑

adplus.exe -hang -p 33668 -o d:dump

adplus.exe -crash -p 33668 -o d:dump

目前安裝包名稱:X64 Debuggers And Tools-x64_en-us.msi

常用插件:

psscor4.dll下載下傳位址: http://www.microsoft.com/download/en/details.aspx?id=21255

SOS.dll 擷取位址:C:WindowsMicrosoft.NETFrameworkv2.0.50727