dmp文件的分析,可以借助各种工具,比如WinDbg, CDB , NTSD,KD等。Windbg提供了窗口接口,而CDB , NTSD是基于命令行的工具,它们都使用了同样的调试引擎Dbgeng.dll,该调试引擎就是 “Windows 调试程序”。

dbgeng.dll 可以在基于x86,x64 或ARM的处理器上运行,并且可以调试在那些相同体系结构上运行的代码。

dbgeng.dll 的使用:

out.hpp  
#ifndef __OUT_HPP__
#define __OUT_HPP__ #include <DbgEng.h> class StdioOutputCallbacks : public IDebugOutputCallbacks
{
public:
// IUnknown.
STDMETHOD(QueryInterface)(
THIS_
_In_ REFIID InterfaceId,
_Out_ PVOID* Interface
);
STDMETHOD_(ULONG, AddRef)(
THIS
);
STDMETHOD_(ULONG, Release)(
THIS
); // IDebugOutputCallbacks.
STDMETHOD(Output)(
THIS_
_In_ ULONG Mask,
_In_ PCSTR Text
);
}; extern StdioOutputCallbacks g_OutputCb; #endif // #ifndef __OUT_HPP__
 
out.cpp
#include <stdio.h>
#include <windows.h>
#include <dbgeng.h>
#include "out.hpp" StdioOutputCallbacks g_OutputCb;
FILE *fp = NULL; STDMETHODIMP
StdioOutputCallbacks::QueryInterface(
THIS_
_In_ REFIID InterfaceId,
_Out_ PVOID* Interface
)
{
if (!fp) {
fp = fopen("D:/ZZZ/analyze.txt", "w+");
} *Interface = NULL;
if (IsEqualIID(InterfaceId, __uuidof(IUnknown)) ||
IsEqualIID(InterfaceId, __uuidof(IDebugOutputCallbacks)))
{
*Interface = (IDebugOutputCallbacks *)this;
AddRef();
return S_OK;
}
else
{
return E_NOINTERFACE;
}
} STDMETHODIMP_(ULONG)
StdioOutputCallbacks::AddRef(
THIS
)
{
// This class is designed to be static so
// there's no true refcount.
return 1;
} STDMETHODIMP_(ULONG)
StdioOutputCallbacks::Release(
THIS
)
{
// This class is designed to be static so
// there's no true refcount.
//fclose(fp);
return 0;
} STDMETHODIMP
StdioOutputCallbacks::Output(
THIS_
_In_ ULONG Mask,
_In_ PCSTR Text
)
{
UNREFERENCED_PARAMETER(Mask);
//fputs(Text, fp);
fputs(Text, stdout);
return S_OK;
}
main.cpp
#include "out.hpp"

