summaryrefslogtreecommitdiff
path: root/lib/libkvm/kvm_proc.c
diff options
context:
space:
mode:
authorAriane van der Steldt <ariane@cvs.openbsd.org>2012-03-09 13:02:46 +0000
committerAriane van der Steldt <ariane@cvs.openbsd.org>2012-03-09 13:02:46 +0000
commitbbf7a61211f58dbe1e5f862b98b675d12e2c964a (patch)
tree577a2bca95e8d49e35bba7daf6495c049e09b584 /lib/libkvm/kvm_proc.c
parent193e3efb70083a72f3d299ea5f129cf83d547115 (diff)
Userspace counterpart of new vmmap.
Allows memory walks to function.
Diffstat (limited to 'lib/libkvm/kvm_proc.c')
-rw-r--r--lib/libkvm/kvm_proc.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/lib/libkvm/kvm_proc.c b/lib/libkvm/kvm_proc.c
index 8bc0745b638..a2555fb77d9 100644
--- a/lib/libkvm/kvm_proc.c
+++ b/lib/libkvm/kvm_proc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kvm_proc.c,v 1.45 2012/01/07 05:38:12 guenther Exp $ */
+/* $OpenBSD: kvm_proc.c,v 1.46 2012/03/09 13:02:45 ariane Exp $ */
/* $NetBSD: kvm_proc.c,v 1.30 1999/03/24 05:50:50 mrg Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -131,7 +131,7 @@ static void ps_str_e(struct ps_strings *, u_long *, int *);
static char *
_kvm_ureadm(kvm_t *kd, const struct miniproc *p, u_long va, u_long *cnt)
{
- u_long addr, head, offset, slot;
+ u_long addr, offset, slot;
struct vm_anon *anonp, anon;
struct vm_map_entry vme;
struct vm_amap amap;
@@ -140,27 +140,28 @@ _kvm_ureadm(kvm_t *kd, const struct miniproc *p, u_long va, u_long *cnt)
if (kd->swapspc == 0) {
kd->swapspc = _kvm_malloc(kd, kd->nbpg);
if (kd->swapspc == 0)
- return (0);
+ return (NULL);
}
/*
* Look through the address map for the memory object
* that corresponds to the given virtual address.
- * The header just has the entire valid range.
*/
- head = (u_long)&p->p_vmspace->vm_map.header;
- addr = head;
+ addr = (u_long)RB_ROOT(&p->p_vmspace->vm_map.addr);
while (1) {
+ if (addr == 0)
+ return (NULL);
if (KREAD(kd, addr, &vme))
- return (0);
+ return (NULL);
- if (va >= vme.start && va < vme.end &&
- vme.aref.ar_amap != NULL)
+ if (va < vme.start)
+ addr = (u_long)RB_LEFT(&vme, daddrs.addr_entry);
+ else if (va >= vme.end + vme.guard + vme.fspace)
+ addr = (u_long)RB_RIGHT(&vme, daddrs.addr_entry);
+ else if (va >= vme.end)
+ return (NULL);
+ else
break;
-
- addr = (u_long)vme.next;
- if (addr == head)
- return (0);
}
/*