diff options
author | Brian Gaeke <gaeke@uiuc.edu> | 2004-02-20 06:40:59 +0000 |
---|---|---|
committer | Brian Gaeke <gaeke@uiuc.edu> | 2004-02-20 06:40:59 +0000 |
commit | 99983d569e5ade572652f5c4776f9d5fb06bd651 (patch) | |
tree | e1dc398285fa335c98143cd12aa7543b1c6de270 /llvm/lib/Support/Signals.cpp | |
parent | 3056626e7be1f215271e55607d7af736f54a9b7d (diff) | |
download | bcm5719-llvm-99983d569e5ade572652f5c4776f9d5fb06bd651.tar.gz bcm5719-llvm-99983d569e5ade572652f5c4776f9d5fb06bd651.zip |
Use backtrace() and include execinfo.h, if they were detected by autoconf.
llvm-svn: 11658
Diffstat (limited to 'llvm/lib/Support/Signals.cpp')
-rw-r--r-- | llvm/lib/Support/Signals.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/llvm/lib/Support/Signals.cpp b/llvm/lib/Support/Signals.cpp index b3baed06683..978d3b7ccb2 100644 --- a/llvm/lib/Support/Signals.cpp +++ b/llvm/lib/Support/Signals.cpp @@ -17,10 +17,12 @@ #include <algorithm> #include <cstdlib> #include <cstdio> -//#include <execinfo.h> +#include "Config/config.h" // Get the signal handler return type +#ifdef HAVE_EXECINFO_H +# include <execinfo.h> // For backtrace(). +#endif #include <signal.h> #include <unistd.h> -#include "Config/config.h" // Get the signal handler return type using namespace llvm; static std::vector<std::string> FilesToRemove; @@ -54,9 +56,12 @@ static RETSIGTYPE SignalHandler(int Sig) { exit(1); // If this is an interrupt signal, exit the program // Otherwise if it is a fault (like SEGV) output the stacktrace to - // STDERR and reissue the signal to die... - //int depth = backtrace(StackTrace, sizeof(StackTrace)/sizeof(StackTrace[0])); - //backtrace_symbols_fd(StackTrace, depth, STDERR_FILENO); + // STDERR (if we can) and reissue the signal to die... +#ifdef HAVE_BACKTRACE + // Use backtrace() to output a backtrace on Linux systems with glibc. + int depth = backtrace(StackTrace, sizeof(StackTrace)/sizeof(StackTrace[0])); + backtrace_symbols_fd(StackTrace, depth, STDERR_FILENO); +#endif signal(Sig, SIG_DFL); } |