#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <windows.h>
#include <dbgeng.h> PSTR g_DumpFile;
IDebugClient* g_Client;
IDebugControl* g_Control;
IDebugSymbols3* g_Symbols3; void Exit(int Code, _In_ _Printf_format_string_ PCSTR Format, ...)
{
// Clean up any resources.
if (g_Symbols3 != NULL)
{
g_Symbols3->Release();
} if (g_Control != NULL) {
g_Control->Release();
} if (g_Client != NULL)
{
g_Client->SetOutputCallbacks(NULL);
g_Client->EndSession(DEBUG_END_PASSIVE);
g_Client->Release();
} // Output an error message if given.
if (Format != NULL)
{
va_list Args;
va_start(Args, Format);
vfprintf(stderr, Format, Args);
va_end(Args);
}
exit(Code);
} void CreateInterfaces(void)
{
HRESULT Status; // Start things off by getting an initial interface from
// the engine. This can be any engine interface but is
// generally IDebugClient as the client interface is
// where sessions are started.
if ((Status = DebugCreate(__uuidof(IDebugClient),
(void**)&g_Client)) != S_OK)
{
Exit(1, "DebugCreate failed, 0x%X\n", Status);
} // Query for some other interfaces that we'll need.
if ((Status = g_Client->QueryInterface(__uuidof(IDebugControl),
(void**)&g_Control)) != S_OK ||
(Status = g_Client->QueryInterface(__uuidof(IDebugSymbols3),
(void**)&g_Symbols3)) != S_OK)
{
Exit(1, "QueryInterface failed, 0x%X\n", Status);
}
} //typedef _Null_terminated_ CHAR *TTPSTR;
void ParseCommandLine(int Argc, _In_reads_(Argc) PSTR* Argv)
{
int i;
while (--Argc > 0)
{
Argv++;
if (!strcmp(Argv[0], "-z"))
{
Argv++;
Argc--;
if (Argc > 0)
{
g_DumpFile = Argv[0];
}
else
{
Exit(1, "-z missing argument\n");
}
}
else
{
//Exit(1, "Unknown command line argument '%s'\n", Argv[0]);
}
} if (g_DumpFile == NULL)
{
Exit(1, "No dump file specified, use -z <file>\n");
}
} void ApplyCommandLineArguments(void)
{
HRESULT Status; // Install output callbacks so we get any output that the
// later calls produce.
if ((Status = g_Client->SetOutputCallbacks(&g_OutputCb)) != S_OK)
{
Exit(1, "SetOutputCallbacks failed, 0x%X\n", Status);
} // Everything's set up so open the dump file.
if ((Status = g_Client->OpenDumpFile(g_DumpFile)) != S_OK)
{
Exit(1, "OpenDumpFile failed, 0x%X\n", Status);
} // Finish initialization by waiting for the event that
// caused the dump. This will return immediately as the
// dump file is considered to be at its event.
if ((Status = g_Control->WaitForEvent(DEBUG_WAIT_DEFAULT,
INFINITE)) != S_OK)
{
Exit(1, "WaitForEvent failed, 0x%X\n", Status);
} // Everything is now initialized and we can make any
// queries we want.
} void DumpStack(void)
{
HRESULT Status;
DEBUG_STACK_FRAME Frames[3] = { 0 };
ULONG Filled; g_Symbols3->SetScopeFromStoredEvent(); if (Frames == NULL)
{
Exit(1, "Unable to allocate stack frames\n");
} if ((Status = g_Control->
GetStackTrace(0, 0, 0,
Frames, 3, &Filled)) != S_OK)
{
Exit(1, "GetStackTrace failed, 0x%X\n", Status);
} printf("\nFirst %d frames of the call stack:\n", Filled); //// Print the call stack.
if ((Status = g_Control->
OutputStackTrace(DEBUG_OUTCTL_ALL_CLIENTS, Frames,
Filled, DEBUG_STACK_ARGUMENTS | DEBUG_STACK_SOURCE_LINE |
DEBUG_STACK_FRAME_ADDRESSES |
DEBUG_STACK_COLUMN_NAMES |
DEBUG_STACK_FRAME_NUMBERS)) != S_OK)
{
Exit(1, "OutputStackTrace failed, 0x%X\n", Status);
}
} int main(int argc, char *argv[])
{
CreateInterfaces();
ParseCommandLine(argc, argv);
ApplyCommandLineArguments();
DumpStack();
return 0;
}

