]> granicus.if.org Git - strace/commitdiff
When reporting signals, use short signal names (SIGfoo) instead of strerror
authorDenys Vlasenko <vda.linux@googlemail.com>
Thu, 15 Mar 2012 16:24:49 +0000 (17:24 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Thu, 15 Mar 2012 16:24:49 +0000 (17:24 +0100)
* 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 <vda.linux@googlemail.com>
defs.h
signal.c
strace.c

diff --git a/defs.h b/defs.h
index 10b306d1401a6c92f3c38a7f3f483d5a9498fb8b..b09b40fbb7dd2fa2d17ee71e13a43ad27421aac9 100644 (file)
--- 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...
index 97c8d1d14111f93720c9d8a3589a07a3dc1cc145..bffdec042abfbf0b4d7deaa32723d1b3e9e55ae5 100644 (file)
--- 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
index 22962a64eca5ae6f620ebe40148fa187960d236d..dda340465a7b415909edb650086be62b03404f8d 100644 (file)
--- 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();