]> git.puffer.fish Git - mirror/frr.git/commitdiff
[lib] Add support for Sun libc printstack to zlog_backtrace_sigsafe
authorPaul Jakma <paul.jakma@sun.com>
Sun, 28 May 2006 08:26:15 +0000 (08:26 +0000)
committerPaul Jakma <paul.jakma@sun.com>
Sun, 28 May 2006 08:26:15 +0000 (08:26 +0000)
2006-05-28 Paul Jakma <paul.jakma@sun.com>

* configure.ac:
  Check for Sun libc printstack(), add a general HAVE_STACK_TRACE
  define for lib/log.c, if any supported stack symbol dumping
  function is found (glibc backtrace/sun libc printstack).
* log.c: (general) Add support for Sun libc printstack().
  (hex_append) make the cpp conditional on general HAVE_STACK_TRACE
  define.
  (zlog_backtrace_sigsafe) Ditto. Add printstack() version of the
  the DUMP macro in this function.

ChangeLog
configure.ac
lib/ChangeLog
lib/log.c

index f36e31e2cf10dd84460448fd9cf13a733f068c73..efe392d17c7571e25b71a021c77af01bd44bad3d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,9 @@
          enable debug options.
          Add a check for GNU Make and warn the user if it does not appear
          to be the make used.
+         Check for Sun libc printstack(), add a general HAVE_STACK_TRACE
+         define for lib/log.c, if any supported stack symbol dumping
+         function is found (glibc backtrace/sun libc printstack).
 
 2006-05-10 Paul Jakma <paul.jakma@sun.com>
 
index e173fcaeab3d7ec9bb66ed01ad6fa59dda099162..37df36e5d911dceeca14f2cac7f7c467266b9085 100755 (executable)
@@ -392,11 +392,15 @@ case "$host" in
   | [*-solaris2.1[0-9]] \
   | [*-solaris2.1[0-9].[0-9]])
       opsys=sol8
-      AC_DEFINE(SUNOS_59,,SunOS 5.8 up)
-      AC_DEFINE(SUNOS_5, 1, SunOS 5)
+      AC_DEFINE(SUNOS_59, 1, [SunOS 5.8 up])
+      AC_DEFINE(SUNOS_5, 1, [SunOS 5])
       AC_CHECK_LIB(socket, main)
       AC_CHECK_LIB(nsl, main)
       AC_CHECK_LIB(umem, main)
+      AC_CHECK_FUNCS([printstack],
+       [AC_DEFINE([HAVE_PRINTSTACK],1,[Solaris printstack])
+        AC_DEFINE([HAVE_STACK_TRACE],1,[Stack symbols decode functionality])
+       ])
       CURSES=-lcurses
   ;;
   *-sunos5* | *-solaris2*)
@@ -1244,12 +1248,12 @@ 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)]
-  )
+   AC_CHECK_HEADER([execinfo.h],
+    [AC_CHECK_FUNC([backtrace],
+       [AC_DEFINE(HAVE_GLIBC_BACKTRACE,,[Glibc backtrace])
+        AC_DEFINE(HAVE_STACK_TRACE,,[Stack symbol decoding])
+       ])
+    ])
 fi
 
 dnl -----------------------------------------
index 90ddd07e0fa7da77728b5523d2a3233d0d26e50d..5d096364e058e87e1ece7b0ae4840383875ddb9c 100644 (file)
@@ -7,6 +7,11 @@
          we still need it on GNU Libc for mallinfo().
        * vty.c: (vty_log/vty_log_fixed) dont crash if called when vty
          hasn't been initiliased.
+       * log.c: (general) Add support for Sun libc printstack().
+         (hex_append) make the cpp conditional on general HAVE_STACK_TRACE
+         define.
+         (zlog_backtrace_sigsafe) Ditto. Add printstack() version of the
+         the DUMP macro in this function.
 
 2006-05-21 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
 
index d55ffb7feb761859d75452711bade9ad80493da1..3eb0bd523dbe363644f4bc08ca70e10ffc3acb03 100644 (file)
--- a/lib/log.c
+++ b/lib/log.c
@@ -1,5 +1,5 @@
 /*
- * $Id: log.c,v 1.27 2006/05/15 16:56:51 paul Exp $
+ * $Id$
  *
  * Logging of zebra
  * Copyright (C) 1997, 1998, 1999 Kunihiro Ishiguro
@@ -179,7 +179,7 @@ num_append(char *s, int len, u_long x)
   return str_append(s,len,t);
 }
 
-#if defined(SA_SIGINFO) || defined(HAVE_GLIBC_BACKTRACE)
+#if defined(SA_SIGINFO) || defined(HAVE_STACK_TRACE)
 static char *
 hex_append(char *s, int len, u_long x)
 {
@@ -371,7 +371,7 @@ zlog_signal(int signo, const char *action
 void
 zlog_backtrace_sigsafe(int priority, void *program_counter)
 {
-#ifdef HAVE_GLIBC_BACKTRACE
+#ifdef HAVE_STACK_TRACE
   static const char pclabel[] = "Program counter: ";
   void *array[20];
   int size;
@@ -379,13 +379,10 @@ zlog_backtrace_sigsafe(int priority, void *program_counter)
   char *s;
 #define LOC s,buf+sizeof(buf)-s
 
+#ifdef HAVE_GLIBC_BACKTRACE
   if (((size = backtrace(array,sizeof(array)/sizeof(array[0]))) <= 0) ||
       ((size_t)size > sizeof(array)/sizeof(array[0])))
     return;
-  s = buf;
-  s = str_append(LOC,"Backtrace for ");
-  s = num_append(LOC,size);
-  s = str_append(LOC," stack frames:\n");
 
 #define DUMP(FD) { \
   if (program_counter) \
@@ -396,6 +393,19 @@ zlog_backtrace_sigsafe(int priority, void *program_counter)
   write(FD, buf, s-buf);       \
   backtrace_symbols_fd(array, size, FD); \
 }
+#elif defined(HAVE_PRINTSTACK)
+#define DUMP(FD) { \
+  if (program_counter) \
+    write((FD), pclabel, sizeof(pclabel)-1); \
+  write((FD), buf, s-buf); \
+  printstack((FD)); \
+}
+#endif /* HAVE_GLIBC_BACKTRACE, HAVE_PRINTSTACK */
+
+  s = buf;
+  s = str_append(LOC,"Backtrace for ");
+  s = num_append(LOC,size);
+  s = str_append(LOC," stack frames:\n");
 
   if ((logfile_fd >= 0) || ((logfile_fd = open_crashlog()) >= 0))
     DUMP(logfile_fd)
@@ -431,7 +441,7 @@ zlog_backtrace_sigsafe(int priority, void *program_counter)
     }
 #undef DUMP
 #undef LOC
-#endif /* HAVE_GLIBC_BACKTRACE */
+#endif /* HAVE_STRACK_TRACE */
 }
 
 void