When reporting reciept of a signal, print the signal's name.

This commit is contained in:
Alfred Perlstein 2004-07-17 19:19:36 +00:00
parent 5ebbe2f056
commit d75300bfa5
3 changed files with 26 additions and 7 deletions

View File

@ -35,6 +35,7 @@ extern int setup_and_wait(char **);
extern int start_tracing(int, int, int);
extern void restore_proc(int);
extern const char *ioctlname(register_t val);
extern char *strsig(int sig);
#ifdef __alpha__
extern void alpha_syscall_entry(struct trussinfo *, int);
extern long alpha_syscall_exit(struct trussinfo *, int);

View File

@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$");
#include <sys/time.h>
#include <sys/resource.h>
#include <ctype.h>
#include <err.h>
#include <errno.h>
#include <fcntl.h>
@ -138,6 +139,23 @@ set_etype(struct trussinfo *trussinfo) {
return funcs;
}
char *
strsig(int sig)
{
char *ret;
ret = NULL;
if (sig > 0 && sig < NSIG) {
int i;
asprintf(&ret, "sig%s", sys_signame[sig]);
if (ret == NULL)
return (NULL);
for (i = 0; ret[i] != '\0'; ++i)
ret[i] = toupper(ret[i]);
}
return (ret);
}
int
main(int ac, char **av) {
int c;
@ -149,6 +167,7 @@ main(int ac, char **av) {
char *fname = NULL;
int sigexit = 0;
struct trussinfo *trussinfo;
char *signame;
/* Initialize the trussinfo struct */
trussinfo = (struct trussinfo *)malloc(sizeof(struct trussinfo));
@ -285,7 +304,10 @@ main(int ac, char **av) {
funcs->exit_syscall(trussinfo, pfs.val);
break;
case S_SIG:
fprintf(trussinfo->outfile, "SIGNAL %lu\n", pfs.val);
signame = strsig(pfs.val);
fprintf(trussinfo->outfile, "SIGNAL %lu (%s)\n", pfs.val,
signame == NULL ? "?" : signame);
free(signame);
sigexit = pfs.val;
break;
case S_EXIT:

View File

@ -471,12 +471,8 @@ print_arg(int fd, struct syscall_args *sc, unsigned long *args) {
long sig;
sig = args[sc->offset];
if (sig > 0 && sig < NSIG) {
int i;
asprintf(&tmp, "sig%s", sys_signame[sig]);
for (i = 0; tmp[i] != '\0'; ++i)
tmp[i] = toupper(tmp[i]);
} else
tmp = strsig(sig);
if (tmp == NULL)
asprintf(&tmp, "%ld", sig);
}
break;