diff options
author | Vitaly Buka <vitalybuka@google.com> | 2019-10-07 22:43:17 +0000 |
---|---|---|
committer | Vitaly Buka <vitalybuka@google.com> | 2019-10-07 22:43:17 +0000 |
commit | 50d8df97befe6f5804b38d1d974f9b3c65282744 (patch) | |
tree | 92ada8a4ba7841f45d642bf1b449cf8f5da5b186 /test | |
parent | 5b3c533a7b7066ffe881b7e9a15b026682e04427 (diff) | |
download | compiler-rt-50d8df97befe6f5804b38d1d974f9b3c65282744.tar.gz |
[tsan] Don't delay SIGTRAP handler
Reviewers: eugenis, jfb
Subscribers: #sanitizers, llvm-commits
Tags: #sanitizers, #llvm
Differential Revision: https://reviews.llvm.org/D68604
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@373978 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r-- | test/sanitizer_common/TestCases/Linux/signal_trap_handler.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/test/sanitizer_common/TestCases/Linux/signal_trap_handler.cpp b/test/sanitizer_common/TestCases/Linux/signal_trap_handler.cpp new file mode 100644 index 000000000..9b4bc067e --- /dev/null +++ b/test/sanitizer_common/TestCases/Linux/signal_trap_handler.cpp @@ -0,0 +1,29 @@ +// RUN: %clangxx -O1 %s -o %t && %env_tool_opts=handle_sigtrap=1 %run %t 2>&1 | FileCheck %s + +#include <assert.h> +#include <signal.h> +#include <stdio.h> + +int handled; + +void handler(int signo, siginfo_t *info, void *uctx) { + handled = 1; +} + +int main() { + struct sigaction a = {}, old = {}; + a.sa_sigaction = handler; + a.sa_flags = SA_SIGINFO; + sigaction(SIGTRAP, &a, &old); + + a = {}; + sigaction(SIGTRAP, 0, &a); + assert(a.sa_sigaction == handler); + assert(a.sa_flags & SA_SIGINFO); + + __builtin_debugtrap(); + assert(handled); + fprintf(stderr, "HANDLED %d\n", handled); +} + +// CHECK: HANDLED 1 |