From: Denys Vlasenko Date: Thu, 15 Mar 2012 16:24:49 +0000 (+0100) Subject: When reporting signals, use short signal names (SIGfoo) instead of strerror X-Git-Tag: v4.7~93 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2c4fb905fef268a7e359ce3acaec4ee7ef087996;p=strace When reporting signals, use short signal names (SIGfoo) instead of strerror * defs.h: Remove strsignal declaration. * signal.c: Better check for SI_FROMUSER define. * strace.c (strerror): Remove this function. (trace): Use short signal names (SIGfoo) instead of strerror. Signed-off-by: Denys Vlasenko --- diff --git a/defs.h b/defs.h index 10b306d1..b09b40fb 100644 --- a/defs.h +++ b/defs.h @@ -63,9 +63,6 @@ #ifndef HAVE_STRERROR const char *strerror(int); #endif -#ifndef HAVE_STRSIGNAL -const char *strsignal(int); -#endif #ifndef HAVE_STPCPY /* Some libc have stpcpy, some don't. Sigh... * Roll our private implementation... diff --git a/signal.c b/signal.c index 97c8d1d1..bffdec04 100644 --- a/signal.c +++ b/signal.c @@ -418,8 +418,10 @@ print_sigset(struct tcb *tcp, long addr, int rt) #define SI_TKILL -6 /* sent by tkill */ #define SI_ASYNCNL -60 /* sent by asynch name lookup completion */ -#define SI_FROMUSER(sip) ((sip)->si_code <= 0) +#endif +#ifndef SI_FROMUSER +# define SI_FROMUSER(sip) ((sip)->si_code <= 0) #endif #if __GLIBC_MINOR__ < 1 diff --git a/strace.c b/strace.c index 22962a64..dda34046 100644 --- a/strace.c +++ b/strace.c @@ -158,6 +158,27 @@ static volatile sig_atomic_t interrupted; static volatile int interrupted; #endif +#ifndef HAVE_STRERROR + +#if !HAVE_DECL_SYS_ERRLIST +extern int sys_nerr; +extern char *sys_errlist[]; +#endif /* HAVE_DECL_SYS_ERRLIST */ + +const char * +strerror(int err_no) +{ + static char buf[sizeof("Unknown error %d") + sizeof(int)*3]; + + if (err_no < 1 || err_no >= sys_nerr) { + sprintf(buf, "Unknown error %d", err_no); + return buf; + } + return sys_errlist[err_no]; +} + +#endif /* HAVE_STERRROR */ + static void usage(FILE *ofp, int exitval) { @@ -1737,54 +1758,6 @@ interrupt(int sig) interrupted = sig; } -#ifndef HAVE_STRERROR - -#if !HAVE_DECL_SYS_ERRLIST -extern int sys_nerr; -extern char *sys_errlist[]; -#endif /* HAVE_DECL_SYS_ERRLIST */ - -const char * -strerror(int err_no) -{ - static char buf[sizeof("Unknown error %d") + sizeof(int)*3]; - - if (err_no < 1 || err_no >= sys_nerr) { - sprintf(buf, "Unknown error %d", err_no); - return buf; - } - return sys_errlist[err_no]; -} - -#endif /* HAVE_STERRROR */ - -#ifndef HAVE_STRSIGNAL - -#if defined HAVE_SYS_SIGLIST && !defined HAVE_DECL_SYS_SIGLIST -extern char *sys_siglist[]; -#endif -#if defined HAVE_SYS__SIGLIST && !defined HAVE_DECL__SYS_SIGLIST -extern char *_sys_siglist[]; -#endif - -const char * -strsignal(int sig) -{ - static char buf[sizeof("Unknown signal %d") + sizeof(int)*3]; - - if (sig < 1 || sig >= NSIG) { - sprintf(buf, "Unknown signal %d", sig); - return buf; - } -#ifdef HAVE__SYS_SIGLIST - return _sys_siglist[sig]; -#else - return sys_siglist[sig]; -#endif -} - -#endif /* HAVE_STRSIGNAL */ - static int trace(void) { @@ -2125,14 +2098,12 @@ trace(void) #endif printleader(tcp); if (!stopped) { - tprints("--- "); + tprintf("--- %s ", signame(sig)); printsiginfo(&si, verbose(tcp)); - tprintf(" (%s)" PC_FORMAT_STR " ---\n", - strsignal(sig) + tprintf(PC_FORMAT_STR " ---\n" PC_FORMAT_ARG); } else - tprintf("--- %s by %s" PC_FORMAT_STR " ---\n", - strsignal(sig), + tprintf("--- stopped by %s" PC_FORMAT_STR " ---\n", signame(sig) PC_FORMAT_ARG); line_ended();