Enter debugger on builtins.trace with an option

This commit is contained in:
Rebecca Turner 2024-02-02 17:41:34 -08:00
parent 1ba9780cf5
commit 8b7eb7400b
No known key found for this signature in database
2 changed files with 7 additions and 0 deletions

View file

@ -127,6 +127,9 @@ struct EvalSettings : Config
Setting<unsigned int> maxCallDepth{this, 10000, "max-call-depth", Setting<unsigned int> maxCallDepth{this, 10000, "max-call-depth",
"The maximum function call depth to allow before erroring."}; "The maximum function call depth to allow before erroring."};
Setting<bool> builtinsTraceDebugger{this, false, "builtins-trace-debugger",
"Whether to enter the debugger on `builtins.trace` calls."};
}; };
extern EvalSettings evalSettings; extern EvalSettings evalSettings;

View file

@ -995,6 +995,10 @@ static void prim_trace(EvalState & state, const PosIdx pos, Value * * args, Valu
printError("trace: %1%", args[0]->string_view()); printError("trace: %1%", args[0]->string_view());
else else
printError("trace: %1%", ValuePrinter(state, *args[0])); printError("trace: %1%", ValuePrinter(state, *args[0]));
if (evalSettings.builtinsTraceDebugger && state.debugRepl && !state.debugTraces.empty()) {
const DebugTrace & last = state.debugTraces.front();
state.runDebugRepl(nullptr, last.env, last.expr);
}
state.forceValue(*args[1], pos); state.forceValue(*args[1], pos);
v = *args[1]; v = *args[1];
} }