summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorajs <ajs>2005-01-17 15:22:28 +0000
committerajs <ajs>2005-01-17 15:22:28 +0000
commit09c64f5153f2450f59a9a42d886c96b4b00ae9f4 (patch)
tree560e082354cf06665f912a5a8cf31e3f2c45b75b /lib
parent6213d09378e706f7625a8a114d554f0b17e66595 (diff)
downloadquagga-09c64f5153f2450f59a9a42d886c96b4b00ae9f4.tar.bz2
quagga-09c64f5153f2450f59a9a42d886c96b4b00ae9f4.tar.xz
2005-01-17 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
* log.h: Change prototype for zlog_backtrace_sigsafe to take additional program_counter argument. * log.c: (zlog_backtrace_sigsafe) Add additional program_counter argument. If it is non-NULL, use backtrace_symbols_fd to resolve the address. (zlog_signal) Call zlog_backtrace_sigsafe with additional program_counter argument. [pullup candidate]
Diffstat (limited to 'lib')
-rw-r--r--lib/ChangeLog10
-rw-r--r--lib/log.c10
-rw-r--r--lib/log.h5
3 files changed, 21 insertions, 4 deletions
diff --git a/lib/ChangeLog b/lib/ChangeLog
index ba4bba97..519467be 100644
--- a/lib/ChangeLog
+++ b/lib/ChangeLog
@@ -1,3 +1,13 @@
+2005-01-17 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
+
+ * log.h: Change prototype for zlog_backtrace_sigsafe to take additional
+ program_counter argument.
+ * log.c: (zlog_backtrace_sigsafe) Add additional program_counter
+ argument. If it is non-NULL, use backtrace_symbols_fd to resolve
+ the address.
+ (zlog_signal) Call zlog_backtrace_sigsafe with additional
+ program_counter argument.
+
2005-01-17 Hasso Tepper <hasso at quagga.net>
* command.[ch], vty.c: cmd_execute_command() function must not attempt
diff --git a/lib/log.c b/lib/log.c
index f9f9766e..0a3a7fc1 100644
--- a/lib/log.c
+++ b/lib/log.c
@@ -312,7 +312,7 @@ zlog_signal(int signo, const char *action, siginfo_t *siginfo,
}
#undef DUMP
- zlog_backtrace_sigsafe(PRI);
+ zlog_backtrace_sigsafe(PRI, program_counter);
#undef PRI
#undef LOC
}
@@ -320,9 +320,10 @@ zlog_signal(int signo, const char *action, siginfo_t *siginfo,
/* Log a backtrace using only async-signal-safe functions.
Needs to be enhanced to support syslog logging. */
void
-zlog_backtrace_sigsafe(int priority)
+zlog_backtrace_sigsafe(int priority, void *program_counter)
{
#ifdef HAVE_GLIBC_BACKTRACE
+ static const char pclabel[] = "Program counter: ";
void *array[20];
int size;
char buf[100];
@@ -338,6 +339,11 @@ zlog_backtrace_sigsafe(int priority)
s = str_append(LOC," stack frames:\n");
#define DUMP(FP) { \
+ if (program_counter) \
+ { \
+ write(fileno(FP),pclabel,sizeof(pclabel)-1); \
+ backtrace_symbols_fd(&program_counter, 1, fileno(FP)); \
+ } \
write(fileno(FP),buf,s-buf); \
backtrace_symbols_fd(array, size, fileno(FP)); \
}
diff --git a/lib/log.h b/lib/log.h
index bcfa0319..5418b1d0 100644
--- a/lib/log.h
+++ b/lib/log.h
@@ -161,8 +161,9 @@ extern void zlog_backtrace(int priority);
/* Log a backtrace, but in an async-signal-safe way. Should not be
called unless the program is about to exit or abort, since it messes
- up the state of zlog file pointers. */
-extern void zlog_backtrace_sigsafe(int priority);
+ up the state of zlog file pointers. If program_counter is non-NULL,
+ that is logged in addition to the current backtrace. */
+extern void zlog_backtrace_sigsafe(int priority, void *program_counter);
/* Defines for use in command construction: */