aboutsummaryrefslogtreecommitdiffstats
path: root/lib/System/Unix
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2006-06-16 00:00:57 +0000
committerReid Spencer <rspencer@reidspencer.com>2006-06-16 00:00:57 +0000
commitdc6830ff255a4fb9afd7683dd8a4cc0a342b44ee (patch)
treec3e54fb39370764cc8a632bb61341891a9e3898a /lib/System/Unix
parent44500e3d538a250d8591e708b62741cde0bdc249 (diff)
downloadexternal_llvm-dc6830ff255a4fb9afd7683dd8a4cc0a342b44ee.zip
external_llvm-dc6830ff255a4fb9afd7683dd8a4cc0a342b44ee.tar.gz
external_llvm-dc6830ff255a4fb9afd7683dd8a4cc0a342b44ee.tar.bz2
Only print the stack trace if it was requested. Previously, any call into
the Signals module that registered the handlers would cause the stack trace to be generated. Now, you must explicitly call PrintStackTraceOnErrorSignal in order for that to happen. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28810 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/System/Unix')
-rw-r--r--lib/System/Unix/Signals.inc6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/System/Unix/Signals.inc b/lib/System/Unix/Signals.inc
index a643dbf..4096ad2 100644
--- a/lib/System/Unix/Signals.inc
+++ b/lib/System/Unix/Signals.inc
@@ -24,6 +24,8 @@
namespace {
+bool StackTraceRequested = false;
+
/// InterruptFunction - The function to call if ctrl-c is pressed.
void (*InterruptFunction)() = 0;
@@ -132,7 +134,8 @@ RETSIGTYPE SignalHandler(int Sig) {
// Otherwise if it is a fault (like SEGV) output the stacktrace to
// STDERR (if we can) and reissue the signal to die...
- PrintStackTrace();
+ if (StackTraceRequested)
+ PrintStackTrace();
signal(Sig, SIG_DFL);
}
@@ -178,6 +181,7 @@ void sys::RemoveDirectoryOnSignal(const llvm::sys::Path& path) {
/// PrintStackTraceOnErrorSignal - When an error signal (such as SIBABRT or
/// SIGSEGV) is delivered to the process, print a stack trace and then exit.
void sys::PrintStackTraceOnErrorSignal() {
+ StackTraceRequested = true;
std::for_each(KillSigs, KillSigsEnd, RegisterHandler);
}