mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-09-01 10:15:21 +02:00
Share SetupCRT with the unit tests so they can't pop a modal dialog
UnitTest.exe runs on CI and from tooling, where an assert or an abort() puts up a message box that nothing will ever click, and the run just hangs until it is killed. Headless already solved this; move its SetupCRT() into Common (ExceptionHandlerSetup, which is where the rest of the process-level fault setup lives) and call it from the unit tests too. No behaviour change for headless. The OS-level SetErrorMode() call is now guarded for UWP, which doesn't have it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GZq8ZtJmFY7bkX5FVkr3P9
This commit is contained in:
co-authored by
Claude Opus 5
parent
0ac822d7f1
commit
a96dfc1390
@@ -20,9 +20,42 @@
|
||||
#include "Common/MachineContext.h"
|
||||
#include "Common/ExceptionHandlerSetup.h"
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#include <crtdbg.h>
|
||||
#include "Common/CommonWindows.h"
|
||||
#endif
|
||||
|
||||
static BadAccessHandler g_badAccessHandler;
|
||||
static void *altStack = nullptr;
|
||||
|
||||
void SetupCRT(bool suppressDialogs) {
|
||||
#if defined(_MSC_VER)
|
||||
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
|
||||
|
||||
if (suppressDialogs) {
|
||||
// 1. Redirect CRT assertions/errors/warnings to stderr.
|
||||
const _HFILE reportTarget = _CRTDBG_FILE_STDERR;
|
||||
|
||||
_CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE);
|
||||
_CrtSetReportFile(_CRT_ASSERT, reportTarget);
|
||||
|
||||
_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE);
|
||||
_CrtSetReportFile(_CRT_ERROR, reportTarget);
|
||||
|
||||
_CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
|
||||
_CrtSetReportFile(_CRT_WARN, reportTarget);
|
||||
|
||||
// 2. Suppress the abort() message box & crash reporting dialogs.
|
||||
_set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT);
|
||||
|
||||
#if !PPSSPP_PLATFORM(UWP)
|
||||
// 3. Suppress Windows OS-level "Program has stopped working" modal dialogs.
|
||||
SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef MACHINE_CONTEXT_SUPPORTED
|
||||
|
||||
// We cannot handle exceptions in UWP builds. Bleh.
|
||||
|
||||
Reference in New Issue
Block a user