qt Creator 生成pdb文件、dump文件

在.pro 文件中添加  重新构建 生成pdb文件

QMAKE_LFLAGS_RELEASE += /MAP
QMAKE_CFLAGS_RELEASE += /Zi
QMAKE_LFLAGS_RELEASE += /debug /opt:ref

管理员权限

.pro 文件添加  亲测可用 qt5.9.3   msvc2015   win32

QMAKE_LFLAGS += /MANIFESTUAC:\"level=\'requireAdministrator\' uiAccess=\'false\'\"

原文地址 https://blog.csdn.net/xiaoyan_yt/article/details/66974639

release版本调试  pro文件添加这两行   执行qmake 再重新构建

QMAKE_CXXFLAGS_RELEASE = [Math Processing Error]QMAKECFLAGSRELEASEWITHDEBUGINFOQMAKELFLAGSRELEASE=QMAKE_LFLAGS_RELEASE_WITH_DEBUGINFO
 

 

 

生成dump文件

dump.h  

//#ifdef Q_OS_WIN qt windows 宏

#pragma once

#include <Windows.h>

#include <dbghelp.h>

#include <string>

 

using namespace std;

 

#pragma comment(lib, "Dbghelp.lib")

void CreateDumpFile(LPCSTR lpstrDumpFilePathName, EXCEPTION_POINTERS *pException)

{

// 创建Dump文件

 

HANDLE hDumpFile = CreateFileA(lpstrDumpFilePathName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);

 

// Dump信息

MINIDUMP_EXCEPTION_INFORMATION dumpInfo;

dumpInfo.ExceptionPointers = pException;

dumpInfo.ThreadId = GetCurrentThreadId();

dumpInfo.ClientPointers = TRUE;

 

// 写入Dump文件内容

MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), hDumpFile, MiniDumpNormal, &dumpInfo, NULL, NULL);

 

CloseHandle(hDumpFile);

}

 

 

 

LONG ApplicationCrashHandler(EXCEPTION_POINTERS *pException)

{

// 这里弹出一个错误对话框并退出程序

char szPath[512];

GetModuleFileNameA(NULL, szPath, 512);

char *pChar = strrchr(szPath, '\\');

*(pChar + 1) = 0;

string strPath = szPath;

SYSTEMTIME syst;

GetLocalTime(&syst);

char strCount[100];

sprintf_s(strCount, 100, "xphone_dump_%d.%.2d.%.2d.%.2d.%.2d.%.2d.%.3d.dmp", syst.wYear - 2000, syst.wMonth, syst.wDay, syst.wHour, syst.wMinute, syst.wSecond, syst.wMilliseconds);

 

strPath += string(strCount);

MakeSureDirectoryPathExists(strPath.c_str());

CreateDumpFile(strPath.c_str(), pException);

FatalAppExitA(0, "*** Unhandled Exception! ***");

 

return EXCEPTION_EXECUTE_HANDLER;

}

 

//#endif

 

 

test.cpp

#include "dump.h"

 

 

 

LONG __stdcall MyUnhandledExceptionFilter(PEXCEPTION_POINTERS pExceptionInfo)

{

char creashFile[100];

getcwd(creashFile, 100);

strcat(creashFile, "\\CreatFile.dmp");

CreateMiniDump(pExceptionInfo, creashFile);

return EXCEPTION_EXECUTE_HANDLER;

}

 

 

 

int main(int argc, char *argv[])

{

SetUnhandledExceptionFilter(MyUnhandledExceptionFilter);

 

//do something...

 

return 0;

 

 

 

}

dump+pdb 用windbg进行调试

 

  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值