ProcMapsLoad
Description
Read and parse /proc/self/maps. The full file is held inside out->raw for the lifetime of the ProcMaps so each entry’s path can borrow from it without a separate copy.
Parameters
| Name | Direction | Description |
|---|---|---|
out |
out | Populated on success. |
alloc |
in | Allocator for the raw buffer and entries vector. |
Success
Returns true; out->entries is populated.
Failure
Returns false; logs the failing step. out is left zeroed.
Usage example (Cross-references)
Usage examples (Cross-references)
out->allocator = alloc;
out->cache = VecInitT(out->cache, alloc);
if (!ProcMapsLoad(&out->maps, alloc)) {
VecDeinit(&out->cache);
MemSet(out, 0, sizeof(*out));- In
ProcMaps.c:171:
bool proc_maps_load(ProcMaps *out, Allocator *alloc) {
if (!out || !alloc) {
LOG_FATAL("ProcMapsLoad: NULL argument");
}
MemSet(out, 0, sizeof(*out));- In
ProcMaps.c:182:
File f = FileOpen("/proc/self/maps", "rb");
if (!FileIsOpen(&f)) {
LOG_ERROR("ProcMapsLoad: FileOpen(/proc/self/maps) failed");
ProcMapsDeinit(out);
return false;- In
ProcMaps.c:193:
u64 grown_to = StrLen(&out->raw) + CHUNK + 1;
if (!StrReserve(&out->raw, grown_to)) {
LOG_ERROR("ProcMapsLoad: failed to grow buffer");
FileClose(&f);
ProcMapsDeinit(out);- In
ProcMaps.c:200:
i64 n = FileRead(&f, StrEnd(&out->raw), CHUNK);
if (n < 0) {
LOG_ERROR("ProcMapsLoad: FileRead failed");
FileClose(&f);
ProcMapsDeinit(out);- In
ProcMaps.c:216:
FileClose(&f);
if (StrLen(&out->raw) == 0) {
LOG_ERROR("ProcMapsLoad: /proc/self/maps was empty");
ProcMapsDeinit(out);
return false; ProcMaps maps;
bool got = false;
if (ProcMapsLoad(&maps, ALLOCATOR_OF(&a))) {
for (u64 i = 0; i < VecLen(&maps.entries); ++i) {
const ProcMapEntry *m = VecPtrAt(&maps.entries, i);- In
ProcMaps.c:17:
ProcMaps maps;
if (!ProcMapsLoad(&maps, ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
ProcMaps.c:45:
ProcMaps maps;
if (!ProcMapsLoad(&maps, ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
ProcMaps.c:73:
ProcMaps maps;
if (!ProcMapsLoad(&maps, ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
ProcMaps.c:95:
ProcMaps maps;
if (!ProcMapsLoad(&maps, ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
ProcMaps.c:124:
volatile int local = 0xABCD;
if (!ProcMapsLoad(&maps, ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
ProcMaps.c:153:
ProcMaps maps;
if (!ProcMapsLoad(&maps, ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
ProcMaps.c:192:
ProcMaps maps;
if (!ProcMapsLoad(&maps, ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
ProcMaps.c:236:
ProcMaps maps;
if (!ProcMapsLoad(&maps, ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
ProcMaps.c:258:
ProcMaps maps;
if (!ProcMapsLoad(&maps, ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
ProcMaps.c:340:
DefaultAllocator alloc = DefaultAllocatorInit();
ProcMaps maps;
if (!ProcMapsLoad(&maps, ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;
Last updated on