ProcMapsFindByAddr
Description
Find the entry whose [start, end) range contains addr. Linear scan; for a few dozen mappings this is fine.
Success
Returns a pointer to the matching entry inside self.
Failure
Returns NULL if addr is not in any mapping.
Usage example (Cross-references)
Usage examples (Cross-references)
u64 addr = (u64)runtime_addr;
const ProcMapEntry *entry = ProcMapsFindByAddr(&self->maps, addr);
if (!entry || !entry->path || entry->path[0] == '\0')
return false; u64 addr = (u64)runtime_addr;
const ProcMapEntry *entry = ProcMapsFindByAddr(&self->maps, addr);
if (!entry || !entry->path || entry->path[0] == '\0') {
return false;- In
ProcMaps.c:260:
}
const ProcMapEntry *ProcMapsFindByAddr(const ProcMaps *self, u64 addr) {
if (!self)
return NULL;
// 0x5500 is inside the stale e2 range only — must be unreachable.
const ProcMapEntry *hit = ProcMapsFindByAddr(&pm, 0x5500);
bool ok = (hit == NULL);
// Sanity: live entries are still found at the right slots.
const ProcMapEntry *h0 = ProcMapsFindByAddr(&pm, 0x1500);
const ProcMapEntry *h1 = ProcMapsFindByAddr(&pm, 0x3500);
ok = ok && h0 != NULL && h0->start == 0x1000 && h1 != NULL && h1->start == 0x3000; // Sanity: live entries are still found at the right slots.
const ProcMapEntry *h0 = ProcMapsFindByAddr(&pm, 0x1500);
const ProcMapEntry *h1 = ProcMapsFindByAddr(&pm, 0x3500);
ok = ok && h0 != NULL && h0->start == 0x1000 && h1 != NULL && h1->start == 0x3000;- In
ProcMaps.c:53:
// mapping of the test binary itself.
u64 self_addr = (u64)&test_procmaps_find_self;
const ProcMapEntry *entry = ProcMapsFindByAddr(&maps, self_addr);
bool ok = entry != NULL && (entry->perms & PROC_MAP_PERM_EXEC) != 0;- In
ProcMaps.c:101:
u64 fn_addr = (u64)&pm2_marker_fn;
const ProcMapEntry *e = ProcMapsFindByAddr(&maps, fn_addr);
bool ok = e != NULL;- In
ProcMaps.c:130:
u64 stack_addr = (u64)&local;
const ProcMapEntry *e = ProcMapsFindByAddr(&maps, stack_addr);
bool ok = e != NULL;- In
ProcMaps.c:172:
if (ok) {
u64 start = region->start;
const ProcMapEntry *hit = ProcMapsFindByAddr(&maps, start);
// The start address must resolve, and to a region whose
// start is exactly that address.
- In
ProcMaps.c:211:
// end - 1 is the last byte inside the region: must resolve to it.
if (ok) {
const ProcMapEntry *last_in = ProcMapsFindByAddr(&maps, top->end - 1);
ok = last_in != NULL && last_in->end == top->end;
}- In
ProcMaps.c:216:
// end is one-past the top region and above all mappings: NULL.
if (ok) {
const ProcMapEntry *past = ProcMapsFindByAddr(&maps, top->end);
ok = past == NULL;
}- In
ProcMaps.c:242:
// Address 0 / a tiny address is never mapped in a normal process.
const ProcMapEntry *e = ProcMapsFindByAddr(&maps, (u64)0x1);
bool ok = e == NULL;- In
ProcMaps.c:280:
if (!inside) {
found_gap = true;
const ProcMapEntry *at_gap = ProcMapsFindByAddr(&maps, hole);
ok = at_gap == NULL;
}- In
ProcMaps.c:288:
// definitely-unmapped high canonical-hole address.
if (!found_gap) {
const ProcMapEntry *at = ProcMapsFindByAddr(&maps, (u64)0x0000800000000000ULL);
ok = at == NULL;
}
Last updated on