[llvm-commits] [PATCH] Program to aid in automated testing on windows.
Óscar Fuentes
ofv at wanadoo.es
Tue Sep 21 12:37:12 PDT 2010
Michael Spencer <bigcheesegs at gmail.com>
writes:
> While porting test-suite over to lit so I could run it on Windows I
> ran into severe issues due to Dr. Watson and the C runtime.
[snip]
For solving the same problem on my compiler I use something like the
chunk of code below. It works fine on Windows XP, although in one case
it still pops the dialog on Vista/7. I didn't investigate the issue but
it is probably a missing _CrtSetReportMode call. Maybe it is worth a try
before adding yet another utility.
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#if defined(_MSC_VER) && ! defined(NDEBUG)
# include <crtdbg.h>
#endif
#if defined(_WIN32)
# include <windows.h>
#endif
void InstallSignalHandlers();
#define SIGNAL_ARGS int sig
void sig_abrt_catcher(SIGNAL_ARGS);
void sig_ill_catcher(SIGNAL_ARGS);
void sig_fpr_catcher(SIGNAL_ARGS);
void sig_segv_catcher(SIGNAL_ARGS);
int main() {
/* ... */
InstallSignalHandlers();
/* ... */
}
void InstallSignalHandlers() {
signal(SIGFPE, &sig_abrt_catcher);
signal(SIGFPE, &sig_ill_catcher);
signal(SIGFPE, &sig_fpr_catcher);
signal(SIGSEGV, &sig_segv_catcher);
#if defined(_MSC_VER) && ! defined(NDEBUG)
_CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE);
_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE);
_CrtSetReportHook(&MsvcrtReportHook);
_set_error_mode(_OUT_TO_STDERR);
#endif // #if defined(_MSC_VER) && ! defined(NDEBUG)
#if defined(_WIN32)
SetUnhandledExceptionFilter(&UnhandledWin32Exception);
#endif
}
void sig_abrt_catcher(SIGNAL_ARGS) {
puts("SIGABRT\n");
exit(3);
}
void sig_ill_catcher(SIGNAL_ARGS) {
puts("SIGILL\n");
exit(3);
}
void sig_fpr_catcher(SIGNAL_ARGS) {
puts("SIGFPR\n");
exit(3);
}
void sig_segv_catcher(SIGNAL_ARGS) {
puts("SIGSEGV\n");
exit(3);
}
More information about the llvm-commits
mailing list