标题:qt 获取windows下崩溃日志的三种方法
作者:shixingya
日期:2018-05-07 10:39
内容:
long __stdcall MinGW_Callback(_EXCEPTION_POINTERS* excp)
{
CCrashStack crashStack(excp);
QString sCrashInfo = crashStack.GetExceptionInfo();
qDebug()
#1 [shixingya 05-07 10:41]
方式二
方式二
static LONG ApplicationCrashHandler(EXCEPTION_POINTERS *pException)
{
::SetCursor(LoadCursor(NULL, IDC_NO));
//And output crash information
EXCEPTION_RECORD *record = pException->ExceptionRecord;
QString errCode(QString::number(record->ExceptionCode, 16));
QString errAddr(QString::number((uint)record->ExceptionAddress, 16));
QString errFlag(QString::number(record->ExceptionFlags, 16));
QString errPara(QString::number(record->NumberParameters, 16));
qDebug()
#2 [九重水 05-07 14:42]
#3 [shixingya 05-07 16:54]
方式三 : 主要针对VS下pdb文件
#include "preheader.h"
#include "MiniDump.h"
#include
#include
MiniDump::MiniDump(void)
{
SetErrorMode(SEM_FAILCRITICALERRORS);
SetUnhandledExceptionFilter(&MiniDump::UnhandledExceptionFilter);
}
MiniDump::~MiniDump(void)
{
}
LONG WINAPI MiniDump::UnhandledExceptionFilter(LPEXCEPTION_POINTERS lpExceptionInfo)
{
if(IsDebuggerPresent())
{
return EXCEPTION_CONTINUE_SEARCH;
}
return GenerateMiniDump(NULL, lpExceptionInfo);
}
int MiniDump::GenerateMiniDump(HANDLE hFile, PEXCEPTION_POINTERS pExceptionPointers)
{
char szErrorMsg;
StringCchPrintfA(szErrorMsg, MAX_PATH, "An unexpected error has occured: \n\nFETAL ERROR!\n\nException: 0x%08x at 0x%p\n\nPressing OK will terminate the application and save the helpful debugging information that may help us resolve this issue in the future.", pExceptionPointers->ExceptionRecord->ExceptionCode, pExceptionPointers->ExceptionRecord->ExceptionAddress);
QMessageBox box(QMessageBox::Question,"批改系统崩溃","亲,我死了,是否生成错误报告?");
box.setStandardButtons (QMessageBox::Ok|QMessageBox::Cancel);
box.setDefaultButton(QMessageBox::Ok);
box.setButtonText (QMessageBox::Ok,QString("确 定"));
box.setButtonText (QMessageBox::Cancel,QString("取 消"));
box.setWindowFlags(Qt::WindowStaysOnTopHint);
if(box.exec () ==QMessageBox::Ok)
{
qDebug()