[llvm-commits] [llvm] r82537 - in /llvm/trunk: lib/System/Win32/Signals.inc utils/lit/TestingConfig.py
Daniel Dunbar
daniel at zuster.org
Tue Sep 22 02:50:30 PDT 2009
Author: ddunbar
Date: Tue Sep 22 04:50:28 2009
New Revision: 82537
URL: http://llvm.org/viewvc/llvm-project?rev=82537&view=rev
Log:
Add a magic LLVM_DISABLE_CRT_DEBUG environment variable which we check in RegisterHandler and use to disable the Win32 crash dialogs. These are a major blocker to any kind of automated testing.
Also, tweak the 'lit' test runner to set this variable unconditionally.
Modified:
llvm/trunk/lib/System/Win32/Signals.inc
llvm/trunk/utils/lit/TestingConfig.py
Modified: llvm/trunk/lib/System/Win32/Signals.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Win32/Signals.inc?rev=82537&r1=82536&r2=82537&view=diff
==============================================================================
--- llvm/trunk/lib/System/Win32/Signals.inc (original)
+++ llvm/trunk/lib/System/Win32/Signals.inc Tue Sep 22 04:50:28 2009
@@ -43,6 +43,7 @@
static std::vector<std::pair<void(*)(void*), void*> > *CallBacksToRun = 0;
static bool RegisteredUnhandledExceptionFilter = false;
static bool CleanupExecuted = false;
+static bool ExitOnUnhandledExceptions = false;
static PTOP_LEVEL_EXCEPTION_FILTER OldFilter = NULL;
// Windows creates a new thread to execute the console handler when an event
@@ -57,8 +58,36 @@
//=== and must not be UNIX code
//===----------------------------------------------------------------------===//
+/// CRTReportHook - Function called on a CRT debugging event.
+static int CRTReportHook(int ReportType, char *Message, int *Return) {
+ // Don't cause a DebugBreak() on return.
+ if (Return)
+ *Return = 0;
+
+ switch (ReportType) {
+ default:
+ case _CRT_ASSERT:
+ fprintf(stderr, "CRT assert: %s\n", Message);
+ // FIXME: Is there a way to just crash? Perhaps throw to the unhandled
+ // exception code? Perhaps SetErrorMode() handles this.
+ _exit(3);
+ break;
+ case _CRT_ERROR:
+ fprintf(stderr, "CRT error: %s\n", Message);
+ // FIXME: Is there a way to just crash? Perhaps throw to the unhandled
+ // exception code? Perhaps SetErrorMode() handles this.
+ _exit(3);
+ break;
+ case _CRT_WARN:
+ fprintf(stderr, "CRT warn: %s\n", Message);
+ break;
+ }
+
+ // Don't call _CrtDbgReport.
+ return TRUE;
+}
-static void RegisterHandler() {
+static void RegisterHandler() {
if (RegisteredUnhandledExceptionFilter) {
EnterCriticalSection(&CriticalSection);
return;
@@ -76,6 +105,12 @@
OldFilter = SetUnhandledExceptionFilter(LLVMUnhandledExceptionFilter);
SetConsoleCtrlHandler(LLVMConsoleCtrlHandler, TRUE);
+ // Environment variable to disable any kind of crash dialog.
+ if (getenv("LLVM_DISABLE_CRT_DEBUG")) {
+ _CrtSetReportHook(CRTReportHook);
+ ExitOnUnhandledExceptions = true;
+ }
+
// IMPORTANT NOTE: Caller must call LeaveCriticalSection(&CriticalSection) or
// else multi-threading problems will ensue.
}
@@ -235,6 +270,9 @@
assert(0 && "Crashed in LLVMUnhandledExceptionFilter");
}
+ if (ExitOnUnhandledExceptions)
+ _exit(-3);
+
// Allow dialog box to pop up allowing choice to start debugger.
if (OldFilter)
return (*OldFilter)(ep);
Modified: llvm/trunk/utils/lit/TestingConfig.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/TestingConfig.py?rev=82537&r1=82536&r2=82537&view=diff
==============================================================================
--- llvm/trunk/utils/lit/TestingConfig.py (original)
+++ llvm/trunk/utils/lit/TestingConfig.py Tue Sep 22 04:50:28 2009
@@ -13,6 +13,7 @@
'PATH' : os.pathsep.join(litConfig.path +
[os.environ.get('PATH','')]),
'SYSTEMROOT' : os.environ.get('SYSTEMROOT',''),
+ 'LLVM_DISABLE_CRT_DEBUG' : '1',
}
config = TestingConfig(parent,
More information about the llvm-commits
mailing list