diff options
author | Marcos Pividori <mpividori@google.com> | 2016-12-13 17:45:20 +0000 |
---|---|---|
committer | Marcos Pividori <mpividori@google.com> | 2016-12-13 17:45:20 +0000 |
commit | c59b692c85e0b75ffb3168c2dbec2a0280886c9b (patch) | |
tree | cec0e0d25a453d4860ebc832fdc9f7e8f80e4389 /llvm/lib/Fuzzer/FuzzerUtilPosix.cpp | |
parent | 3462cac9afb58c5355f47ecfc8ce1c5dcae85a0a (diff) | |
download | bcm5719-llvm-c59b692c85e0b75ffb3168c2dbec2a0280886c9b.tar.gz bcm5719-llvm-c59b692c85e0b75ffb3168c2dbec2a0280886c9b.zip |
[libFuzzer] Improve Signal Handler interface.
Add new flags to FuzzingOptions to represent the different conditions
on the signal handling. These options are passed when calling
SetSignalHandler().
This changes simplify the implementation of Windows's exception
handling. Now we can define a unique handler for all the exceptions.
Differential Revision: https://reviews.llvm.org/D27238
llvm-svn: 289557
Diffstat (limited to 'llvm/lib/Fuzzer/FuzzerUtilPosix.cpp')
-rw-r--r-- | llvm/lib/Fuzzer/FuzzerUtilPosix.cpp | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/llvm/lib/Fuzzer/FuzzerUtilPosix.cpp b/llvm/lib/Fuzzer/FuzzerUtilPosix.cpp index ad1e3044477..abb2680abb0 100644 --- a/llvm/lib/Fuzzer/FuzzerUtilPosix.cpp +++ b/llvm/lib/Fuzzer/FuzzerUtilPosix.cpp @@ -64,13 +64,24 @@ void SetTimer(int Seconds) { SetSigaction(SIGALRM, AlarmHandler); } -void SetSigSegvHandler() { SetSigaction(SIGSEGV, CrashHandler); } -void SetSigBusHandler() { SetSigaction(SIGBUS, CrashHandler); } -void SetSigAbrtHandler() { SetSigaction(SIGABRT, CrashHandler); } -void SetSigIllHandler() { SetSigaction(SIGILL, CrashHandler); } -void SetSigFpeHandler() { SetSigaction(SIGFPE, CrashHandler); } -void SetSigIntHandler() { SetSigaction(SIGINT, InterruptHandler); } -void SetSigTermHandler() { SetSigaction(SIGTERM, InterruptHandler); } +void SetSignalHandler(const FuzzingOptions& Options) { + if (Options.UnitTimeoutSec > 0) + SetTimer(Options.UnitTimeoutSec / 2 + 1); + if (Options.HandleInt) + SetSigaction(SIGINT, InterruptHandler); + if (Options.HandleTerm) + SetSigaction(SIGTERM, InterruptHandler); + if (Options.HandleSegv) + SetSigaction(SIGSEGV, CrashHandler); + if (Options.HandleBus) + SetSigaction(SIGBUS, CrashHandler); + if (Options.HandleAbrt) + SetSigaction(SIGABRT, CrashHandler); + if (Options.HandleIll) + SetSigaction(SIGILL, CrashHandler); + if (Options.HandleFpe) + SetSigaction(SIGFPE, CrashHandler); +} void SleepSeconds(int Seconds) { sleep(Seconds); // Use C API to avoid coverage from instrumented libc++. |