DumpTest

所属分类:Windows编程
开发工具:C/C++
文件大小:10KB
下载次数:0
上传日期:2020-12-22 10:18:55
上 传 者晴天公子
说明:  程序在debug可以正常运行,但是在release版后异常结束,系统又没有提供任何信息情况下,或者程序发布后在客户手中出现异常崩溃,但自己测试又不能复现问题,要是能捕获到异常时相关信息就很好定位问题了。 资源中包含Qt mingw编译程序crash信息捕捉和跟踪方法说明,以及测试程序代码。 修改地方 1.*pro 文件添加调试信息;2.添加ccrashstack类,
(The program can run normally in debug, but it ends abnormally after the release version, and the system does not provide any information, or the program crashes in the customer's hands after the release, but the problem cannot be reproduced by self testing. If the relevant information can be captured when the exception is found, it is very good to locate the problem. Resource contains QT MinGW compiler crash information capture and tracking method description, as well as test program code.)

文件列表:
DumpTest (0, 2020-12-22)
DumpTest\DumpTest.pro (1300, 2020-12-22)
DumpTest\DumpTest.pro.user (24203, 2020-12-22)
DumpTest\ccrashstack.cpp (13935, 2019-03-22)
DumpTest\ccrashstack.h (543, 2019-03-22)
DumpTest\main.cpp (1608, 2020-12-22)
DumpTest\mainwindow.cpp (332, 2020-12-22)
DumpTest\mainwindow.h (366, 2019-03-22)
DumpTest\mainwindow.ui (1304, 2019-03-22)

# Qt程序crash信息捕捉和跟踪(mingw) 1. 项目配置 在.pro文件中添加: QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CXXFLAGS_RELEASE_WITH_DEBUGINFO QMAKE_CFLAGS_RELEASE = $$QMAKE_CLAGS_RELEASE_WITH_DEBUGINFO QMAKE_LFLAGS_RELEASE = $$QMAKE_LFLAGS_RELEASE_WITH_DEBUGINFO 2. 修改代码支持异常搜集 ``` #ifdef Q_OS_WIN long __stdcall callback(_EXCEPTION_POINTERS* excp) { CCrashStack crashStack(excp); QString sCrashInfo = crashStack.GetExceptionInfo(); TCHAR my_documents[MAX_PATH]; SHGetFolderPath(NULL, CSIDL_DESKTOP, NULL, SHGFP_TYPE_CURRENT, my_documents); QString file_path = QString::fromWCharArray(my_documents); QDir *folder_path = new QDir; bool exist = folder_path->exists(file_path.append("\\MyApp")); if(!exist) { folder_path->mkdir(file_path); } delete folder_path; folder_path = nullptr; QString sFileName = file_path + "\\crash.log"; QFile file(sFileName); if (file.open(QIODevice::WriteOnly|QIODevice::Truncate)) { file.write(sCrashInfo.toUtf8()); file.close(); } return EXCEPTION_EXECUTE_HANDLER; } #endif int main(int argc, char *argv[]) { #ifdef Q_OS_WIN SetUnhandledExceptionFilter(callback); #endif QApplication a(argc, argv); MainWindow w; w.show(); QString *p = NULL; p->clear(); return a.exec(); } ``` 3. 生成汇编信息 使用cmd命令 "objdump -S app.exe > app.asm" 生成汇编信息文件 4. 定位异常 查看crash.log里的 "Exception Addr: 004021D0" 在app.asm中查找相应地址 5. 缺点 程序文件中包含了调试信息和源代码信息,用户可以查看到。

近期下载者

相关文件


收藏者