快捷搜索: 王者荣耀 脱发

用Windbg分析程序意外崩溃

可以针对Release版本程序的以为崩溃进行源代码级的定位:

Usage of Error Locater

Step 1: Add following file to your project

CrashFileNames.h

dbghelp.h

ExceptionHandler.h

FunctionStackTrace.h

GetWinVer.h

MiniVersion.h

ExceptionAttacher.cpp

ExceptionHandler.cpp

GetWinVer.cpp

MiniVersion.cpp

Dgbhelp.lib

To your project.

Step 2: Copy following file to your project’s output directory( ie.Debug or Release )

Dbghelp.dll

Step 3: In your VC++ project, go to Project | Settings. Make sure the Release configuration is selected in the Settings For combobox on the left. Go to the C/C++ tab, select the General category, and select Program Database in the Debug Info combobox. This tells the compiler to generate debug information.

Go to the Link tab and check Generate debug info. This tells the linker to collate debug information into .pdb files. The linker also puts the name of the .pdb file in the executable, so the debugger can find it.

On the same Link tab, enter /OPT:REF at the end of the Project Options list. This tells the linker to eliminate functions and/or data that are never referenced. This is the usually the default for release builds, but it gets turned off when you tell the linker to generate debug information.

Step 4: Set ExceptionHandler.cpp Not using precompiled headers on the C/C++ tab (Right click the file-> properties->c++->precompiled header)

Step 5: Compile the App, get the .exe and .pdb file in the output directory

Step 6: Run the app

Setp 7: Use windbg.exe to get source line when crash happens Or open GmsCrash.txt to view a error log of computer environment.

---------------

补充,WinDbg可以从以下地址下载安装

用WinDbg打开.dmp文件后,输入命令

!analyze -v

即可定位错误代码

如果该命令无效,可参考

标 题: 【讨论】如何分析堆栈出错的 dmp 文件 作 者: 小喂 时 间: 2007-09-05,15:41 链 接: http://bbs.pediy.com/showthread.php?t=51141 如何分析堆栈出错的 dmp 文件

经验分享 程序员 微信小程序 职场和发展