1// RUN: %clang -O1 %s -o %t
2// RUN: %env_tool_opts=handle_sigfpe=2 not %run %t 0 2>&1 | FileCheck %s -DSIGNAME=FPE
3// RUN: %env_tool_opts=handle_sigill=2 not %run %t 1 2>&1 | FileCheck %s -DSIGNAME=ILL
4// RUN: %env_tool_opts=handle_abort=2 not %run %t 2 2>&1 | FileCheck %s -DSIGNAME=ABRT
5// RUN: %env_tool_opts=handle_segv=2 not %run %t 3 2>&1 | FileCheck %s -DSIGNAME=SEGV
6// RUN: %env_tool_opts=handle_sigbus=2 not %run %t 4 2>&1 | FileCheck %s -DSIGNAME=BUS
7// RUN: %env_tool_opts=handle_sigtrap=2 not %run %t 5 2>&1 | FileCheck %s -DSIGNAME=TRAP
8
9// FIXME: Hwasan misclassify TRAP as tag missmatch.
10// XFAIL: hwasan && !hwasan-aliasing
11
12#include <signal.h>
13#include <stdlib.h>
14
15int main(int argc, char **argv) {
16 if (argc != 2)
17 return 0;
18 int signals[] = {SIGFPE, SIGILL, SIGABRT, SIGSEGV, SIGBUS, SIGTRAP};
19 raise(sig: signals[atoi(nptr: argv[1])]);
20}
21
22// CHECK: Sanitizer:DEADLYSIGNAL
23// CHECK: Sanitizer: [[SIGNAME]] on unknown address
24

source code of compiler-rt/test/sanitizer_common/TestCases/Linux/signal_name.c