| 1 | /* @title: Debugging */ |
| 2 | #include <stdbool.h> |
| 3 | #include <stddef.h> |
| 4 | #include <stdint.h> |
| 5 | |
| 6 | #define STACK_TRACE_MAX_DEPTH 64 |
| 7 | |
| 8 | void debug_print_registers(); |
| 9 | |
| 10 | void debug_print_stack(); |
| 11 | |
| 12 | void debug_print_memory(void *addr, size_t size); |
| 13 | |
| 14 | void debug_print_stack_from(uint64_t *start, size_t max_scan); |
| 15 | |
| 16 | size_t stack_unwind(uint64_t frame, uint64_t *entries, size_t max); |
| 17 | void debug_print_stack_trace(const uint64_t *entries, size_t nr); |
| 18 | |
| 19 | const char *debug_symbolize(uint64_t addr, uint64_t *out_off); |
| 20 | const char *debug_line_for(uint64_t addr, uint32_t *out_line); |
| 21 | bool debug_syms_present(void); |
| 22 | |
| 23 | /* Unwinds from the caller's own frame */ |
| 24 | #define stack_trace_save(entries, max) \ |
| 25 | stack_unwind((uint64_t) __builtin_frame_address(0), (entries), (max)) |
| 26 | #pragma once |
| 27 | |