Provide hooks for signal number to name translation, and use them for kill

and PSIG.

XXX[1]: This shows that signal emulation ktrace is slightly busted: posted
	signals should really be translated to the emulated ones instead of
	producing ktrace records with the signal numbers of the native
	emulation.
XXX[2]: There are other places where signal names can be displayed, but this
	is not done yet.
This commit is contained in:
christos 2002-03-31 22:44:03 +00:00
parent 840887afee
commit f600368b8f
3 changed files with 122 additions and 46 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: kdump.c,v 1.36 2002/02/12 22:22:37 christos Exp $ */
/* $NetBSD: kdump.c,v 1.37 2002/03/31 22:44:03 christos Exp $ */
/*-
* Copyright (c) 1988, 1993
@ -43,7 +43,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 1993\n\
#if 0
static char sccsid[] = "@(#)kdump.c 8.4 (Berkeley) 4/28/95";
#else
__RCSID("$NetBSD: kdump.c,v 1.36 2002/02/12 22:22:37 christos Exp $");
__RCSID("$NetBSD: kdump.c,v 1.37 2002/03/31 22:44:03 christos Exp $");
#endif
#endif /* not lint */
@ -109,6 +109,7 @@ void ktruser __P((struct ktr_user *, int));
void usage __P((void));
void eprint __P((int));
char *ioctlname __P((long));
static const char *signame __P((long, int));
int
main(argc, argv)
@ -318,8 +319,10 @@ ktrsyscall(ktr)
if (argsize) {
char c = '(';
if (!plain) {
if (ktr->ktr_code == SYS_ioctl) {
char *cp;
char *cp;
switch (ktr->ktr_code) {
case SYS_ioctl:
if (decimal)
(void)printf("(%ld", (long)*ap);
else
@ -333,11 +336,15 @@ ktrsyscall(ktr)
c = ',';
ap++;
argsize -= sizeof(register_t);
} else if (ktr->ktr_code == SYS_ptrace) {
break;
case SYS_ptrace:
if (strcmp(current->name, "linux") == 0) {
if (*ap >= 0 && *ap <=
sizeof(linux_ptrace_ops) / sizeof(linux_ptrace_ops[0]))
(void)printf("(%s", linux_ptrace_ops[*ap]);
if (*ap >= 0 && *ap <=
sizeof(linux_ptrace_ops) /
sizeof(linux_ptrace_ops[0]))
(void)printf("(%s",
linux_ptrace_ops[*ap]);
else
(void)printf("(%ld", (long)*ap);
} else {
@ -350,6 +357,22 @@ ktrsyscall(ktr)
c = ',';
ap++;
argsize -= sizeof(register_t);
break;
case SYS_kill:
if (decimal)
(void)printf("(%ld, SIG%s",
(long)ap[0], signame(ap[1], 1));
else
(void)printf("(%#lx, SIG%s",
(long)ap[0], signame(ap[1], 1));
ap += 2;
argsize -= 2 * sizeof(register_t);
break;
default:
/* No special handling */
break;
}
}
while (argsize) {
@ -546,7 +569,7 @@ ktrpsig(psig)
{
int signo, first;
(void)printf("SIG%s ", sys_signame[psig->signo]);
(void)printf("SIG%s ", signame(psig->signo, 0));
if (psig->action == SIG_DFL)
(void)printf("SIG_DFL\n");
else {
@ -590,6 +613,17 @@ ktruser(usr, len)
printf("\"\n");
}
static const char *
signame(long sig, int xlat)
{
static char buf[64];
if (sig <= 0 || sig >= NSIG) {
(void)snprintf(buf, sizeof(buf), "*unknown %ld*", sig);
return buf;
} else
return sys_signame[xlat ? current->signalmap[sig] : sig];
}
void
usage()
{

View File

@ -1,4 +1,4 @@
/* $NetBSD: setemul.c,v 1.11 2002/01/07 23:45:10 manu Exp $ */
/* $NetBSD: setemul.c,v 1.12 2002/03/31 22:44:03 christos Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@ -73,7 +73,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: setemul.c,v 1.11 2002/01/07 23:45:10 manu Exp $");
__RCSID("$NetBSD: setemul.c,v 1.12 2002/03/31 22:44:03 christos Exp $");
#endif /* not lint */
#include <sys/param.h>
@ -124,44 +124,84 @@ __RCSID("$NetBSD: setemul.c,v 1.11 2002/01/07 23:45:10 manu Exp $");
#include "../../sys/compat/svr4/svr4_errno.c"
#include "../../sys/compat/ibcs2/ibcs2_errno.c"
#include "../../sys/compat/irix/irix_errno.c"
#include "../../sys/compat/osf1/osf1_errno.c"
#include "../../sys/compat/linux/common/linux_errno.c"
#undef KTRACE
#define SIGRTMIN 33 /* XXX */
#include "../../sys/compat/hpux/hpux_signo.c"
#include "../../sys/compat/svr4/svr4_signo.c"
#include "../../sys/compat/ibcs2/ibcs2_signo.c"
/* irix uses svr4 */
#include "../../sys/compat/osf1/osf1_signo.c"
#include "../../sys/compat/linux/common/linux_signo.c"
#define NELEM(a) (sizeof(a) / sizeof(a[0]))
static const struct emulation emulations[] = {
{ "netbsd", syscallnames, SYS_MAXSYSCALL,
NULL, 0 },
{ "netbsd32", netbsd32_syscallnames, SYS_MAXSYSCALL,
NULL, 0 },
{ "freebsd", freebsd_syscallnames, FREEBSD_SYS_MAXSYSCALL,
NULL, 0 },
{ "hpux", hpux_syscallnames, HPUX_SYS_MAXSYSCALL,
native_to_hpux_errno, NELEM(native_to_hpux_errno) },
{ "ibcs2", ibcs2_syscallnames, IBCS2_SYS_MAXSYSCALL,
native_to_ibcs2_errno, NELEM(native_to_ibcs2_errno) },
{ "irix o32", irix_syscallnames, IRIX_SYS_MAXSYSCALL,
native_to_irix_errno, NELEM(native_to_irix_errno) },
{ "irix n32", irix_syscallnames, IRIX_SYS_MAXSYSCALL,
native_to_irix_errno, NELEM(native_to_irix_errno) },
{ "linux", linux_syscallnames, LINUX_SYS_MAXSYSCALL,
native_to_linux_errno, NELEM(native_to_linux_errno) },
{ "osf1", osf1_syscallnames, OSF1_SYS_MAXSYSCALL,
NULL, 0 },
{ "sunos32",sunos32_syscallnames, SUNOS32_SYS_MAXSYSCALL,
NULL, 0 },
{ "sunos", sunos_syscallnames, SUNOS_SYS_MAXSYSCALL,
NULL, 0 },
{ "svr4", svr4_syscallnames, SVR4_SYS_MAXSYSCALL,
native_to_svr4_errno, NELEM(native_to_svr4_errno) },
{ "svr4_32", svr4_syscallnames, SVR4_SYS_MAXSYSCALL,
native_to_svr4_errno, NELEM(native_to_svr4_errno) },
{ "ultrix", ultrix_syscallnames, ULTRIX_SYS_MAXSYSCALL,
NULL, 0 },
{ "pecoff", syscallnames, SYS_MAXSYSCALL,
NULL, 0 },
{ NULL, NULL, 0,
NULL, 0 }
{ "netbsd", syscallnames, SYS_MAXSYSCALL,
NULL, 0,
NULL, 0 },
{ "netbsd32", netbsd32_syscallnames, SYS_MAXSYSCALL,
NULL, 0,
NULL, 0 },
{ "freebsd", freebsd_syscallnames, FREEBSD_SYS_MAXSYSCALL,
NULL, 0,
NULL, 0 },
{ "hpux", hpux_syscallnames, HPUX_SYS_MAXSYSCALL,
native_to_hpux_errno, NELEM(native_to_hpux_errno),
hpux_to_native_signo, NSIG },
{ "ibcs2", ibcs2_syscallnames, IBCS2_SYS_MAXSYSCALL,
native_to_ibcs2_errno, NELEM(native_to_ibcs2_errno),
ibcs2_to_native_signo, NSIG },
{ "irix o32", irix_syscallnames, IRIX_SYS_MAXSYSCALL,
native_to_irix_errno, NELEM(native_to_irix_errno),
svr4_to_native_signo, NSIG },
{ "irix n32", irix_syscallnames, IRIX_SYS_MAXSYSCALL,
native_to_irix_errno, NELEM(native_to_irix_errno),
svr4_to_native_signo, NSIG },
{ "linux", linux_syscallnames, LINUX_SYS_MAXSYSCALL,
native_to_linux_errno, NELEM(native_to_linux_errno),
linux_to_native_signo, NSIG },
{ "osf1", osf1_syscallnames, OSF1_SYS_MAXSYSCALL,
native_to_osf1_errno, NELEM(native_to_osf1_errno),
osf1_to_native_signo, NSIG },
{ "sunos32", sunos32_syscallnames, SUNOS32_SYS_MAXSYSCALL,
NULL, 0,
NULL, 0 },
{ "sunos", sunos_syscallnames, SUNOS_SYS_MAXSYSCALL,
NULL, 0,
NULL, 0 },
{ "svr4", svr4_syscallnames, SVR4_SYS_MAXSYSCALL,
native_to_svr4_errno, NELEM(native_to_svr4_errno),
svr4_to_native_signo, NSIG },
{ "svr4_32", svr4_syscallnames, SVR4_SYS_MAXSYSCALL,
native_to_svr4_errno, NELEM(native_to_svr4_errno),
svr4_to_native_signo, NSIG },
{ "ultrix", ultrix_syscallnames, ULTRIX_SYS_MAXSYSCALL,
NULL, 0,
NULL, 0 },
{ "pecoff", syscallnames, SYS_MAXSYSCALL,
NULL, 0,
NULL, 0 },
{ NULL, NULL, 0,
NULL, 0,
NULL, 0 }
};
struct emulation_ctx {

View File

@ -1,4 +1,4 @@
/* $NetBSD: setemul.h,v 1.5 2001/02/16 23:28:44 manu Exp $ */
/* $NetBSD: setemul.h,v 1.6 2002/03/31 22:44:03 christos Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@ -76,9 +76,11 @@
struct emulation {
const char *name; /* Emulation name */
const char * const *sysnames; /* Array of system call names */
int nsysnames; /* Number of */
int nsysnames; /* Number of */
const int *errnomap; /* Array of error number mapping */
int nerrnomap; /* number of elements in array */
int nerrnomap; /* number of elements in array */
const int *signalmap; /* Array of signal number mapping */
int nsignalmap; /* number of elements in array */
};
extern const struct emulation *current;