diff options
author | peter <peter@FreeBSD.org> | 2006-04-21 04:32:51 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 2006-04-21 04:32:51 +0000 |
commit | aeeca95e16a25ef1697a410a1c75cedb6f3fcd27 (patch) | |
tree | c546335c0248613d0123d64bcdb8f956ae439af1 /lib/libkvm/kvm_i386.c | |
parent | 3fd2125c991b07c464f53c893b51e9d74bea6859 (diff) | |
download | FreeBSD-src-aeeca95e16a25ef1697a410a1c75cedb6f3fcd27.zip FreeBSD-src-aeeca95e16a25ef1697a410a1c75cedb6f3fcd27.tar.gz |
Teach libkvm how to read minidumps. It turns out that minidumps are
far more convenient for libkvm to work with because of the page table
block at the beginning. As a result, the MD code is smaller.
libkvm will automatically detect old vs mini dumps on i386 and amd64.
libkvm will handle i386 PAE and non-PAE modes. There is a PAE flag in
the i386 minidump header to signal the width of the entries in the
page table block.
Other convenient values are also present, such as kernbase and the direct
map addresses on amd64.
Diffstat (limited to 'lib/libkvm/kvm_i386.c')
-rw-r--r-- | lib/libkvm/kvm_i386.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/libkvm/kvm_i386.c b/lib/libkvm/kvm_i386.c index 258c2f2..9560cc9 100644 --- a/lib/libkvm/kvm_i386.c +++ b/lib/libkvm/kvm_i386.c @@ -78,7 +78,9 @@ static char sccsid[] = "@(#)kvm_hp300.c 8.1 (Berkeley) 6/4/93"; #define NPTEPG_PAE (PAGE_SIZE/sizeof(uint64_t)) #define NBPDR_PAE (1<<PDRSHIFT_PAE) +/* minidump must be the first item! */ struct vmstate { + int minidump; /* 1 = minidump mode */ void *mmapbase; size_t mmapsize; void *PTD; @@ -134,6 +136,8 @@ _kvm_freevtop(kvm_t *kd) { struct vmstate *vm = kd->vmst; + if (kd->vmst->minidump) + return (_kvm_minidump_freevtop(kd)); if (vm->mmapbase != NULL) munmap(vm->mmapbase, vm->mmapsize); if (vm->PTD) @@ -152,6 +156,11 @@ _kvm_initvtop(kvm_t *kd) Elf_Ehdr *ehdr; size_t hdrsz; int i; + char minihdr[8]; + + if (pread(kd->pmfd, &minihdr, 8, 0) == 8) + if (memcmp(&minihdr, "minidump", 8) == 0) + return (_kvm_minidump_initvtop(kd)); kd->vmst = (struct vmstate *)_kvm_malloc(kd, sizeof(*kd->vmst)); if (kd->vmst == 0) { @@ -426,6 +435,8 @@ int _kvm_kvatop(kvm_t *kd, u_long va, off_t *pa) { + if (kd->vmst->minidump) + return (_kvm_minidump_kvatop(kd, va, pa)); if (ISALIVE(kd)) { _kvm_err(kd, 0, "vatop called in live kernel!"); return (0); |