使用WinDBG生成dump文件 WinDBG分析dump文件

    xiaoxiao2021-03-25  108

    使用Windbg生成dump文件WinDBG  Windbg生成dump文件的方法: 程序崩溃(crash)的时候, 为了以后能够调试分析问题, 可以使用WinDBG要把当时程序内存空间数据都保存下来,生成的文件称为dump 文件。 步骤: 1) 打开WinDBG并将之Attach 到crash的程序进程 2) 输入产生dump 文件的命令 WinDBG产生dump 文件的命令是 .dump ,可以选择不同的参数来生成不同类型的dump文件。 选项(1): /m 

    命令行示例:.dump /m C:\dumps\myapp.dmp

    注解: 缺省选项,生成标准的minidump, 转储文件通常较小,便于在网络上通过邮件或其他方式传输。 这种文件的信息量较少,只包含系统信息、加载的模块(DLL)信息、 进程信息和线程信息。

    选项(2): /ma 命令行示例:.dump /ma C:\dumps\myapp.dmp 注解: 带有尽量多选项的minidump(包括完整的内存内容、句柄、未加载的模块,等等),文件很大,但如果条件允许(本机调试,局域网环境), 推荐使用这中dump。 

    选项(3):/mFhutwd

    命令行示例:.dump /mFhutwd C:\dumps\myapp.dmp

    注解:带有数据段、非共享的读/写内存页和其他有用的信息的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 

    转载请注明原文地址: https://ju.6miu.com/read-19064.html

    最新回复(0)