summaryrefslogtreecommitdiff
path: root/lib/log.c
diff options
context:
space:
mode:
authorajs <ajs>2005-01-17 15:22:28 +0000
committerajs <ajs>2005-01-17 15:22:28 +0000
commit239c26fdeae4dbccb43da359f9ea034041440831 (patch)
treeaefdb215d2e9ad88afe04d105c07cb9d8550bf96 /lib/log.c
parentf127165de02a66934082f23810fab37d7efbce8b (diff)
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/log.c')
-rw-r--r--lib/log.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/log.c b/lib/log.c
index fcf7c5d5..a639745d 100644
--- a/lib/log.c
+++ b/lib/log.c
@@ -1,5 +1,5 @@
/*
- * $Id: log.c,v 1.21 2005/01/12 17:27:27 ajs Exp $
+ * $Id: log.c,v 1.22 2005/01/17 15:22:28 ajs Exp $
*
* Logging of zebra
* Copyright (C) 1997, 1998, 1999 Kunihiro Ishiguro
@@ -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)); \
}