Skip to content

Commit

Permalink
Always use BugTrap to produce minidump
Browse files Browse the repository at this point in the history
New command line key -detailed_minidump that produces more detailed bump than usual
  • Loading branch information
Xottab-DUTY committed Aug 6, 2018
1 parent 4d73bb3 commit 1fb38b0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 39 deletions.
50 changes: 12 additions & 38 deletions src/xrCore/xrDebug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ static BOOL bException = FALSE;

#ifdef DEBUG
#define USE_OWN_ERROR_MESSAGE_WINDOW
#else
#define USE_OWN_MINI_DUMP
#endif

#if defined XR_X64
Expand Down Expand Up @@ -618,11 +616,14 @@ void WINAPI xrDebug::PreErrorHandler(INT_PTR)
void xrDebug::SetupExceptionHandler(const bool& dedicated)
{
#if defined(WINDOWS)
const auto commandLine = GetCommandLine();

// disable 'appname has stopped working' popup dialog
UINT prevMode = SetErrorMode(SEM_NOGPFAULTERRORBOX);
const auto prevMode = SetErrorMode(SEM_NOGPFAULTERRORBOX);
SetErrorMode(prevMode | SEM_NOGPFAULTERRORBOX);
BT_InstallSehFilter();
if (!dedicated && !strstr(GetCommandLine(), "-silent_error_mode"))

if (!dedicated && !strstr(commandLine, "-silent_error_mode"))
BT_SetActivityType(BTA_SHOWUI);
else
BT_SetActivityType(BTA_SAVEREPORT);
Expand All @@ -636,50 +637,23 @@ void xrDebug::SetupExceptionHandler(const bool& dedicated)
BT_SetAppName("X-Ray Engine");
BT_SetReportFormat(BTRF_TEXT);
BT_SetFlags(BTF_DETAILEDMODE | BTF_ATTACHREPORT);

#ifdef MASTER_GOLD
#ifdef _EDITOR // MASTER_GOLD && EDITOR
auto minidumpFlags = !dedicated ? MiniDumpNoDump : MiniDumpWithDataSegs;
#else // MASTER_GOLD && !EDITOR
auto minidumpFlags = !dedicated ? MiniDumpNoDump : MiniDumpWithDataSegs | MiniDumpWithIndirectlyReferencedMemory;
#endif
auto minidumpFlags = MiniDumpFilterMemory | MiniDumpScanMemory;

if (strstr(commandLine, "-detailed_minidump"))
minidumpFlags = MiniDumpWithDataSegs | MiniDumpWithIndirectlyReferencedMemory;
#else
#ifdef EDITOR // !MASTER_GOLD && EDITOR
auto minidumpFlags = MiniDumpWithDataSegs;
#else // !MASTER_GOLD && !EDITOR
auto minidumpFlags = MiniDumpWithDataSegs | MiniDumpWithIndirectlyReferencedMemory;
#endif
const auto minidumpFlags = MiniDumpWithDataSegs | MiniDumpWithIndirectlyReferencedMemory;
#endif

BT_SetDumpType(minidumpFlags);
//BT_SetSupportEMail("[email protected]");
BT_SetSupportEMail("[email protected]");
#endif
}
#endif // USE_BUG_TRAP

#ifdef USE_OWN_MINI_DUMP
void xrDebug::SaveMiniDump(EXCEPTION_POINTERS *exPtrs)
{
#if defined(WINDOWS)
string64 dateStr;
timestamp(dateStr);
string_path dumpPath;
xr_sprintf(dumpPath, sizeof(dumpPath), "%s_%s_%s.mdmp", Core.ApplicationName, Core.UserName, dateStr);
__try
{
if (FS.path_exist("$logs$"))
FS.update_path(dumpPath, "$logs$", dumpPath);
}
__except (EXCEPTION_EXECUTE_HANDLER)
{
string_path temp;
xr_strcpy(temp, dumpPath);
xr_sprintf(dumpPath, sizeof(dumpPath), "logs/%s", temp);
}
WriteMiniDump(MINIDUMP_TYPE(MiniDumpFilterMemory | MiniDumpScanMemory), dumpPath, GetCurrentThreadId(), exPtrs);
#endif
}
#endif

void xrDebug::FormatLastError(char* buffer, const size_t& bufferSize)
{
#if defined(WINDOWS)
Expand Down
1 change: 0 additions & 1 deletion src/xrCore/xrDebug.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ class XRCORE_API xrDebug
static void SetupExceptionHandler(const bool& dedicated);
static LONG WINAPI UnhandledFilter(EXCEPTION_POINTERS* exPtrs);
static void WINAPI PreErrorHandler(INT_PTR);
static void SaveMiniDump(EXCEPTION_POINTERS* exPtrs);
#if defined(WINDOWS)
static xr_vector<xr_string> BuildStackTrace(PCONTEXT threadCtx, u16 maxFramesCount);
static bool GetNextStackFrameString(LPSTACKFRAME stackFrame, PCONTEXT threadCtx, xr_string& frameStr);
Expand Down

0 comments on commit 1fb38b0

Please sign in to comment.