Factor out shared backtrace code (#1793)

This commit is contained in:
Rangi
2025-08-12 17:56:54 -04:00
committed by GitHub
parent 50d0b101c3
commit 9c3ce69180
14 changed files with 118 additions and 173 deletions

21
src/backtrace.cpp Normal file
View File

@@ -0,0 +1,21 @@
// SPDX-License-Identifier: MIT
#include "backtrace.hpp"
#include <stdlib.h> // strtoul
#include "platform.hpp" // strcasecmp
uint64_t traceDepth = 0;
bool trace_ParseTraceDepth(char const *arg) {
if (!strcasecmp(arg, "collapse")) {
traceDepth = TRACE_COLLAPSE;
return true;
}
char *endptr;
traceDepth = strtoul(arg, &endptr, 0);
return arg[0] != '\0' && *endptr == '\0' && traceDepth != TRACE_COLLAPSE;
}