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
This commit is contained in:
paul 2003-06-04 09:40:54 +00:00
parent 97e34b88b3
commit fb2d1502bb
5 changed files with 54 additions and 0 deletions

View file

@ -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 -------------

View file

@ -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 -------------

23
lib/debug.c Normal file
View file

@ -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);
}

3
lib/debug.h Normal file
View file

@ -0,0 +1,3 @@
void debug_print_trace (int);

View 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