diff options
author | Alexandre Ganea <alexandre.ganea@ubisoft.com> | 2020-01-11 15:27:07 -0500 |
---|---|---|
committer | Alexandre Ganea <alexandre.ganea@ubisoft.com> | 2020-01-11 15:27:07 -0500 |
commit | a1f16998f371870ca4da8b3c00a093c607a36ddd (patch) | |
tree | 16c485a7efd204626905f09dfbc073c02740cf12 /llvm/lib/Support/Unix | |
parent | 179abb091d8a1d67115d21b54001d10250756042 (diff) | |
download | bcm5719-llvm-a1f16998f371870ca4da8b3c00a093c607a36ddd.tar.gz bcm5719-llvm-a1f16998f371870ca4da8b3c00a093c607a36ddd.zip |
[Support] Optionally call signal handlers when a function wrapped by the the CrashRecoveryContext fails
This patch allows for handling a failure inside a CrashRecoveryContext in the same way as the global exception/signal handler. A failure will have the same side-effect, such as cleanup of temporarty file, printing callstack, calling relevant signal handlers, and finally returning an exception code. This is an optional feature, disabled by default.
This is a support patch for D69825.
Differential Revision: https://reviews.llvm.org/D70568
Diffstat (limited to 'llvm/lib/Support/Unix')
-rw-r--r-- | llvm/lib/Support/Unix/Signals.inc | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/llvm/lib/Support/Unix/Signals.inc b/llvm/lib/Support/Unix/Signals.inc index 2b31672670c..f68374d29f0 100644 --- a/llvm/lib/Support/Unix/Signals.inc +++ b/llvm/lib/Support/Unix/Signals.inc @@ -345,6 +345,22 @@ static void RemoveFilesToRemove() { FileToRemoveList::removeAllFiles(FilesToRemove); } +void sys::CleanupOnSignal(uintptr_t Context) { + int Sig = (int)Context; + + if (llvm::is_contained(InfoSigs, Sig)) { + InfoSignalHandler(Sig); + return; + } + + RemoveFilesToRemove(); + + if (llvm::is_contained(IntSigs, Sig) || Sig == SIGPIPE) + return; + + llvm::sys::RunSignalHandlers(); +} + // The signal handler that runs. static RETSIGTYPE SignalHandler(int Sig) { // Restore the signal behavior to default, so that the program actually |