1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2024-09-19 10:50:24 -04:00

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",
"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;

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());
else
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);
v = *args[1];
}