summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormarc <marc@openbsd.org>2004-05-05 16:43:53 +0000
committermarc <marc@openbsd.org>2004-05-05 16:43:53 +0000
commitd963f85c7443d387e75ee92573c7c95e7ab8923a (patch)
tree32bdd9a7ab778b6f082be262aa5923c348eb32ff
parentprovide some filter examples; PR3764 (diff)
downloadwireguard-openbsd-d963f85c7443d387e75ee92573c7c95e7ab8923a.tar.xz
wireguard-openbsd-d963f85c7443d387e75ee92573c7c95e7ab8923a.zip
write cpuhdr with info needed by libkvm to crash dumps.
-rw-r--r--sys/arch/amd64/amd64/machdep.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/sys/arch/amd64/amd64/machdep.c b/sys/arch/amd64/amd64/machdep.c
index f670be81df6..8fa5af7a800 100644
--- a/sys/arch/amd64/amd64/machdep.c
+++ b/sys/arch/amd64/amd64/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.22 2004/03/11 21:06:01 deraadt Exp $ */
+/* $OpenBSD: machdep.c,v 1.23 2004/05/05 16:43:53 marc Exp $ */
/* $NetBSD: machdep.c,v 1.3 2003/05/07 22:58:18 fvdl Exp $ */
/*-
@@ -126,6 +126,7 @@
#include <machine/biosvar.h>
#include <machine/mpbiosvar.h>
#include <machine/reg.h>
+#include <machine/kcore.h>
#include <dev/isa/isareg.h>
#include <machine/isa_machdep.h>
@@ -929,11 +930,17 @@ cpu_dump()
int (*dump)(dev_t, daddr_t, caddr_t, size_t);
char buf[dbtob(1)];
kcore_seg_t *segp;
+ cpu_kcore_hdr_t *cpuhdrp;
+ phys_ram_seg_t *memsegp;
+ int i;
dump = bdevsw[major(dumpdev)].d_dump;
memset(buf, 0, sizeof buf);
segp = (kcore_seg_t *)buf;
+ cpuhdrp = (cpu_kcore_hdr_t *)&buf[ALIGN(sizeof(*segp))];
+ memsegp = (phys_ram_seg_t *)&buf[ALIGN(sizeof(*segp)) +
+ ALIGN(sizeof(*cpuhdrp))];
/*
* Generate a segment header.
@@ -941,6 +948,20 @@ cpu_dump()
CORE_SETMAGIC(*segp, KCORE_MAGIC, MID_MACHINE, CORE_CPU);
segp->c_size = dbtob(1) - ALIGN(sizeof(*segp));
+ /*
+ * Add the machine-dependent header info.
+ */
+ cpuhdrp->ptdpaddr = PTDpaddr;
+ cpuhdrp->nmemsegs = mem_cluster_cnt;
+
+ /*
+ * Fill in the memory segment descriptors.
+ */
+ for (i = 0; i < mem_cluster_cnt; i++) {
+ memsegp[i].start = mem_clusters[i].start;
+ memsegp[i].size = mem_clusters[i].size & ~PAGE_MASK;
+ }
+
return (dump(dumpdev, dumplo, (caddr_t)buf, dbtob(1)));
}