Teach truss to print symbolic signal names (e.g. SIGHUP instead of 0x01).

This commit is contained in:
Dag-Erling Smørgrav 1999-08-10 16:57:37 +00:00
parent df4509c005
commit f0ebbc2985
2 changed files with 24 additions and 3 deletions

View File

@ -18,10 +18,11 @@
* IN (meaning that the data is passed *into* the system call).
*/
/*
* $Id: syscall.h,v 1.2 1997/12/06 06:51:13 sef Exp $
* $Id: syscall.h,v 1.3 1997/12/20 18:40:41 sef Exp $
*/
enum Argtype { None = 1, Hex, Octal, Int, String, Ptr, Stat, Ioctl, Quad };
enum Argtype { None = 1, Hex, Octal, Int, String, Ptr, Stat, Ioctl, Quad,
Signal };
#define ARG_MASK 0xff
#define OUT 0x100

View File

@ -31,7 +31,7 @@
#ifndef lint
static const char rcsid[] =
"$Id: syscalls.c,v 1.6 1998/10/15 04:31:44 sef Exp $";
"$Id: syscalls.c,v 1.7 1999/08/05 12:03:50 des Exp $";
#endif /* not lint */
/*
@ -45,6 +45,7 @@ static const char rcsid[] =
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <signal.h>
#include "syscall.h"
/*
@ -80,6 +81,8 @@ struct syscall syscalls[] = {
{ "break", 1, 1, { { Hex, 0 }}},
{ "exit", 0, 1, { { Hex, 0 }}},
{ "access", 1, 2, { { String | IN, 0 }, { Int, 1 }}},
{ "sigaction", 1, 3,
{ { Signal, 0 }, { Ptr | IN, 1 }, { Ptr | OUT, 2 }}},
{ 0, 0, 0, { { 0, 0 }}},
};
@ -217,6 +220,23 @@ print_arg(int fd, struct syscall_args *sc, unsigned long *args) {
sprintf(tmp, "0x%lx", args[sc->offset]);
}
}
break;
case Signal:
{
long sig;
sig = args[sc->offset];
tmp = malloc(12);
if (sig > 0 && sig < NSIG) {
int i;
sprintf(tmp, "sig%s", sys_signame[sig]);
for (i = 0; tmp[i] != '\0'; ++i)
tmp[i] = toupper(tmp[i]);
} else {
sprintf(tmp, "%ld", sig);
}
}
break;
}
return tmp;
}