]> git.puffer.fish Git - matthieu/frr.git/commitdiff
Paul Jakma:
authorpaul <paul>
Wed, 4 Jun 2003 09:40:54 +0000 (09:40 +0000)
committerpaul <paul>
Wed, 4 Jun 2003 09:40:54 +0000 (09:40 +0000)
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

configure.ac
configure.in
lib/debug.c [new file with mode: 0644]
lib/debug.h [new file with mode: 0644]
lib/zebra.h

index 4c30bceec43b2cc42f69ca25929dae75880bd41d..be371fcbe6cb07c615d35471ee557c6313919477 100755 (executable)
@@ -856,6 +856,18 @@ AC_TRY_COMPILE([#include <sys/resource.h>
  AC_DEFINE(HAVE_RUSAGE,,rusage)],
  AC_MSG_RESULT(no))
 
+dnl ---------------------------
+dnl check for glibc 'backtrace'
+dnl --------------------------- 
+if test "${glibc}" = "yes"; then
+   AC_CHECK_HEADER(execinfo.h)
+fi
+if test x"${ac_cv_header_execinfo_h}" = x"yes"; then
+  AC_CHECK_FUNC(backtrace,
+    [AC_DEFINE(HAVE_GLIBC_BACKTRACE,,Glibc backtrace)]
+  )
+fi
+
 dnl -------------
 dnl check version
 dnl -------------
index 4c30bceec43b2cc42f69ca25929dae75880bd41d..be371fcbe6cb07c615d35471ee557c6313919477 100755 (executable)
@@ -856,6 +856,18 @@ AC_TRY_COMPILE([#include <sys/resource.h>
  AC_DEFINE(HAVE_RUSAGE,,rusage)],
  AC_MSG_RESULT(no))
 
+dnl ---------------------------
+dnl check for glibc 'backtrace'
+dnl --------------------------- 
+if test "${glibc}" = "yes"; then
+   AC_CHECK_HEADER(execinfo.h)
+fi
+if test x"${ac_cv_header_execinfo_h}" = x"yes"; then
+  AC_CHECK_FUNC(backtrace,
+    [AC_DEFINE(HAVE_GLIBC_BACKTRACE,,Glibc backtrace)]
+  )
+fi
+
 dnl -------------
 dnl check version
 dnl -------------
diff --git a/lib/debug.c b/lib/debug.c
new file mode 100644 (file)
index 0000000..c4b67a5
--- /dev/null
@@ -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 (file)
index 0000000..4440904
--- /dev/null
@@ -0,0 +1,3 @@
+
+void debug_print_trace (int);
+
index 7b1e8011c70adb2061d7a542fa53c61d6bd7a967..62566cf86c4a3c5d5bdff531825bf0dc61a1bea1 100644 (file)
@@ -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