Dump the current call stack to a string.
95 {
97 fl::string
result =
"Stack trace (depth ";
98
99 char depth_str[32];
100 fl::snprintf(depth_str,
sizeof(depth_str),
"%zu", (
size_t)storage.stackDepth);
103
104 if (storage.callStack.empty()) {
107 }
108
109
111 result +=
" <WARNING: Stack overflow - showing last ";
112 char max_str[32];
118 }
119
120
121 for (fl::size i = 0; i < storage.callStack.size(); ++i) {
122 const auto& entry = storage.callStack[i];
123 char line_buf[256];
124 if (entry.line > 0) {
125 fl::snprintf(line_buf,
sizeof(line_buf),
" [%zu] %s(%d)\n", (
size_t)i, entry.function, entry.line);
126 } else {
127 fl::snprintf(line_buf,
sizeof(line_buf),
" [%zu] %s\n", (
size_t)i, entry.function);
128 }
130 }
131
133}
static TraceStorage & getTraceStorage() FL_NO_EXCEPT
int snprintf(char *buffer, fl::size size, const char *format) FL_NO_EXCEPT
expected< T, E > result
Alias for expected (Rust-style naming)
#define FL_STACK_TRACE_MAX_DEPTH