天天看點

WinDBG生成Dump 檔案

Windbg .dump 指令: .dump [Options] <File Name>

Options 表示有很多選項,

/o 表示可以重寫 (overwrites) 一個已經存在的dump檔案并使用相同的檔案名。

/f表示有2層意思:如果在核心模式,将建立一個完整的Kernel-Model dump 檔案。該檔案包含所有出錯時的記憶體資訊。要注意的是,這樣的話dump檔案會很大。另一層的意思是如果在使用者模式下,将建立包含程序所占的記憶體大小,程式執行的情況,以及相應的處理和一些有用的其它資訊。

/m[options],該指令是建立一個小的記憶體dump檔案(核心模式下)或者一個minidump(使用者模式下)。這樣建立出來的dump檔案體積小,又包含有用的資訊。如果配合相應的選項,建立出來的dump檔案可以說是“短小精悍“了!

.dump /m c:\example_dump.dmp

生成标準的minidump, 轉儲檔案通常較小,便于在網絡上通過郵件或其他方式傳輸。 這種檔案的資訊量較少,隻包含系統資訊、加載的子產品(DLL)資訊、 程序資訊和線程資訊。

dump /ma c:\example_dump.dmp

帶有盡量多選項的minidump(包括完整的記憶體内容、句柄、未加載的子產品,等等),檔案很大,但如果條件允許(本機調試,區域網路環境), 推薦使用這種。

抓取的時機:

實際上,察看dump檔案是個很浩大的工程,也和枯燥。是以,抓取一個比較精确的dump檔案是比較好的。

上面說到了2種dump檔案:full dump 和 mini dump。

Full dump 很大,包含的資訊多,建立時候相對省力,隻需要在debugger中斷的時候用下.dump指令就可以了。Mini dump需要找到異常第一次發生的地方,這其中,還有許多異常是程式預期的 ,也就是說,你需要有判斷該異常是不是導緻程式中斷的最終原因的能力。

=================================================================

/m[MiniOptions] Creates asmall memory dump(in kernel mode) or aminidump(in user mode). If neither/fnor/mis specified,/mis the default.

In user mode,/mcan be followed with additionalMiniOptionsspecifying extra data that is to be included in the dump. If noMiniOptionsare included, the dump will include module, thread, and stack information, but no additional data. You can add any of the followingMiniOptionsto change the contents of the dump file; they are case-sensitive.

aCreates a minidump with all optional additions. The/maoption is equivalent to/mfFhut— it adds full memory data, handle data, unloaded module information, basic memory information, and thread time information to the minidump.fAdds full memory data to the minidump. All accessible committed pages owned by the target application will be included.