diff --git a/doc/manual/rl-next/debugger-on-trace.md b/doc/manual/rl-next/debugger-on-trace.md index d4e55d59c..721928550 100644 --- a/doc/manual/rl-next/debugger-on-trace.md +++ b/doc/manual/rl-next/debugger-on-trace.md @@ -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 --- -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 the debug REPL. This is useful for determining where warnings are being emitted from. diff --git a/src/libexpr/eval-settings.hh b/src/libexpr/eval-settings.hh index 757daebc0..b5783d28f 100644 --- a/src/libexpr/eval-settings.hh +++ b/src/libexpr/eval-settings.hh @@ -128,8 +128,15 @@ struct EvalSettings : Config Setting maxCallDepth{this, 10000, "max-call-depth", "The maximum function call depth to allow before erroring."}; - Setting builtinsTraceDebugger{this, false, "builtins-trace-debugger", - "Whether to enter the debugger on `builtins.trace` calls."}; + Setting builtinsTraceDebugger{this, false, "debugger-on-trace", + 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; diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc index a24a2d018..0ee146359 100644 --- a/src/libexpr/primops.cc +++ b/src/libexpr/primops.cc @@ -1010,6 +1010,12 @@ static RegisterPrimOp primop_trace({ Evaluate *e1* and print its abstract syntax representation on standard error. Then return *e2*. This function is useful for 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, });