Fix repeated REPT nodes in backtraces

This commit is contained in:
Rangi
2025-10-06 16:36:55 -04:00
parent 0c9920d4a6
commit fba0562650
11 changed files with 145 additions and 55 deletions

View File

@@ -11,6 +11,10 @@
#include "style.hpp"
#define TRACE_SEPARATOR "<-"
#define NODE_SEPARATOR "::"
#define REPT_NODE_PREFIX "REPT~"
struct Tracing {
uint64_t depth = 0;
bool collapse = false;
@@ -34,7 +38,7 @@ void trace_PrintBacktrace(std::vector<T> const &stack, M getName, N getLineNo) {
if (!tracing.collapse) {
fputs(" ", stderr); // Just three spaces; the fourth will be printed next
}
fprintf(stderr, " %s ", i == 0 ? "at" : "<-");
fprintf(stderr, " %s ", i == 0 ? "at" : TRACE_SEPARATOR);
style_Set(stderr, STYLE_CYAN, true);
fputs(getName(item), stderr);
style_Set(stderr, STYLE_CYAN, false);
@@ -62,7 +66,7 @@ void trace_PrintBacktrace(std::vector<T> const &stack, M getName, N getLineNo) {
style_Reset(stderr);
if (tracing.collapse) {
fputs(" <-", stderr);
fputs(" " TRACE_SEPARATOR, stderr);
} else {
fputs(" ", stderr); // Just three spaces; the fourth will be printed next
}