summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorpaul <paul>2003-06-04 09:40:54 +0000
committerpaul <paul>2003-06-04 09:40:54 +0000
commitfb2d1502bb0893f2aaccb49fb39521974078d96a (patch)
tree0d3059d875d2be20913eaceaed12c8c09ec2b481 /lib
parent97e34b88b39abdef4ba0581574d315ef7ddb1a86 (diff)
Paul Jakma:
lib/debug.{c,h}: glibc backtrace printing function (from the glibc info page) configure.ac: check for glibc backtrace and set define lib/zebra.h: glibc backtrace support
Diffstat (limited to 'lib')
-rw-r--r--lib/debug.c23
-rw-r--r--lib/debug.h3
-rw-r--r--lib/zebra.h4
3 files changed, 30 insertions, 0 deletions
diff --git a/lib/debug.c b/lib/debug.c
new file mode 100644
index 00000000..c4b67a52
--- /dev/null
+++ b/lib/debug.c
@@ -0,0 +1,23 @@
+#include <zebra.h>
+#include "log.h"
+
+void
+debug_print_trace (int signal)
+{
+ void *array[10];
+ size_t size;
+ char **strings;
+ size_t i;
+
+ size = backtrace (array, 10);
+ strings = backtrace_symbols (array, size);
+
+ printf ("Obtained %zd stack frames.\n", size);
+
+ for (i = 0; i < size; i++)
+ printf ("%s\n", strings[i]);
+
+ free (strings);
+
+ exit(1);
+}
diff --git a/lib/debug.h b/lib/debug.h
new file mode 100644
index 00000000..44409042
--- /dev/null
+++ b/lib/debug.h
@@ -0,0 +1,3 @@
+
+void debug_print_trace (int);
+
diff --git a/lib/zebra.h b/lib/zebra.h
index 7b1e8011..62566cf8 100644
--- a/lib/zebra.h
+++ b/lib/zebra.h
@@ -172,6 +172,10 @@ typedef int socklen_t;
#include <libutil.h>
#endif /* HAVE_LIBUTIL_H */
+#ifdef HAVE_GLIBC_BACKTRACE
+#include <execinfo.h>
+#endif /* HAVE_GLIBC_BACKTRACE */
+
#ifdef BSDI_NRL
#ifdef HAVE_NETINET6_IN6_H