From 7903bfcf8bdfcda821c0db8144fd247966630224 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= Date: Tue, 15 Jun 2021 16:13:37 +0200 Subject: [PATCH] strace: add signal name tracing inspired by hrev23436, fix #10944 Change-Id: Ieedace86a6541a4cd1346791146a96e99d09d614 Reviewed-on: https://review.haiku-os.org/c/haiku/+/4093 Reviewed-by: Alex von Gluck IV --- src/bin/debug/strace/strace.cpp | 42 +++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/src/bin/debug/strace/strace.cpp b/src/bin/debug/strace/strace.cpp index 1ae5751a99..7c80721791 100644 --- a/src/bin/debug/strace/strace.cpp +++ b/src/bin/debug/strace/strace.cpp @@ -110,6 +110,44 @@ static const char *kTerminalTextMagenta = "\33[35m"; static const char *kTerminalTextBlue = "\33[34m"; +// signal names +static const char *kSignalName[] = { + /* 0 */ "SIG0", + /* 1 */ "SIGHUP", + /* 2 */ "SIGINT", + /* 3 */ "SIGQUIT", + /* 4 */ "SIGILL", + /* 5 */ "SIGCHLD", + /* 6 */ "SIGABRT", + /* 7 */ "SIGPIPE", + /* 8 */ "SIGFPE", + /* 9 */ "SIGKILL", + /* 10 */ "SIGSTOP", + /* 11 */ "SIGSEGV", + /* 12 */ "SIGCONT", + /* 13 */ "SIGTSTP", + /* 14 */ "SIGALRM", + /* 15 */ "SIGTERM", + /* 16 */ "SIGTTIN", + /* 17 */ "SIGTTOU", + /* 18 */ "SIGUSR1", + /* 19 */ "SIGUSR2", + /* 20 */ "SIGWINCH", + /* 21 */ "SIGKILLTHR", + /* 22 */ "SIGTRAP", + /* 23 */ "SIGPOLL", + /* 24 */ "SIGPROF", + /* 25 */ "SIGSYS", + /* 26 */ "SIGURG", + /* 27 */ "SIGVTALRM", + /* 28 */ "SIGXCPU", + /* 29 */ "SIGXFSZ", + /* 30 */ "SIGBUS", + /* 31 */ "SIGRESERVED1", + /* 32 */ "SIGRESERVED2", +}; + + // command line args static int sArgc; static const char *const *sArgv; @@ -382,8 +420,8 @@ print_syscall(FILE *outputFile, Syscall* syscall, debug_post_syscall &message, static const char * signal_name(int signal) { - if (signal >= 0 && signal < NSIG) - return strsignal(signal); + if (signal >= 0 && signal <= SIGRESERVED2) + return kSignalName[signal]; static char buffer[32]; sprintf(buffer, "%d", signal);