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 <kallisti5@unixzen.com>
This commit is contained in:
Jérôme Duval 2021-06-15 16:13:37 +02:00 committed by Alex von Gluck IV
parent b0557f6959
commit 7903bfcf8b

View File

@ -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);