From 52d2cc927cf4138541a02776b41686ef84066c3d Mon Sep 17 00:00:00 2001 From: ajs Date: Wed, 12 Jan 2005 17:27:27 +0000 Subject: 2005-01-12 Andrew J. Schorr * configure.ac: Test for header file (for use in signal processing). * sigevent.c: (trap_default_signals) Use the SA_SIGINFO flag to pass additional siginfo_t and ucontext_t arguments to core_handler and exit_handler. (core_handler,exit_handler) Now invoked with 3 arguments (using SA_SIGINFO). Pass additional info to zlog_signal. (program_counter) New function to find program counter in ucontext_t, needs to be enhanced to support more platforms (currently works only on Linux/x86). * log.h: Change the zlog_signal prototype to add new arguments siginfo_t * and program_counter. * log.c: (zlog_signal) Add new arguments siginfo and program_counter. Include si_addr and program counter (if non-NULL) in message. And remove #ifdef HAVE_GLIBC_BACKTRACE around hex_append, since that is now used to render the si_addr and PC pointers. --- lib/log.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'lib/log.c') diff --git a/lib/log.c b/lib/log.c index 9c1cbdcb..f9f9766e 100644 --- a/lib/log.c +++ b/lib/log.c @@ -177,10 +177,6 @@ num_append(char *s, int len, u_long x) return str_append(s,len,t); } -#ifdef HAVE_GLIBC_BACKTRACE - -/* This function is used only in zlog_backtrace_sigsafe when glibc - backtraces are available. */ static char * hex_append(char *s, int len, u_long x) { @@ -199,8 +195,6 @@ hex_append(char *s, int len, u_long x) return str_append(s,len,t); } -#endif /* HAVE_GLIBC_BACKTRACE */ - static int syslog_fd = -1; /* Needs to be enhanced to support Solaris. */ @@ -264,10 +258,11 @@ syslog_sigsafe(int priority, const char *msg, size_t msglen) /* Note: the goal here is to use only async-signal-safe functions. */ void -zlog_signal(int signo, const char *action) +zlog_signal(int signo, const char *action, siginfo_t *siginfo, + void *program_counter) { time_t now; - char buf[sizeof("DEFAULT: Received signal S at T; aborting...")+60]; + char buf[sizeof("DEFAULT: Received signal S at T (si_addr 0xP, PC 0xP); aborting...")+100]; char *s = buf; char *msgstart = buf; #define LOC s,buf+sizeof(buf)-s @@ -284,7 +279,14 @@ zlog_signal(int signo, const char *action) s = num_append(LOC,signo); s = str_append(LOC," at "); s = num_append(LOC,now); - s = str_append(LOC,"; "); + s = str_append(LOC," (si_addr 0x"); + s = hex_append(LOC,(u_long)(siginfo->si_addr)); + if (program_counter) + { + s = str_append(LOC,", PC 0x"); + s = hex_append(LOC,(u_long)program_counter); + } + s = str_append(LOC,"); "); s = str_append(LOC,action); if (s < buf+sizeof(buf)) *s++ = '\n'; -- cgit v1.2.3