Created
July 18, 2026 00:20
-
-
Save mlabbe/3ba516a832cfd93a1e050e3bf233ebdc to your computer and use it in GitHub Desktop.
arena trace logging
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| typedef struct { | |
| // set to one of the TRACE_RECORD_* | |
| unsigned int trace_record_type; | |
| // number of bytes from the beginning of the page this allocation took place | |
| // took place | |
| unsigned int arena_page_offset; | |
| // the page the arena came from, count from 0 | |
| unsigned int arena_page_number; | |
| // bytes in allocation | |
| size_t alloc_bytes; | |
| // if allocation orphans a pointer, such as when reallocing inside | |
| // of an arena, how many bytes were orphaned | |
| size_t orphaned_bytes; | |
| // address of now-orphaned memory | |
| void* orphaned_ptr; | |
| // stack addresses for the allocation | |
| void* stack_addresses[TRACE_MAX_STACK_SIZE]; | |
| unsigned int stack_address_count; | |
| // trailing bytes of padding after allocation before next allocation | |
| // (does not include jumping to the next page to fit an allocation) | |
| unsigned int padding_bytes; | |
| // the actual address of the allocation (or free, if trace_record_type is a free) | |
| const void* alloc_ptr; | |
| // pointer to the first arena in the chain | |
| const ftg_arena_t* arena_head; | |
| // number of elapsed nanoseconds since arena_trace_init called | |
| uint64_t elapsed_nanoseconds; | |
| // the frame number, or any step index that increases over time | |
| uint64_t frame_number; | |
| // name of the arena (ptr to arena_name_t record's name | |
| char arena_name[ARENA__MAX_STRLEN]; | |
| } arena_trace_record_t; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment