Changeset View
Changeset View
Standalone View
Standalone View
head/sys/dev/hwpmc/hwpmc_mod.c
Show First 20 Lines • Show All 1,878 Lines • ▼ Show 20 Lines | pmc_log_process_mappings(struct pmc_owner *po, struct proc *p) | ||||
fullpath = freepath = NULL; | fullpath = freepath = NULL; | ||||
if ((vm = vmspace_acquire_ref(p)) == NULL) | if ((vm = vmspace_acquire_ref(p)) == NULL) | ||||
return; | return; | ||||
map = &vm->vm_map; | map = &vm->vm_map; | ||||
vm_map_lock_read(map); | vm_map_lock_read(map); | ||||
for (entry = map->header.next; entry != &map->header; entry = entry->next) { | VM_MAP_ENTRY_FOREACH(entry, map) { | ||||
if (entry == NULL) { | if (entry == NULL) { | ||||
PMCDBG2(LOG,OPS,2, "hwpmc: vm_map entry unexpectedly " | PMCDBG2(LOG,OPS,2, "hwpmc: vm_map entry unexpectedly " | ||||
"NULL! pid=%d vm_map=%p\n", p->p_pid, map); | "NULL! pid=%d vm_map=%p\n", p->p_pid, map); | ||||
break; | break; | ||||
} | } | ||||
/* | /* | ||||
▲ Show 20 Lines • Show All 87 Lines • ▼ Show 20 Lines | VM_MAP_ENTRY_FOREACH(entry, map) { | ||||
/* | /* | ||||
* If our saved timestamp doesn't match, this means | * If our saved timestamp doesn't match, this means | ||||
* that the vm_map was modified out from under us and | * that the vm_map was modified out from under us and | ||||
* we can't trust our current "entry" pointer. Do a | * we can't trust our current "entry" pointer. Do a | ||||
* new lookup for this entry. If there is no entry | * new lookup for this entry. If there is no entry | ||||
* for this address range, vm_map_lookup_entry() will | * for this address range, vm_map_lookup_entry() will | ||||
* return the previous one, so we always want to go to | * return the previous one, so we always want to go to | ||||
* entry->next on the next loop iteration. | * the next entry on the next loop iteration. | ||||
* | * | ||||
* There is an edge condition here that can occur if | * There is an edge condition here that can occur if | ||||
* there is no entry at or before this address. In | * there is no entry at or before this address. In | ||||
* this situation, vm_map_lookup_entry returns | * this situation, vm_map_lookup_entry returns | ||||
* &map->header, which would cause our loop to abort | * &map->header, which would cause our loop to abort | ||||
* without processing the rest of the map. However, | * without processing the rest of the map. However, | ||||
* in practice this will never happen for process | * in practice this will never happen for process | ||||
* vm_map. This is because the executable's text | * vm_map. This is because the executable's text | ||||
▲ Show 20 Lines • Show All 3,970 Lines • Show Last 20 Lines |