summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2003-05-30 20:37:43 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2003-05-30 20:37:43 +0000
commit573f29cf8f47e5dc0c772fa73df907fc191ffd06 (patch)
treea8a16fb1d313e84c864abf3fa166f1e63a77f66a /sys
parent3dffae44c0066a6e4aee54e1a346110caf316c12 (diff)
Sync the core dump routine with hp300; generates correct coredumps again.
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/mvme68k/mvme68k/vm_machdep.c53
1 files changed, 50 insertions, 3 deletions
diff --git a/sys/arch/mvme68k/mvme68k/vm_machdep.c b/sys/arch/mvme68k/mvme68k/vm_machdep.c
index 027c7c6d1f0..a8d66141f7e 100644
--- a/sys/arch/mvme68k/mvme68k/vm_machdep.c
+++ b/sys/arch/mvme68k/mvme68k/vm_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vm_machdep.c,v 1.35 2002/04/28 14:47:54 miod Exp $ */
+/* $OpenBSD: vm_machdep.c,v 1.36 2003/05/30 20:37:42 miod Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -50,10 +50,13 @@
#include <sys/buf.h>
#include <sys/vnode.h>
#include <sys/user.h>
+#include <sys/core.h>
+#include <sys/exec.h>
#include <machine/cpu.h>
#include <machine/pte.h>
#include <machine/reg.h>
+#include <machine/frame.h>
#include <uvm/uvm_extern.h>
@@ -136,6 +139,10 @@ cpu_exit(p)
/*
* Dump the machine specific header information at the start of a core dump.
*/
+struct md_core {
+ struct reg intreg;
+ struct fpreg freg;
+};
int
cpu_coredump(p, vp, cred, chdr)
struct proc *p;
@@ -143,8 +150,48 @@ cpu_coredump(p, vp, cred, chdr)
struct ucred *cred;
struct core *chdr;
{
- return (vn_rdwr(UIO_WRITE, vp, (caddr_t) p->p_addr, USPACE,
- (off_t)0, UIO_SYSSPACE, IO_NODELOCKED|IO_UNIT, cred, NULL, p));
+ struct md_core md_core;
+ 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(md_core);
+
+ /* Save integer registers. */
+ error = process_read_regs(p, &md_core.intreg);
+ if (error)
+ return error;
+
+ if (fputype) {
+ /* Save floating point registers. */
+ error = process_read_fpregs(p, &md_core.freg);
+ if (error)
+ return error;
+ } else {
+ /* Make sure these are clear. */
+ bzero((caddr_t)&md_core.freg, sizeof(md_core.freg));
+ }
+
+ 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)&md_core, sizeof(md_core),
+ (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;
}
/*