注解:带有数据段、非共享的读/写内存页和其他有用的信息的minidump。包含了通过minidump能够得到的最多的信息。是一种折中方案。
--------------------------------------------------------------------------------
1.为什么需要dump 内存
系统经常出现各种各样的问题,这些问题,可能是本身程序设计的时候考虑的不够周全,导致的程序异常,或者系统本身的问题。那么,当系统crash或者发生exception的时候,如何获得系统的context,然后给出准确地diagnostics,然后提出resolution呢?
我们所说的crash或者exception包括各种各样的情况,比如系统某个进程占用大量资源,某个进程low performance,某个程序crash等等。为了获得发生crash或者exception的process的context, 我们必须得到发生exception的时候,该process的context。那么可以给该process进行捕捉一个snapshot。捕捉发生exception时刻的snapshot所用的方法就是dump当时该process的内存。
2.dump内存的方法
这里介绍一种dump内存的方法,就是windbg中的.dump。当程序发生异常时,我们可以通过该方法snapshot该process在发生exception的时候的context。
具体做法就是:
当program发生exception的时候,或者发生之前,我们可以将windbg attach to a specific process in which en exception will occur. 然后在windbg command window中,type g or press F5 to let the program execute.如果不出意外的话,会出现exception,然后我们我们可以用.dump command来capture the snapshot。the following section is the usage about command .dump.
.dump (Create Dump File)
The .dump command creates a user-mode or kernel-mode crash dump file.
Syntax
.dump Options FileName
.dump /?
Parameters
Options
Represents one or more of the following options
/o
Overwrites an existing dump file with the same name. If this is option not used and the there is a file with the same file name, the dump file is not written.
/f