天天看点

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.