From 0c82cdbbbd19eccf869673227cffa7d2f773c1b3 Mon Sep 17 00:00:00 2001 From: Miod Vallat Date: Fri, 30 May 2003 20:47:54 +0000 Subject: Working process core dumps, borrowed from m68k code. --- sys/arch/mvme88k/mvme88k/vm_machdep.c | 48 ++++++++++++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 4 deletions(-) (limited to 'sys/arch') diff --git a/sys/arch/mvme88k/mvme88k/vm_machdep.c b/sys/arch/mvme88k/mvme88k/vm_machdep.c index 8978b6a65f0..3e635e3add9 100644 --- a/sys/arch/mvme88k/mvme88k/vm_machdep.c +++ b/sys/arch/mvme88k/mvme88k/vm_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vm_machdep.c,v 1.49 2003/01/04 01:12:08 miod Exp $ */ +/* $OpenBSD: vm_machdep.c,v 1.50 2003/05/30 20:47:53 miod Exp $ */ /* * Copyright (c) 1998 Steve Murphree, Jr. @@ -54,6 +54,9 @@ #include #include #include +#include +#include +#include #include @@ -172,11 +175,48 @@ cpu_exit(struct proc *p) /* NOTREACHED */ } +/* + * Dump the machine specific header information at the start of a core dump. + */ int -cpu_coredump(struct proc *p, struct vnode *vp, struct ucred *cred, struct core *corep) +cpu_coredump(p, vp, cred, chdr) + struct proc *p; + struct vnode *vp; + struct ucred *cred; + struct core *chdr; { - return (vn_rdwr(UIO_WRITE, vp, (caddr_t) p->p_addr, ctob(UPAGES), - (off_t)0, UIO_SYSSPACE, IO_NODELOCKED|IO_UNIT, cred, NULL, p)); + struct reg reg; + struct coreseg cseg; + int error; + + CORE_SETMAGIC(*chdr, COREMAGIC, MID_MACHINE, 0); + chdr->c_hdrsize = ALIGN(sizeof(*chdr)); + chdr->c_seghdrsize = ALIGN(sizeof(cseg)); + chdr->c_cpusize = sizeof(reg); + + /* Save registers. */ + error = process_read_regs(p, ®); + if (error) + return error; + + CORE_SETMAGIC(cseg, CORESEGMAGIC, MID_MACHINE, CORE_CPU); + cseg.c_addr = 0; + cseg.c_size = chdr->c_cpusize; + + error = vn_rdwr(UIO_WRITE, vp, (caddr_t)&cseg, chdr->c_seghdrsize, + (off_t)chdr->c_hdrsize, UIO_SYSSPACE, IO_NODELOCKED|IO_UNIT, cred, + NULL, p); + if (error) + return error; + + error = vn_rdwr(UIO_WRITE, vp, (caddr_t)®, sizeof(reg), + (off_t)(chdr->c_hdrsize + chdr->c_seghdrsize), UIO_SYSSPACE, + IO_NODELOCKED|IO_UNIT, cred, NULL, p); + if (error) + return error; + + chdr->c_nseg++; + return 0; } /* -- cgit v1.2.3