brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · da457d6 Raw
38 lines · cpp
1// Test the handle_sigill option.2//3// RUN: %clangxx_asan %s -o %t && %env_asan_opts=handle_sigill=0 not --crash %run %t 2>&1 | FileCheck %s --check-prefix=CHECK04// RUN: %clangxx_asan %s -o %t && %env_asan_opts=handle_sigill=1 not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK15// REQUIRES: x86-target-arch && (!MSVC || asan-32-bits)6 7#ifdef _WIN328#include <windows.h>9#endif10 11// note: test is limited to i386 only ("asan-32-bits") when using "real" MSVC12//  see the requires clause above13#if defined(_MSC_VER) && !defined(__clang__)14#  define __builtin_trap() __asm ud2;15#endif16 17int main(int argc, char **argv) {18#ifdef _WIN3219  // Sometimes on Windows this test generates a WER fault dialog. Suppress that.20  UINT new_flags = SEM_FAILCRITICALERRORS |21                   SEM_NOGPFAULTERRORBOX |22                   SEM_NOOPENFILEERRORBOX;23  // Preserve existing error mode, as discussed at24  // http://blogs.msdn.com/oldnewthing/archive/2004/07/27/198410.aspx25  UINT existing_flags = SetErrorMode(new_flags);26  SetErrorMode(existing_flags | new_flags);27#endif28 29  if (argc)30    __builtin_trap();31  // Unreachable code to avoid confusing the Windows unwinder.32#ifdef _WIN3233  SetErrorMode(0);34#endif35}36// CHECK0-NOT: ERROR: AddressSanitizer37// CHECK1: ERROR: AddressSanitizer: {{ILL|illegal-instruction}} on unknown address {{0x0*}}38