Dump the current call stack to a string.
95 {
97 fl::string
result =
"Stack trace (depth ";
98
99 char depth_str[32];
100 fl::sprintf(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::sprintf(line_buf,
" [%zu] %s(%d)\n", (
size_t)i, entry.function, entry.line);
126 } else {
127 fl::sprintf(line_buf,
" [%zu] %s\n", (
size_t)i, entry.function);
128 }
130 }
131
133}
static TraceStorage & getTraceStorage() FL_NOEXCEPT
int sprintf(char(&buffer)[N], const char *format, const Args &... args) FL_NOEXCEPT
Sprintf-like formatting function that writes to a buffer.
expected< T, E > result
Alias for expected (Rust-style naming)
#define FL_STACK_TRACE_MAX_DEPTH