Add documentation, rename to debugger-on-trace

This commit is contained in:
Rebecca Turner 2024-02-21 09:07:39 -08:00
parent 4440eb54e7
commit b111fba8cd
No known key found for this signature in database
3 changed files with 17 additions and 4 deletions

View File

@ -1,9 +1,9 @@
--- ---
synopsis: Enter the `--debugger` when `builtins.trace` is called if `builtins-trace-debugger` is set synopsis: Enter the `--debugger` when `builtins.trace` is called if `debugger-on-trace` is set
prs: 9914 prs: 9914
--- ---
If the `builtins-trace-debugger` option is set and `--debugger` is given, If the `debugger-on-trace` option is set and `--debugger` is given,
`builtins.trace` calls will behave similarly to `builtins.break` and will enter `builtins.trace` calls will behave similarly to `builtins.break` and will enter
the debug REPL. This is useful for determining where warnings are being emitted the debug REPL. This is useful for determining where warnings are being emitted
from. from.

View File

@ -128,8 +128,15 @@ 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", Setting<bool> builtinsTraceDebugger{this, false, "debugger-on-trace",
"Whether to enter the debugger on `builtins.trace` calls."}; R"(
If set to true and the `--debugger` flag is given,
[`builtins.trace`](@docroot@/language/builtins.md#builtins-trace) will
enter the debugger like
[`builtins.break`](@docroot@/language/builtins.md#builtins-break).
This is useful for debugging warnings in third-party Nix code.
)"};
}; };
extern EvalSettings evalSettings; extern EvalSettings evalSettings;

View File

@ -1010,6 +1010,12 @@ static RegisterPrimOp primop_trace({
Evaluate *e1* and print its abstract syntax representation on Evaluate *e1* and print its abstract syntax representation on
standard error. Then return *e2*. This function is useful for standard error. Then return *e2*. This function is useful for
debugging. debugging.
If the
[`debugger-on-trace`](@docroot@/command-ref/conf-file.md#conf-debugger-on-trace)
option is set to `true` and the `--debugger` flag is given, the
interactive debugger will be started when `trace` is called (like
[`break`](@docroot@/language/builtins.md#builtins-break)).
)", )",
.fun = prim_trace, .fun = prim_trace,
}); });