mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 19:48:20 +02:00
Added crash text to minidump
This commit is contained in:
parent
7bd29b5b69
commit
a7e9182d4b
3 changed files with 61 additions and 48 deletions
|
@ -560,23 +560,26 @@ static bool CreateMiniDump(EXCEPTION_POINTERS* pep, const StringImpl& filePath)
|
||||||
|
|
||||||
MINIDUMP_TYPE mdt = (MINIDUMP_TYPE)(MiniDumpWithIndirectlyReferencedMemory | MiniDumpScanMemory);
|
MINIDUMP_TYPE mdt = (MINIDUMP_TYPE)(MiniDumpWithIndirectlyReferencedMemory | MiniDumpScanMemory);
|
||||||
|
|
||||||
|
CrashCatcher* crashCatcher = CrashCatcher::Get();
|
||||||
|
|
||||||
|
MINIDUMP_USER_STREAM user_info_stream = {
|
||||||
|
0xBEEF00,
|
||||||
|
(ULONG)crashCatcher->mCrashInfo.length(),
|
||||||
|
(void*)crashCatcher->mCrashInfo.c_str()
|
||||||
|
};
|
||||||
|
MINIDUMP_USER_STREAM_INFORMATION user_stream_info = {
|
||||||
|
1,
|
||||||
|
&user_info_stream
|
||||||
|
};
|
||||||
|
|
||||||
BOOL rv = (*pFn)(GetCurrentProcess(), GetCurrentProcessId(),
|
BOOL rv = (*pFn)(GetCurrentProcess(), GetCurrentProcessId(),
|
||||||
hFile, mdt, (pep != 0) ? &mdei : 0, 0, &mci);
|
hFile, mdt, (pep != 0) ? &mdei : 0, &user_stream_info, &mci);
|
||||||
|
|
||||||
// Close the file
|
// Close the file
|
||||||
CloseHandle(hFile);
|
CloseHandle(hFile);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
//LONG WINAPI MyUnhandledExceptionFilter(
|
|
||||||
// struct _EXCEPTION_POINTERS *ExceptionInfo
|
|
||||||
//)
|
|
||||||
//{
|
|
||||||
// CreateMiniDump(ExceptionInfo);
|
|
||||||
// return EXCEPTION_EXECUTE_HANDLER;
|
|
||||||
//}
|
|
||||||
|
|
||||||
static String ImageHelpWalk(PCONTEXT theContext, int theSkipCount)
|
static String ImageHelpWalk(PCONTEXT theContext, int theSkipCount)
|
||||||
{
|
{
|
||||||
//char aBuffer[2048];
|
//char aBuffer[2048];
|
||||||
|
@ -818,41 +821,24 @@ static void DoHandleDebugEvent(LPEXCEPTION_POINTERS lpEP)
|
||||||
|
|
||||||
String anErrorTitle;
|
String anErrorTitle;
|
||||||
String aDebugDump;
|
String aDebugDump;
|
||||||
|
String& crashInfo = CrashCatcher::Get()->mCrashInfo;
|
||||||
|
|
||||||
char aBuffer[2048];
|
char aBuffer[2048];
|
||||||
|
|
||||||
if (isCLI)
|
if (isCLI)
|
||||||
aDebugDump += "**** FATAL APPLICATION ERROR ****\n";
|
aDebugDump += "**** FATAL APPLICATION ERROR ****\n";
|
||||||
|
|
||||||
WCHAR exeFilePathW[MAX_PATH];
|
|
||||||
exeFilePathW[0] = 0;
|
|
||||||
::GetModuleFileNameW(hMod, exeFilePathW, MAX_PATH);
|
|
||||||
String exeFilePath = UTF8Encode(exeFilePathW);
|
|
||||||
String exeDir = GetFileDir(exeFilePath);
|
|
||||||
String crashPath = exeDir + "\\CrashDumps";
|
|
||||||
if (BfpDirectory_Exists(crashPath.c_str()))
|
|
||||||
{
|
|
||||||
crashPath += "\\" + GetFileName(exeFilePath);
|
|
||||||
crashPath.RemoveToEnd((int)crashPath.length() - 4);
|
|
||||||
crashPath += "_";
|
|
||||||
|
|
||||||
time_t curTime = time(NULL);
|
|
||||||
auto time_info = localtime(&curTime);
|
|
||||||
crashPath += StrFormat("%4d%02d%02d_%02d%02d%02d",
|
|
||||||
time_info->tm_year + 1900, time_info->tm_mon + 1, time_info->tm_mday,
|
|
||||||
time_info->tm_hour, time_info->tm_min, time_info->tm_sec);
|
|
||||||
crashPath += ".dmp";
|
|
||||||
|
|
||||||
if (CreateMiniDump(lpEP, crashPath))
|
|
||||||
{
|
|
||||||
aDebugDump += StrFormat("Crash minidump saved as %s\n", crashPath.c_str());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (auto func : CrashCatcher::Get()->mCrashInfoFuncs)
|
for (auto func : CrashCatcher::Get()->mCrashInfoFuncs)
|
||||||
func();
|
func();
|
||||||
|
|
||||||
aDebugDump.Append(CrashCatcher::Get()->mCrashInfo);
|
CHAR path[MAX_PATH];
|
||||||
|
GetModuleFileNameA(NULL, path, MAX_PATH);
|
||||||
|
crashInfo += "\nExecutable: ";
|
||||||
|
crashInfo += path;
|
||||||
|
crashInfo += "\r\n";
|
||||||
|
crashInfo += GetVersion(path);
|
||||||
|
|
||||||
|
aDebugDump.Append(crashInfo);
|
||||||
|
|
||||||
for (int i = 0; i < (int)aDebugDump.length(); i++)
|
for (int i = 0; i < (int)aDebugDump.length(); i++)
|
||||||
{
|
{
|
||||||
|
@ -880,6 +866,31 @@ static void DoHandleDebugEvent(LPEXCEPTION_POINTERS lpEP)
|
||||||
aDebugDump += "\r\n";
|
aDebugDump += "\r\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WCHAR exeFilePathW[MAX_PATH];
|
||||||
|
exeFilePathW[0] = 0;
|
||||||
|
::GetModuleFileNameW(hMod, exeFilePathW, MAX_PATH);
|
||||||
|
String exeFilePath = UTF8Encode(exeFilePathW);
|
||||||
|
String exeDir = GetFileDir(exeFilePath);
|
||||||
|
String crashPath = exeDir + "\\CrashDumps";
|
||||||
|
if (BfpDirectory_Exists(crashPath.c_str()))
|
||||||
|
{
|
||||||
|
crashPath += "\\" + GetFileName(exeFilePath);
|
||||||
|
crashPath.RemoveToEnd((int)crashPath.length() - 4);
|
||||||
|
crashPath += "_";
|
||||||
|
|
||||||
|
time_t curTime = time(NULL);
|
||||||
|
auto time_info = localtime(&curTime);
|
||||||
|
crashPath += StrFormat("%4d%02d%02d_%02d%02d%02d",
|
||||||
|
time_info->tm_year + 1900, time_info->tm_mon + 1, time_info->tm_mday,
|
||||||
|
time_info->tm_hour, time_info->tm_min, time_info->tm_sec);
|
||||||
|
crashPath += ".dmp";
|
||||||
|
|
||||||
|
if (CreateMiniDump(lpEP, crashPath))
|
||||||
|
{
|
||||||
|
aDebugDump += StrFormat("Crash minidump saved as %s\n", crashPath.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////
|
///////////////////////////
|
||||||
// first name the exception
|
// first name the exception
|
||||||
char *szName = NULL;
|
char *szName = NULL;
|
||||||
|
@ -910,13 +921,6 @@ static void DoHandleDebugEvent(LPEXCEPTION_POINTERS lpEP)
|
||||||
uintptr section, offset;
|
uintptr section, offset;
|
||||||
GetLogicalAddress(lpEP->ExceptionRecord->ExceptionAddress, aBuffer, sizeof(aBuffer), section, offset);
|
GetLogicalAddress(lpEP->ExceptionRecord->ExceptionAddress, aBuffer, sizeof(aBuffer), section, offset);
|
||||||
|
|
||||||
CHAR path[MAX_PATH];
|
|
||||||
GetModuleFileNameA(NULL, path, MAX_PATH);
|
|
||||||
aDebugDump += "Executable: ";
|
|
||||||
aDebugDump += path;
|
|
||||||
aDebugDump += "\r\n";
|
|
||||||
aDebugDump += GetVersion(path);
|
|
||||||
aDebugDump += "\r\n";
|
|
||||||
|
|
||||||
aDebugDump += StrFormat("Logical Address: %04X:%@\r\n", section, offset);
|
aDebugDump += StrFormat("Logical Address: %04X:%@\r\n", section, offset);
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ class CrashCatcher
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Array<CrashInfoFunc> mCrashInfoFuncs;
|
Array<CrashInfoFunc> mCrashInfoFuncs;
|
||||||
StringT<0> mCrashInfo;
|
String mCrashInfo;
|
||||||
bool mCrashed;
|
bool mCrashed;
|
||||||
bool mInitialized;
|
bool mInitialized;
|
||||||
CritSect mBfpCritSect;
|
CritSect mBfpCritSect;
|
||||||
|
|
|
@ -222,6 +222,15 @@ MiniDumpDebugger::MiniDumpDebugger(DebugManager* debugManager, DbgMiniDump* mini
|
||||||
{
|
{
|
||||||
const char* report = &mMiniDump->GetStreamData<char>(section);
|
const char* report = &mMiniDump->GetStreamData<char>(section);
|
||||||
}
|
}
|
||||||
|
else if (section.mStreamType == 0x4b6b0002) // Stability report
|
||||||
|
{
|
||||||
|
const char* report = &mMiniDump->GetStreamData<char>(section);
|
||||||
|
}
|
||||||
|
else if (section.mStreamType == 0xBEEF00) // Error text
|
||||||
|
{
|
||||||
|
char* text = &mMiniDump->GetStreamData<char>(section);
|
||||||
|
OutputMessage(String(text, section.mDataSize));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Run();
|
Run();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue