QT生成崩溃dmp文件
// 崩溃定位
static LONG TopLevelExceptionFilter(EXCEPTION_POINTERS *pExceptionPointers)
{
QDateTime dateTime = QDateTime::currentDateTime();
QString appDirPath = QCoreApplication::applicationDirPath();
QString fileName = appDirPath + "/crash_" + dateTime.toString("yyyyMMddhhmmss") + ".dmp";
HANDLE hDmpFile = CreateFile((LPCTSTR)fileName.utf16(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (hDmpFile != INVALID_HANDLE_VALUE)
{
MINIDUMP_EXCEPTION_INFORMATION dmpInfo;
dmpInfo.ExceptionPointers = pExceptionPointers;
dmpInfo.ThreadId = GetCurrentThreadId();
dmpInfo.ClientPointers = TRUE;
typedef BOOL(WINAPI * PFN_MiniDumpWriteDump)(
HANDLE,
DWORD,
HANDLE,
MINIDUMP_TYPE,
PMINIDUMP_EXCEPTION_INFORMATION,
PMINIDUMP_USER_STREAM_INFORMATION,
PMINIDUMP_CALLBACK_INFORMATION
);
PFN_MiniDumpWriteDump pfnMiniDumpWriteDump = NULL;
HMODULE hModule = LoadLibraryW((L"DbgHelp.dll"));
if (hModule == NULL)
{
return EXCEPTION_CONTINUE_EXECUTION;
}
pfnMiniDumpWriteDump = (PFN_MiniDumpWriteDump)GetProcAddress(hModule, ("MiniDumpWriteDump"));
if (pfnMiniDumpWriteDump == NULL)
{
FreeLibrary(hModule);
return EXCEPTION_CONTINUE_EXECUTION;
}
pfnMiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), hDmpFile, MiniDumpNormal, &dmpInfo, NULL, NULL);
CloseHandle(hDmpFile);
}
return EXCEPTION_EXECUTE_HANDLER;
}
int main(int argc, char *argv[])
{
SetUnhandledExceptionFilter((LPTOP_LEVEL_EXCEPTION_FILTER)TopLevelExceptionFilter);
int *p = nullptr;
*p = 1000;
return(0);
}
附件为解析工具。