dmp文件自动分析的更多相关文章

  1. Oracle 数据库导入导出 dmp文件

    转自: http://hi.baidu.com/ooofcu/blog/item/ec5d1f9580d41f007af48077.html 首先询问对方数据库的表空间名称和大小,然后在你的oracl ...

  2. 使用VS2013分析DMP文件

    当一个发布的.NET应用程序出现app crash,无法通过日志分析异常原因时,就需要通过分析DMP文件了,传统方式是通过WinDbg来分析DMP文件,但是WinDbg用起来不是很方便,其实VS就是一 ...

  3. Linux 中 Oracle dmp 文件导入导出

    a. 用户名 system 密码 manager 导出到D:/daochu.dmp中 exp system/manager@SID file=d:/daochu.dmp full=y b. 将数据库中 ...

  4. Oracle数据库导入、导出dmp文件

    oracle导出数据: 1.该处的导出数据需要在dos命令行下执行,进入到oracle客户端路径下执行(该处也可为oracle客户端路径配置系统变量),如: E:\oraclexe\app\oracl ...

  5. Oracle----SQL语句积累 (Oracle 导入 dmp文件)

    Oracle----SQL语句积累 (Oracle 导入 dmp文件) Oracle SQL PL  导入dum文件 1.数据库DBA权限: 注意:这个是在cmd命令行中直接输入,不需要进入Oracl ...

  6. Oracle导出表(即DMP文件)的两种方法

    转载:http://blog.csdn.net/lanpy88/article/details/7580691   方法一:利用PL/SQL Developer工具导出: 菜单栏---->Too ...

  7. Linux下oracle11gR2系统安装到数据库建立配置及最后oracle的dmp文件导入一站式操作记录

    简介 之前也在linux下安装过oralce,可每次都是迷迷糊糊的,因为大脑一片空白,网上随便看见一个文档就直接复制,最后搞了乱七八糟,虽然装上了,却乱得很,现在记录下来,希望能给其他网上朋友遇到问题 ...

  8. Oracle dmp文件导入(还原)到不同的表空间和不同的用户下

    ------------------------------------- 从生产环境拷贝一个dmp备份文件,在另外一台电脑上搭建测试环境,用imp命令导入dmp文件时提示如下错误: 问题描述: IM ...

  9. Oracle数据库导入导出总结(dmp文件)

    Oracle 10G 管理页面(Oracle Enterprise Manager 10g): http://localhost:1158/em http://localhost:1158/em/co ...

随机推荐

  1. 珠心算测验(0)<P2014_1>

    珠心算测验 (count.cpp/c/pas) 问题描述]  珠心算是一种通过在脑中模拟算盘变化来完成快速运算的一种计算技术.珠心算训练,既能够开发智力,又能够为日常生活带来很多便利,因而在很多学校得 ...

  2. python中 yield 的用法 (简单、清晰)

    首先我要吐槽一下,看程序的过程中遇见了yield这个关键字,然后百度的时候,发现没有一个能简单的让我懂的,讲起来真TM的都是头头是道,什么参数,什么传递的,还口口声声说自己的教程是最简单的,最浅显易懂 ...

  3. 两台W7系统的电脑,A电脑可以ping通B电脑,B电脑ping不通A电脑。

    https://zhidao.baidu.com/question/1946500242424659908.html 打开控制面板-系统和安全-防火墙-允许程序-文件和打印机共享(勾选) 局域网共享是 ...

  4. Java基础 -5.3

    方法的递归调用 指的是一个方法自己调用自己的情况,利用递归调用可以解决一些重复且麻烦的问题 在进行我们递归调用的时候一般要考虑如下几点问题 一定要设置方法递归调用的结束条件 每一次调用的过程之中一定要 ...

  5. 第1节 Scala基础语法:scala中的方法源码分析

    val list=List(1,2,3,4) list.reduce((x:Int,y:Int)=>x+y)--->list.reduceLeft((x:Int,y:Int)=>x+ ...

  6. Linux CentOS7 rsync通过服务同步、linux系统日志、screen工具

    一.rsync通过服务同步 rsyncd.conf配置文件详解 port:指定在哪个端口启动rsyncd服务,默认是873端口. log file:指定日志文件. pid file:指定pid文件,这 ...

  7. [aac @ ...] more samples than frame size (avcodec_encode_audio2)

    在用FFmpeg对音频进行编码的时候报如下错误: [aac @ 000001cfc2717200] more samples than frame size (avcodec_encode_audio ...

  8. Django 学习之Xadmin

    一.xadmin的特点 1.基于Bootstrap3:Xadmin使用Bootstrap3.0框架精心打造.基于Bootstrap3,Xadmin天生就支持在多种屏幕上无缝浏览,并完全支持Bootst ...

  9. 五、Centos7安装mysql:第一步查看系统有无mysql,然后删除之

    CentOS下MySQL的彻底卸载 原创 2015年10月12日 00:16:02 标签: 21149 编辑 删除 #################CentOS7下MySQL的卸载######### ...

  10. 三 SprigMvc与Mybatis整合&实现商品列表功能

    思路: Dao层: 1 逆向工程生成mapper及其配置文件以及pojo 2 SqlMapConfig.xml,空文件即可,需要文件头 3 applicationContext-dao.xml a 数 ...