diff options
| author | gingerBill <bill@gingerbill.org> | 2024-04-28 12:52:02 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2024-04-28 12:52:02 +0100 |
| commit | 5ac8e8f9fd6d2e749edd7bf37c28d7439ed4e840 (patch) | |
| tree | f86e703e2428a4acd36453e3c2f7ea4f9b890087 /core/debug | |
| parent | 2eea06fc73ea7abc1432a2ad368d0fe032f5ba6f (diff) | |
Add doc.odin
Diffstat (limited to 'core/debug')
| -rw-r--r-- | core/debug/trace/doc.odin | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/core/debug/trace/doc.odin b/core/debug/trace/doc.odin new file mode 100644 index 000000000..8c0778558 --- /dev/null +++ b/core/debug/trace/doc.odin @@ -0,0 +1,50 @@ +/* +A debug stack trace library. Only works when debug symbols are enabled `-debug`. + +Example: + import "base:runtime" + import "core:debug/trace" + + import "core:fmt" + + global_trace_ctx: trace.Context + + debug_trace_assertion_failure_proc :: proc(prefix, message: string, loc := #caller_location) -> ! { + runtime.print_caller_location(loc) + runtime.print_string(" ") + runtime.print_string(prefix) + if len(message) > 0 { + runtime.print_string(": ") + runtime.print_string(message) + } + runtime.print_byte('\n') + + ctx := &global_trace_ctx + if !trace.in_resolve(ctx) { + runtime.print_string("Debug Trace:\n") + frames := trace.frames(ctx, skip=1, allocator=context.temp_allocator) + for f, i in frames { + fl := trace.resolve(ctx, f, context.temp_allocator) + if fl.loc.file_path == "" && fl.loc.line == 0 { + continue + } + runtime.print_caller_location(fl.loc) + runtime.print_string(" - frame ") + runtime.print_int(i) + runtime.print_byte('\n') + } + } + runtime.trap() + } + + main :: proc() { + trace.init(&global_trace_ctx) + defer trace.destroy(&global_trace_ctx) + + context.assertion_failure_proc = debug_trace_assertion_failure_proc + + ... + } + +*/ +package debug_trace
\ No newline at end of file |