diff options
author | Ted Unangst <tedu@cvs.openbsd.org> | 2004-02-23 19:48:41 +0000 |
---|---|---|
committer | Ted Unangst <tedu@cvs.openbsd.org> | 2004-02-23 19:48:41 +0000 |
commit | b1c86d001b96d55eca1de66859e1c3bd6e8c55a6 (patch) | |
tree | dc61ebb0427b162ee293cce19f000c9ea352438f /usr.sbin/procmap | |
parent | 842f37a96949a2995ae2b539eb7932df7635bbab (diff) |
if the heap is non-exec, it makes it hard to find by looking for an exec
mapping. much better heuristic.
Diffstat (limited to 'usr.sbin/procmap')
-rw-r--r-- | usr.sbin/procmap/procmap.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/usr.sbin/procmap/procmap.c b/usr.sbin/procmap/procmap.c index ee61268b99f..dfe466584e6 100644 --- a/usr.sbin/procmap/procmap.c +++ b/usr.sbin/procmap/procmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: procmap.c,v 1.11 2004/02/23 04:34:31 tedu Exp $ */ +/* $OpenBSD: procmap.c,v 1.12 2004/02/23 19:48:40 tedu Exp $ */ /* $NetBSD: pmap.c,v 1.1 2002/09/01 20:32:44 atatat Exp $ */ /* @@ -105,7 +105,7 @@ void *kernel_floor; u_long nchash_addr, nchashtbl_addr, kernel_map_addr; int debug, verbose; int print_all, print_map, print_maps, print_solaris, print_ddb; -int rwx = VM_PROT_READ | VM_PROT_WRITE | VM_PROT_EXECUTE, heapfound; +int rwx = VM_PROT_READ | VM_PROT_WRITE | VM_PROT_EXECUTE; rlim_t maxssiz; struct kbit { @@ -368,13 +368,11 @@ process_map(kvm_t *kd, pid_t pid, struct kinfo_proc *proc) A(vm_map_entry) = 0; if (pid > 0) { - heapfound = 0; A(vmspace) = (u_long)proc->kp_proc.p_vmspace; S(vmspace) = sizeof(struct vmspace); KDEREF(kd, vmspace); thing = "proc->p_vmspace.vm_map"; } else { - heapfound = 1; /* but really, do kernels have a heap? */ A(vmspace) = 0; S(vmspace) = 0; thing = "kernel_map"; @@ -779,7 +777,7 @@ findname(kvm_t *kd, struct kbit *vmspace, if (UVM_ET_ISOBJ(vme)) { if (A(vfs)) { - l = (unsigned)strlen(D(vfs, mount)->mnt_stat.f_mntonname); + l = strlen(D(vfs, mount)->mnt_stat.f_mntonname); switch (search_cache(kd, vp, &name, buf, sizeof(buf))) { case 0: /* found something */ name--; @@ -835,9 +833,10 @@ findname(kvm_t *kd, struct kbit *vmspace, (D(vmspace, vmspace)->vm_maxsaddr + (size_t)maxssiz) >= (caddr_t)vme->end) { name = " [ stack ]"; - } else if ((vme->protection & rwx) == rwx && !heapfound) { - /* XXX this could probably be done better */ - heapfound = 1; + } else if (D(vmspace, vmspace)->vm_daddr <= (caddr_t)vme->start && + D(vmspace, vmspace)->vm_daddr + MAXDSIZ >= (caddr_t)vme->end && + D(vmspace, vmspace)->vm_dsize * getpagesize() / 2 < + (vme->end - vme->start)) { name = " [ heap ]"; } else name = " [ anon ]"; |