MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ptrace_vm_entry

Function ptrace_vm_entry

freebsd/kern/sys_process.c:337–447  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

335}
336
337static int
338ptrace_vm_entry(struct thread *td, struct proc *p, struct ptrace_vm_entry *pve)
339{
340 struct vattr vattr;
341 vm_map_t map;
342 vm_map_entry_t entry;
343 vm_object_t obj, tobj, lobj;
344 struct vmspace *vm;
345 struct vnode *vp;
346 char *freepath, *fullpath;
347 u_int pathlen;
348 int error, index;
349
350 error = 0;
351 obj = NULL;
352
353 vm = vmspace_acquire_ref(p);
354 map = &vm->vm_map;
355 vm_map_lock_read(map);
356
357 do {
358 KASSERT((map->header.eflags & MAP_ENTRY_IS_SUB_MAP) == 0,
359 ("Submap in map header"));
360 index = 0;
361 VM_MAP_ENTRY_FOREACH(entry, map) {
362 if (index >= pve->pve_entry &&
363 (entry->eflags & MAP_ENTRY_IS_SUB_MAP) == 0)
364 break;
365 index++;
366 }
367 if (index < pve->pve_entry) {
368 error = EINVAL;
369 break;
370 }
371 if (entry == &map->header) {
372 error = ENOENT;
373 break;
374 }
375
376 /* We got an entry. */
377 pve->pve_entry = index + 1;
378 pve->pve_timestamp = map->timestamp;
379 pve->pve_start = entry->start;
380 pve->pve_end = entry->end - 1;
381 pve->pve_offset = entry->offset;
382 pve->pve_prot = entry->protection;
383
384 /* Backing object's path needed? */
385 if (pve->pve_pathlen == 0)
386 break;
387
388 pathlen = pve->pve_pathlen;
389 pve->pve_pathlen = 0;
390
391 obj = entry->object.vm_object;
392 if (obj != NULL)
393 VM_OBJECT_RLOCK(obj);
394 } while (0);

Callers 1

kern_ptraceFunction · 0.70

Calls 10

vmspace_acquire_refFunction · 0.85
vm_object_vnodeFunction · 0.85
vn_lockFunction · 0.85
VOP_GETATTRFunction · 0.85
vputFunction · 0.85
vmspace_freeFunction · 0.85
vrefFunction · 0.70
vn_fullpathFunction · 0.70
freeFunction · 0.70
copyoutFunction · 0.50

Tested by

no test coverage detected