[url=http://xiazai.jb51.net/201504/other/debugtools.rar]这里下载[/url]。
3.下面通过一个实例来演示下效果:
#include <stdio.h>
void test2()
{
int a = 1;
int b = 0;
int c = a/b;
}
void test1()
{
test2();
}
int main(int argc, char** argv)
{
test1();
return 0;
}
我们通过除0错误来构造一次崩溃,test1和test2是为了演示调用堆栈。
通过本方法抓取的堆栈文本如下:
Opened log file 'D:\Dump\dump_22d4_2014-09-30_15-15-33-062.txt'
Debug session time: Tue Sep 30 15:15:33.063 2014 (GMT+8)
System Uptime: 2 days 3:35:54.545
Process Uptime: 0 days 0:00:00.923
Kernel time: 0 days 0:00:00.015
User time: 0 days 0:00:00.000
Process Status:
. 0 id: 3854 attach name: D:\xcb\20140808\test\CoreDump\DumpExampleNormalStack.exe
Thread Status:
. 0 Id: 3854.3138 Suspend: 1 Teb: 7ffdf000 Unfrozen
Stack Status:
*** ERROR: Symbol file could not be found. Defaulted to export symbols for C:\Windows\SYSTEM32\ntdll.dll -
# ChildEBP RetAddr
002dfb2c 01321038 DumpExampleNormalStack!test2(void)+0x18
002dfb34 01321048 DumpExampleNormalStack!test1(void)+0x8
002dfb3c 01321159 DumpExampleNormalStack!main(int argc = 1, char ** argv = 0x003ea488)+0x8
*** ERROR: Symbol file could not be found. Defaulted to export symbols for C:\Windows\system32\kernel32.dll -
002dfb84 76e2ee1c DumpExampleNormalStack!__tmainCRTStartup(void)+0xfe
WARNING: Stack unwind information not available. Following frames may be wrong.
002dfb90 77ba37eb kernel32!BaseThreadInitThunk+0x12
002dfbd0 77ba37be ntdll!RtlInitializeExceptionChain+0xef
002dfbe8 00000000 ntdll!RtlInitializeExceptionChain+0xc2
Closing open log file D:\Dump\dump_22d4_2014-09-30_15-15-33-062.txt
切记:在Release版本中需要把调试选项打开,而且生成的pdb文件和exe要放在同一目录下。
完~