// allocator.
use core
+use runtime
#local
Allocation_Action_Strings := str.[
log(.Info, "Core", msg);
+ trace := runtime.info.get_stack_trace();
+ defer if trace do delete(&trace);
+ for trace {
+ log(.Info, "Core", tprintf("in {} ({}:{})", it.func_name, it.file, it.line));
+ }
+
return res;
}
package runtime.info
+
use runtime
+use core {alloc} // These can included because this file is only included in non-custom runtimes.
+
+//
+// This file contains the code for working with runtime stack traces.
+// The only function in this file is `get_stack_trace`, which returns
+// an array of stack nodes, allocated from the threads temporary allocator.
+// This is not the `context.temp_allocator`, because certain builtin in
+// allocators use `get_stack_trace`, and can accidentally cause infinite
+// recursion.
+//
Stack_Node :: struct {
file: str;
#if runtime.Stack_Trace_Enabled {
-get_stack_trace :: () -> [] &Stack_Node {
- trace: [..] &Stack_Node;
+get_stack_trace :: () -> [..] &Stack_Node {
+ trace := make([..] &Stack_Node, 8, alloc.temp_allocator);
walker := __stack_trace.prev;
while walker {