2016-08-04 02:13:14 +08:00
|
|
|
// Test the handle_sigill option.
|
|
|
|
//
|
|
|
|
// RUN: %clangxx_asan %s -o %t && %env_asan_opts=handle_sigill=0 not --crash %run %t 2>&1 | FileCheck %s --check-prefix=CHECK0
|
|
|
|
// RUN: %clangxx_asan %s -o %t && %env_asan_opts=handle_sigill=1 not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK1
|
2016-08-04 07:24:06 +08:00
|
|
|
// REQUIRES: x86-target-arch
|
2016-08-04 02:13:14 +08:00
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
#include <windows.h>
|
|
|
|
#endif
|
|
|
|
|
2016-08-06 05:47:46 +08:00
|
|
|
int main(int argc, char **argv) {
|
2016-08-04 02:13:14 +08:00
|
|
|
#ifdef _WIN32
|
|
|
|
// Sometimes on Windows this test generates a WER fault dialog. Suppress that.
|
|
|
|
UINT new_flags = SEM_FAILCRITICALERRORS |
|
|
|
|
SEM_NOGPFAULTERRORBOX |
|
|
|
|
SEM_NOOPENFILEERRORBOX;
|
|
|
|
// Preserve existing error mode, as discussed at
|
|
|
|
// http://blogs.msdn.com/oldnewthing/archive/2004/07/27/198410.aspx
|
|
|
|
UINT existing_flags = SetErrorMode(new_flags);
|
|
|
|
SetErrorMode(existing_flags | new_flags);
|
|
|
|
#endif
|
|
|
|
|
2016-08-06 05:47:46 +08:00
|
|
|
if (argc)
|
|
|
|
__builtin_trap();
|
|
|
|
// Unreachable code to avoid confusing the Windows unwinder.
|
2016-08-06 08:57:58 +08:00
|
|
|
#ifdef _WIN32
|
2016-08-06 05:47:46 +08:00
|
|
|
SetErrorMode(0);
|
2016-08-06 08:57:58 +08:00
|
|
|
#endif
|
2016-08-04 02:13:14 +08:00
|
|
|
}
|
|
|
|
// CHECK0-NOT: ERROR: AddressSanitizer
|
|
|
|
// CHECK1: ERROR: AddressSanitizer: {{ILL|illegal-instruction}} on unknown address {{0x0*}}
|