|
memory_arena
|
#include <pthread.h>#include <stdatomic.h>#include <stdbool.h>#include "arena.h"#include "arena_hooks.h"
Include dependency graph for arena_visualizer.h:
This graph shows which files directly or indirectly include this file:Go to the source code of this file.
Data Structures | |
| struct | s_arena_history_entry |
| Each ring-buffer event: error, step, normal or sub-alloc. More... | |
| struct | s_arena_visualizer |
| The main interactive visualizer. More... | |
Macros | |
| #define | MAX_HISTORY 200 |
| #define | MAX_LABEL_LEN 128 |
Typedefs | |
| typedef struct s_arena_history_entry | t_arena_history_entry |
| Each ring-buffer event: error, step, normal or sub-alloc. | |
| typedef struct s_arena_visualizer | t_arena_visualizer |
| The main interactive visualizer. | |
Functions | |
| void | arena_start_interactive_visualizer (t_arena_visualizer *vis, t_arena *arena) |
| Start the interactive session (blocks until user quits). | |
| void | arena_visualizer_allocation_hook (t_arena *arena, int id, void *ptr, size_t size, size_t offset, size_t wasted, const char *label) |
| The ring buffer hooks. | |
| void | arena_visualizer_enable_history_hook (t_arena_visualizer *vis, t_arena *arena) |
| Attach our allocation hook to an arena. | |
| void | arena_visualizer_error_callback (const char *msg, void *context) |
| void | draw_visualizer (t_arena_visualizer *vis) |
| void | step_message (t_arena_visualizer *vis, const char *msg) |
| int | wait_for_key (t_arena_visualizer *vis) |
| function that blocks reading keystrokes: | |
| struct s_arena_history_entry |
Each ring-buffer event: error, step, normal or sub-alloc.
Definition at line 25 of file arena_visualizer.h.
| Data Fields | ||
|---|---|---|
| bool | is_error | |
| bool | is_step | |
| bool | is_sub | |
| char | label[MAX_LABEL_LEN] | |
| size_t | offset | |
| size_t | size | |
| size_t | usage | |
| struct s_arena_visualizer |
The main interactive visualizer.
Definition at line 39 of file arena_visualizer.h.
Collaboration diagram for s_arena_visualizer:| Data Fields | ||
|---|---|---|
| t_arena * | arena | |
| t_arena_history_entry | history[MAX_HISTORY] | |
| atomic_size_t | history_count | |
| atomic_size_t | history_index | |
| pthread_mutex_t | lock | |
| struct ncplane * | main_plane | |
| struct notcurses * | nc | |
| bool | script_done | |
| int | scroll_offset | |
| #define MAX_HISTORY 200 |
Definition at line 11 of file arena_visualizer.h.
| #define MAX_LABEL_LEN 128 |
Definition at line 12 of file arena_visualizer.h.
| typedef struct s_arena_history_entry t_arena_history_entry |
Each ring-buffer event: error, step, normal or sub-alloc.
| typedef struct s_arena_visualizer t_arena_visualizer |
The main interactive visualizer.
| void arena_start_interactive_visualizer | ( | t_arena_visualizer * | vis, |
| t_arena * | arena | ||
| ) |
Start the interactive session (blocks until user quits).
The user can scroll the ring buffer with arrow keys, press 'n' to do next step, press 'q' to quit, etc.
Definition at line 257 of file arena_visualizer.c.
References s_arena_visualizer::arena, s_arena_visualizer::history_count, s_arena_visualizer::history_index, interactive_loop(), s_arena_visualizer::lock, s_arena_visualizer::main_plane, s_arena_visualizer::nc, s_arena_visualizer::script_done, and s_arena_visualizer::scroll_offset.
| void arena_visualizer_allocation_hook | ( | t_arena * | arena, |
| int | id, | ||
| void * | ptr, | ||
| size_t | size, | ||
| size_t | offset, | ||
| size_t | wasted, | ||
| const char * | label | ||
| ) |
The ring buffer hooks.
Definition at line 47 of file arena_visualizer.c.
References arena_used(), and vis_record_event().
| void arena_visualizer_enable_history_hook | ( | t_arena_visualizer * | vis, |
| t_arena * | arena | ||
| ) |
Attach our allocation hook to an arena.
Definition at line 250 of file arena_visualizer.c.
References arena_set_allocation_hook(), and arena_visualizer_allocation_hook().
| void arena_visualizer_error_callback | ( | const char * | msg, |
| void * | context | ||
| ) |
Definition at line 66 of file arena_visualizer.c.
References vis_record_event().
| void draw_visualizer | ( | t_arena_visualizer * | vis | ) |
Definition at line 89 of file arena_visualizer.c.
References s_arena_visualizer::arena, arena_peak(), arena_remaining(), arena_used(), draw_bar_to_plane(), s_arena_visualizer::history, s_arena_visualizer::history_count, s_arena_visualizer::history_index, s_arena_history_entry::is_error, s_arena_history_entry::is_step, s_arena_history_entry::is_sub, s_arena_history_entry::label, s_arena_visualizer::main_plane, MAX_HISTORY, s_arena_visualizer::nc, s_arena_history_entry::offset, s_arena_visualizer::scroll_offset, s_arena_history_entry::size, s_arena_history_entry::usage, and used.
| void step_message | ( | t_arena_visualizer * | vis, |
| const char * | msg | ||
| ) |
Definition at line 78 of file arena_visualizer.c.
References vis_record_event().
| int wait_for_key | ( | t_arena_visualizer * | vis | ) |
function that blocks reading keystrokes:
Definition at line 198 of file arena_visualizer.c.
References draw_visualizer(), s_arena_visualizer::nc, and s_arena_visualizer::scroll_offset.