qt Creator 生成pdb文件、dump文件 、管理员权限、release 版本调试

在.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 = $$QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO
QMAKE_LFLAGS_RELEASE = $$QMAKE_LFLAGS_RELEASE_WITH_DEBUGINFO
 

 

 

生成dump文件

dump.h  

//#ifdef Q_OS_WIN  qt windows 宏
#pragma once
#include 
#include 
#include 

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进行调试

 

原地址 https://www.cnblogs.com/swarmbees/p/5621602.html

你可能感兴趣的:(QT)