[clang][modules] Don't prevent translation of FW_Private includes when explicitly...
[llvm-project.git] / compiler-rt / test / sanitizer_common / TestCases / Linux / signal_trap_handler.cpp
blob51b5d30223cedabc6d6406cc44e1e9f3e620dd0b
1 // RUN: %clangxx -O1 %s -o %t && %env_tool_opts=handle_sigtrap=1 %run %t 2>&1 | FileCheck %s
3 // __builtin_debugtrap() does not raise SIGTRAP on these platforms.
4 // UNSUPPORTED: target=s390{{.*}}
6 #include <assert.h>
7 #include <signal.h>
8 #include <stdio.h>
9 #include <stdlib.h>
11 int in_handler;
13 void handler(int signo, siginfo_t *info, void *uctx) {
14 fprintf(stderr, "in_handler: %d\n", in_handler);
15 fflush(stderr);
16 // CHECK: in_handler: 1
17 _Exit(0);
20 int main() {
21 struct sigaction a = {}, old = {};
22 a.sa_sigaction = handler;
23 a.sa_flags = SA_SIGINFO;
24 sigaction(SIGTRAP, &a, &old);
26 a = {};
27 sigaction(SIGTRAP, 0, &a);
28 assert(a.sa_sigaction == handler);
29 assert(a.sa_flags & SA_SIGINFO);
31 in_handler = 1;
32 // Check that signal handler is not postponed by sanitizer.
33 // Don't use raise here as it calls any signal handler immediately.
34 __builtin_debugtrap();
35 in_handler = 0;
37 fprintf(stderr, "UNREACHABLE\n");
38 return 1;