* tests/tests.h (signal2name): New prototype.
* tests/signal2name.c: New file.
* tests/Makefile.am (libtests_a_SOURCES): Add it.
---
 tests/Makefile.am   |  1 +
 tests/signal2name.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/tests.h       |  3 +++
 3 files changed, 59 insertions(+)
 create mode 100644 tests/signal2name.c

diff --git a/tests/Makefile.am b/tests/Makefile.am
index 7a029b6..a136e2a 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -51,6 +51,7 @@ libtests_a_SOURCES = \
        print_quoted_string.c \
        printflags.c \
        printxval.c \
+       signal2name.c \
        tail_alloc.c \
        tests.h \
        tprintf.c \
diff --git a/tests/signal2name.c b/tests/signal2name.c
new file mode 100644
index 0000000..e301f4e
--- /dev/null
+++ b/tests/signal2name.c
@@ -0,0 +1,55 @@
+#include "tests.h"
+#include <signal.h>
+
+#define CASE(x) case x: return #x
+
+const char *
+signal2name(int sig)
+{
+       switch (sig) {
+       CASE(SIGALRM);
+       CASE(SIGBUS);
+       CASE(SIGCHLD);
+       CASE(SIGCONT);
+       CASE(SIGFPE);
+       CASE(SIGHUP);
+       CASE(SIGILL);
+       CASE(SIGINT);
+       CASE(SIGIO);
+       CASE(SIGPIPE);
+       CASE(SIGPROF);
+       CASE(SIGQUIT);
+       CASE(SIGSEGV);
+       CASE(SIGSYS);
+       CASE(SIGTERM);
+       CASE(SIGTRAP);
+       CASE(SIGTSTP);
+       CASE(SIGTTIN);
+       CASE(SIGTTOU);
+       CASE(SIGURG);
+       CASE(SIGUSR1);
+       CASE(SIGUSR2);
+       CASE(SIGVTALRM);
+       CASE(SIGWINCH);
+       CASE(SIGXCPU);
+       CASE(SIGXFSZ);
+#if defined ALPHA
+       CASE(SIGABRT);
+       CASE(SIGEMT);
+       CASE(SIGINFO);
+#elif defined SPARC || defined SPARC64
+       CASE(SIGABRT);
+       CASE(SIGEMT);
+       CASE(SIGLOST);
+#elif defined MIPS
+       CASE(SIGEMT);
+       CASE(SIGIOT);
+       CASE(SIGPWR);
+#else
+       CASE(SIGABRT);
+       CASE(SIGPWR);
+       CASE(SIGSTKFLT);
+#endif
+       default: perror_msg_and_fail("unknown signal number %d", sig);
+       }
+}
diff --git a/tests/tests.h b/tests/tests.h
index 9f556ae..02d588e 100644
--- a/tests/tests.h
+++ b/tests/tests.h
@@ -93,6 +93,9 @@ void check_overflowgid(const int);
 /* Translate errno to its name. */
 const char *errno2name(void);
 
+/* Translate signal number to its name. */
+const char *signal2name(int);
+
 struct xlat;
 
 /* Print flags in symbolic form according to xlat table. */
-- 
1.8.3.1




------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports. http://pubads.g.doubleclick.net/gampad/clk?id=1444514421&iu=/41014381
_______________________________________________
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel

Reply via email to