Skip to content

Commit 1fb38b0

Browse files
committed
Always use BugTrap to produce minidump
New command line key -detailed_minidump that produces more detailed bump than usual
1 parent 4d73bb3 commit 1fb38b0

File tree

2 files changed

+12
-39
lines changed

2 files changed

+12
-39
lines changed

src/xrCore/xrDebug.cpp

Lines changed: 12 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ static BOOL bException = FALSE;
5353

5454
#ifdef DEBUG
5555
#define USE_OWN_ERROR_MESSAGE_WINDOW
56-
#else
57-
#define USE_OWN_MINI_DUMP
5856
#endif
5957

6058
#if defined XR_X64
@@ -618,11 +616,14 @@ void WINAPI xrDebug::PreErrorHandler(INT_PTR)
618616
void xrDebug::SetupExceptionHandler(const bool& dedicated)
619617
{
620618
#if defined(WINDOWS)
619+
const auto commandLine = GetCommandLine();
620+
621621
// disable 'appname has stopped working' popup dialog
622-
UINT prevMode = SetErrorMode(SEM_NOGPFAULTERRORBOX);
622+
const auto prevMode = SetErrorMode(SEM_NOGPFAULTERRORBOX);
623623
SetErrorMode(prevMode | SEM_NOGPFAULTERRORBOX);
624624
BT_InstallSehFilter();
625-
if (!dedicated && !strstr(GetCommandLine(), "-silent_error_mode"))
625+
626+
if (!dedicated && !strstr(commandLine, "-silent_error_mode"))
626627
BT_SetActivityType(BTA_SHOWUI);
627628
else
628629
BT_SetActivityType(BTA_SAVEREPORT);
@@ -636,50 +637,23 @@ void xrDebug::SetupExceptionHandler(const bool& dedicated)
636637
BT_SetAppName("X-Ray Engine");
637638
BT_SetReportFormat(BTRF_TEXT);
638639
BT_SetFlags(BTF_DETAILEDMODE | BTF_ATTACHREPORT);
640+
639641
#ifdef MASTER_GOLD
640-
#ifdef _EDITOR // MASTER_GOLD && EDITOR
641-
auto minidumpFlags = !dedicated ? MiniDumpNoDump : MiniDumpWithDataSegs;
642-
#else // MASTER_GOLD && !EDITOR
643-
auto minidumpFlags = !dedicated ? MiniDumpNoDump : MiniDumpWithDataSegs | MiniDumpWithIndirectlyReferencedMemory;
644-
#endif
642+
auto minidumpFlags = MiniDumpFilterMemory | MiniDumpScanMemory;
643+
644+
if (strstr(commandLine, "-detailed_minidump"))
645+
minidumpFlags = MiniDumpWithDataSegs | MiniDumpWithIndirectlyReferencedMemory;
645646
#else
646-
#ifdef EDITOR // !MASTER_GOLD && EDITOR
647-
auto minidumpFlags = MiniDumpWithDataSegs;
648-
#else // !MASTER_GOLD && !EDITOR
649-
auto minidumpFlags = MiniDumpWithDataSegs | MiniDumpWithIndirectlyReferencedMemory;
650-
#endif
647+
const auto minidumpFlags = MiniDumpWithDataSegs | MiniDumpWithIndirectlyReferencedMemory;
651648
#endif
649+
652650
BT_SetDumpType(minidumpFlags);
653651
//BT_SetSupportEMail("[email protected]");
654652
BT_SetSupportEMail("[email protected]");
655653
#endif
656654
}
657655
#endif // USE_BUG_TRAP
658656

659-
#ifdef USE_OWN_MINI_DUMP
660-
void xrDebug::SaveMiniDump(EXCEPTION_POINTERS *exPtrs)
661-
{
662-
#if defined(WINDOWS)
663-
string64 dateStr;
664-
timestamp(dateStr);
665-
string_path dumpPath;
666-
xr_sprintf(dumpPath, sizeof(dumpPath), "%s_%s_%s.mdmp", Core.ApplicationName, Core.UserName, dateStr);
667-
__try
668-
{
669-
if (FS.path_exist("$logs$"))
670-
FS.update_path(dumpPath, "$logs$", dumpPath);
671-
}
672-
__except (EXCEPTION_EXECUTE_HANDLER)
673-
{
674-
string_path temp;
675-
xr_strcpy(temp, dumpPath);
676-
xr_sprintf(dumpPath, sizeof(dumpPath), "logs/%s", temp);
677-
}
678-
WriteMiniDump(MINIDUMP_TYPE(MiniDumpFilterMemory | MiniDumpScanMemory), dumpPath, GetCurrentThreadId(), exPtrs);
679-
#endif
680-
}
681-
#endif
682-
683657
void xrDebug::FormatLastError(char* buffer, const size_t& bufferSize)
684658
{
685659
#if defined(WINDOWS)

src/xrCore/xrDebug.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ class XRCORE_API xrDebug
9393
static void SetupExceptionHandler(const bool& dedicated);
9494
static LONG WINAPI UnhandledFilter(EXCEPTION_POINTERS* exPtrs);
9595
static void WINAPI PreErrorHandler(INT_PTR);
96-
static void SaveMiniDump(EXCEPTION_POINTERS* exPtrs);
9796
#if defined(WINDOWS)
9897
static xr_vector<xr_string> BuildStackTrace(PCONTEXT threadCtx, u16 maxFramesCount);
9998
static bool GetNextStackFrameString(LPSTACKFRAME stackFrame, PCONTEXT threadCtx, xr_string& frameStr);

0 commit comments

Comments
 (0)