FormatStackTrace
Description
Resolve each frame to module!symbol+offset and append a multi- line trace to out. A fresh SymbolResolver is created internally for each call — convenient for one-off uses, but if you format many traces in a loop, share a resolver via FormatStackTraceWith.
Parameters
| Name | Direction | Description |
|---|---|---|
out |
out | Str to append to. |
frames |
in | Frames captured by CaptureStackTrace. |
count |
in | Number of valid frames. |
alloc |
in | Allocator backing the resolver and any scratch. |
Success
Output appended.
Failure
Function does not fail; unresolved frames emit as #N 0x<ip>.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Backtrace.c:32:
Str rendered = StrInit(alloc_base);
FormatStackTrace(&rendered, frames, n, alloc_base);
// We expect both helper names to appear in the rendered trace.
- In
Backtrace.c:79:
}
void FormatStackTrace(Str *out, const StackFrame *frames, size count, Allocator *alloc) {
(void)alloc;
if (!out || !frames)- In
Backtrace.c:209:
}
void FormatStackTrace(Str *out, const StackFrame *frames, size count, Allocator *alloc) {
if (!out || !frames || !alloc)
return;- In
Debug.c:160:
}
Str rendered = StrInit(meta);
FormatStackTrace(&rendered, frames, count, meta);
LOG_ERROR(" {} trace:\n{}", label, rendered);
StrDeinit(&rendered);- In
Debug.c:381:
StrWriteFmt(out, "leaked {x} ({} bytes)\n", (u64)(uintptr_t)user_p, (u64)rec->requested_size);
if (rec->alloc_trace_n) {
FormatStackTrace(out, rec->alloc_trace, rec->alloc_trace_n, self->meta);
}
}
Last updated on