[llvm-commits] CVS: llvm/lib/Support/Signals.cpp
Brian Gaeke
gaeke at cs.uiuc.edu
Fri Feb 20 00:49:41 PST 2004
Changes in directory llvm/lib/Support:
Signals.cpp updated: 1.14 -> 1.15
---
Log message:
Use backtrace() and include execinfo.h, if they were detected by autoconf.
---
Diffs of the changes: (+10 -5)
Index: llvm/lib/Support/Signals.cpp
diff -u llvm/lib/Support/Signals.cpp:1.14 llvm/lib/Support/Signals.cpp:1.15
--- llvm/lib/Support/Signals.cpp:1.14 Thu Feb 19 15:21:23 2004
+++ llvm/lib/Support/Signals.cpp Fri Feb 20 00:40:59 2004
@@ -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 @@
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);
}
More information about the llvm-commits
mailing list