Now properly display Mach traps
This commit is contained in:
parent
598200cca0
commit
bcffe04b31
@ -1,4 +1,4 @@
|
||||
# $NetBSD: Makefile,v 1.21 2002/09/19 11:31:21 lukem Exp $
|
||||
# $NetBSD: Makefile,v 1.22 2002/11/15 19:58:05 manu Exp $
|
||||
# @(#)Makefile 8.1 (Berkeley) 6/6/93
|
||||
|
||||
.include <bsd.own.mk> # for MKDYNAMICROOT & NETBSDSRCDIR
|
||||
@ -10,9 +10,9 @@ SRCS= kdump.c ioctl.c subr.c setemul.c
|
||||
CLEANFILES+=ioctl.c
|
||||
WFORMAT=1
|
||||
|
||||
.if (${MKDYNAMICROOT} == "no")
|
||||
LDSTATIC?=-static
|
||||
.endif
|
||||
#.if (${MKDYNAMICROOT} == "no")
|
||||
#LDSTATIC?=-static
|
||||
#.endif
|
||||
|
||||
.include "Makefile.ioctl-c"
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: kdump.c,v 1.41 2002/09/27 20:31:44 atatat Exp $ */
|
||||
/* $NetBSD: kdump.c,v 1.42 2002/11/15 19:58:05 manu 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.41 2002/09/27 20:31:44 atatat Exp $");
|
||||
__RCSID("$NetBSD: kdump.c,v 1.42 2002/11/15 19:58:05 manu Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -176,6 +176,7 @@ main(argc, argv)
|
||||
usage();
|
||||
|
||||
setemul(emul_name, 0, 0);
|
||||
mach_lookup_emul();
|
||||
|
||||
m = malloc(size = 1024);
|
||||
if (m == NULL)
|
||||
@ -326,12 +327,14 @@ ktrsyscall(ktr)
|
||||
struct ktr_syscall *ktr;
|
||||
{
|
||||
int argsize = ktr->ktr_argsize;
|
||||
const struct emulation *revelant = current;
|
||||
register_t *ap;
|
||||
|
||||
if (ktr->ktr_code >= current->nsysnames || ktr->ktr_code < 0)
|
||||
if ((ktr->ktr_code >= revelant->nsysnames || ktr->ktr_code < 0)
|
||||
&& (mach_traps_dispatch(&ktr->ktr_code, &revelant) == 0))
|
||||
(void)printf("[%d]", ktr->ktr_code);
|
||||
else
|
||||
(void)printf("%s", current->sysnames[ktr->ktr_code]);
|
||||
(void)printf("%s", revelant->sysnames[ktr->ktr_code]);
|
||||
ap = (register_t *)((char *)ktr + sizeof(struct ktr_syscall));
|
||||
if (argsize) {
|
||||
char c = '(';
|
||||
@ -356,7 +359,7 @@ ktrsyscall(ktr)
|
||||
break;
|
||||
|
||||
case SYS_ptrace:
|
||||
if (strcmp(current->name, "linux") == 0) {
|
||||
if (strcmp(revelant->name, "linux") == 0) {
|
||||
if (*ap >= 0 && *ap <=
|
||||
sizeof(linux_ptrace_ops) /
|
||||
sizeof(linux_ptrace_ops[0]))
|
||||
@ -421,7 +424,8 @@ ktrsysret(ktr)
|
||||
revelant = current;
|
||||
emul_changed = 0;
|
||||
|
||||
if (code >= revelant->nsysnames || code < 0 || plain > 1)
|
||||
if ((code >= revelant->nsysnames || code < 0 || plain > 1)
|
||||
&& (mach_traps_dispatch(&code, &revelant) == 0))
|
||||
(void)printf("[%d] ", code);
|
||||
else
|
||||
(void)printf("%s ", revelant->sysnames[code]);
|
||||
@ -445,7 +449,6 @@ ktrsysret(ktr)
|
||||
break;
|
||||
}
|
||||
(void)putchar('\n');
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: setemul.c,v 1.13 2002/10/29 07:17:43 manu Exp $ */
|
||||
/* $NetBSD: setemul.c,v 1.14 2002/11/15 19:58:05 manu Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2000 The NetBSD Foundation, Inc.
|
||||
@ -73,7 +73,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: setemul.c,v 1.13 2002/10/29 07:17:43 manu Exp $");
|
||||
__RCSID("$NetBSD: setemul.c,v 1.14 2002/11/15 19:58:05 manu Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -98,6 +98,9 @@ __RCSID("$NetBSD: setemul.c,v 1.13 2002/10/29 07:17:43 manu Exp $");
|
||||
#include "../../sys/compat/irix/irix_syscall.h"
|
||||
#include "../../sys/compat/linux/linux_syscall.h"
|
||||
#include "../../sys/compat/mach/mach_syscall.h"
|
||||
#include "../../sys/compat/darwin/darwin_syscall.h"
|
||||
#include "../../sys/compat/mach/arch/powerpc/ppccalls/mach_ppccalls_syscall.h"
|
||||
#include "../../sys/compat/mach/arch/powerpc/fasttraps/mach_fasttraps_syscall.h"
|
||||
#include "../../sys/compat/osf1/osf1_syscall.h"
|
||||
#include "../../sys/compat/sunos32/sunos32_syscall.h"
|
||||
#include "../../sys/compat/sunos/sunos_syscall.h"
|
||||
@ -114,7 +117,10 @@ __RCSID("$NetBSD: setemul.c,v 1.13 2002/10/29 07:17:43 manu Exp $");
|
||||
#include "../../sys/compat/ibcs2/ibcs2_syscalls.c"
|
||||
#include "../../sys/compat/irix/irix_syscalls.c"
|
||||
#include "../../sys/compat/linux/linux_syscalls.c"
|
||||
#include "../../sys/compat/darwin/darwin_syscalls.c"
|
||||
#include "../../sys/compat/mach/mach_syscalls.c"
|
||||
#include "../../sys/compat/mach/arch/powerpc/ppccalls/mach_ppccalls_syscalls.c"
|
||||
#include "../../sys/compat/mach/arch/powerpc/fasttraps/mach_fasttraps_syscalls.c"
|
||||
#include "../../sys/compat/osf1/osf1_syscalls.c"
|
||||
#include "../../sys/compat/sunos/sunos_syscalls.c"
|
||||
#include "../../sys/compat/sunos32/sunos32_syscalls.c"
|
||||
@ -140,7 +146,8 @@ __RCSID("$NetBSD: setemul.c,v 1.13 2002/10/29 07:17:43 manu Exp $");
|
||||
|
||||
#define NELEM(a) (sizeof(a) / sizeof(a[0]))
|
||||
|
||||
static const struct emulation emulations[] = {
|
||||
/* static */
|
||||
const struct emulation emulations[] = {
|
||||
{ "netbsd", syscallnames, SYS_MAXSYSCALL,
|
||||
NULL, 0,
|
||||
NULL, 0 },
|
||||
@ -173,10 +180,24 @@ static const struct emulation emulations[] = {
|
||||
native_to_linux_errno, NELEM(native_to_linux_errno),
|
||||
linux_to_native_signo, NSIG },
|
||||
|
||||
{ "mach", mach_syscallnames, MACH_SYS_MAXSYSCALL,
|
||||
{ "darwin", darwin_syscallnames, DARWIN_SYS_MAXSYSCALL,
|
||||
NULL, 0,
|
||||
NULL, 0 },
|
||||
|
||||
{ "mach", mach_syscallnames, MACH_SYS_MAXSYSCALL,
|
||||
NULL, 0,
|
||||
NULL, 0 },
|
||||
|
||||
{ "mach ppccalls", mach_ppccalls_syscallnames,
|
||||
MACH_PPCCALLS_SYS_MAXSYSCALL,
|
||||
NULL, 0,
|
||||
NULL, 0 },
|
||||
|
||||
{ "mach fasttraps", mach_fasttraps_syscallnames,
|
||||
MACH_FASTTRAPS_SYS_MAXSYSCALL,
|
||||
NULL, 0,
|
||||
NULL, 0 },
|
||||
|
||||
{ "osf1", osf1_syscallnames, OSF1_SYS_MAXSYSCALL,
|
||||
native_to_osf1_errno, NELEM(native_to_osf1_errno),
|
||||
osf1_to_native_signo, NSIG },
|
||||
@ -218,6 +239,10 @@ struct emulation_ctx {
|
||||
|
||||
const struct emulation *current;
|
||||
const struct emulation *previous;
|
||||
/* Mach emulation require extra emulation contexts */
|
||||
const struct emulation *mach;
|
||||
const struct emulation *mach_ppccalls;
|
||||
const struct emulation *mach_fasttraps;
|
||||
|
||||
static const struct emulation *default_emul=NULL;
|
||||
|
||||
@ -328,3 +353,61 @@ ectx_sanify(pid)
|
||||
else
|
||||
current = &emulations[0]; /* NetBSD */
|
||||
}
|
||||
|
||||
/*
|
||||
* Temporarily modify code and emulations to handle Mach traps
|
||||
* XXX The define are duplicated from sys/arch/powerpc/include/mach_syscall.c
|
||||
*/
|
||||
#define MACH_FASTTRAPS 0x00007ff0
|
||||
#define MACH_PPCCALLS 0x00006000
|
||||
#define MACH_ODD_SYSCALL_MASK 0x0000fff0
|
||||
int
|
||||
mach_traps_dispatch(code, emul)
|
||||
int *code;
|
||||
const struct emulation **emul;
|
||||
{
|
||||
switch (*code & MACH_ODD_SYSCALL_MASK) {
|
||||
case MACH_FASTTRAPS:
|
||||
*emul = mach_fasttraps;
|
||||
*code -= MACH_FASTTRAPS;
|
||||
return 1;
|
||||
break;
|
||||
|
||||
case MACH_PPCCALLS:
|
||||
*emul = mach_ppccalls;
|
||||
*code -= MACH_PPCCALLS;
|
||||
return 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
if (*code < 0) {
|
||||
*emul = mach;
|
||||
*code = -*code;
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Lookup Machs emulations
|
||||
*/
|
||||
void
|
||||
mach_lookup_emul(void) {
|
||||
const struct emulation *emul_idx;
|
||||
|
||||
for (emul_idx = emulations; emul_idx->name; emul_idx++) {
|
||||
if (strcmp("mach", emul_idx->name) == 0)
|
||||
mach = emul_idx;
|
||||
if (strcmp("mach fasttraps", emul_idx->name) == 0)
|
||||
mach_fasttraps = emul_idx;
|
||||
if (strcmp("mach ppccalls", emul_idx->name) == 0)
|
||||
mach_ppccalls = emul_idx;
|
||||
}
|
||||
if (mach == NULL || mach_fasttraps == NULL || mach_ppccalls == NULL) {
|
||||
errx(1, "Cannot load mach emulations");
|
||||
exit(1);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: setemul.h,v 1.6 2002/03/31 22:44:03 christos Exp $ */
|
||||
/* $NetBSD: setemul.h,v 1.7 2002/11/15 19:58:05 manu Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2000 The NetBSD Foundation, Inc.
|
||||
@ -88,4 +88,6 @@ extern const struct emulation *previous;
|
||||
|
||||
void setemul __P((const char *, pid_t, int));
|
||||
void ectx_sanify __P((pid_t));
|
||||
int mach_traps_dispatch __P((int *, const struct emulation **));
|
||||
void mach_lookup_emul __P((void));
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user