diff options
author | eldritch horrors <pennae@lix.systems> | 2024-03-08 09:47:09 +0100 |
---|---|---|
committer | eldritch horrors <pennae@lix.systems> | 2024-03-09 10:17:26 -0700 |
commit | a9b813cc3bcf89f03de0db96fc2e88d1c83b8303 (patch) | |
tree | b64221dbd3b3461c57e90289cd0539bf96c860dd /src/libexpr | |
parent | f2e11ddce1ef76d9f653e0c32659d46ff7d6cafa (diff) |
Merge pull request #10066 from 9999years/print-all-frames
Do not skip any stack frames when `--show-trace` is given
(cherry picked from commit 0b47783d0a879875d558f0b56e49584f25ceb2d0)
Change-Id: Ia0f18266dbcf97543110110c655c219c7a3e3270
Diffstat (limited to 'src/libexpr')
-rw-r--r-- | src/libexpr/eval-error.cc | 14 | ||||
-rw-r--r-- | src/libexpr/eval-error.hh | 2 | ||||
-rw-r--r-- | src/libexpr/eval.cc | 15 | ||||
-rw-r--r-- | src/libexpr/eval.hh | 6 | ||||
-rw-r--r-- | src/libexpr/primops.cc | 7 |
5 files changed, 19 insertions, 25 deletions
diff --git a/src/libexpr/eval-error.cc b/src/libexpr/eval-error.cc index f4cdeec5c..8db03610b 100644 --- a/src/libexpr/eval-error.cc +++ b/src/libexpr/eval-error.cc @@ -28,15 +28,7 @@ template<class T> EvalErrorBuilder<T> & EvalErrorBuilder<T>::withTrace(PosIdx pos, const std::string_view text) { error.err.traces.push_front( - Trace{.pos = error.state.positions[pos], .hint = HintFmt(std::string(text)), .frame = false}); - return *this; -} - -template<class T> -EvalErrorBuilder<T> & EvalErrorBuilder<T>::withFrameTrace(PosIdx pos, const std::string_view text) -{ - error.err.traces.push_front( - Trace{.pos = error.state.positions[pos], .hint = HintFmt(std::string(text)), .frame = true}); + Trace{.pos = error.state.positions[pos], .hint = HintFmt(std::string(text))}); return *this; } @@ -63,9 +55,9 @@ EvalErrorBuilder<T> & EvalErrorBuilder<T>::withFrame(const Env & env, const Expr } template<class T> -EvalErrorBuilder<T> & EvalErrorBuilder<T>::addTrace(PosIdx pos, HintFmt hint, bool frame) +EvalErrorBuilder<T> & EvalErrorBuilder<T>::addTrace(PosIdx pos, HintFmt hint) { - error.addTrace(error.state.positions[pos], hint, frame); + error.addTrace(error.state.positions[pos], hint); return *this; } diff --git a/src/libexpr/eval-error.hh b/src/libexpr/eval-error.hh index 2bb607280..43e6718b0 100644 --- a/src/libexpr/eval-error.hh +++ b/src/libexpr/eval-error.hh @@ -90,7 +90,7 @@ public: [[nodiscard, gnu::noinline]] EvalErrorBuilder<T> & withFrame(const Env & e, const Expr & ex); - [[nodiscard, gnu::noinline]] EvalErrorBuilder<T> & addTrace(PosIdx pos, HintFmt hint, bool frame = false); + [[nodiscard, gnu::noinline]] EvalErrorBuilder<T> & addTrace(PosIdx pos, HintFmt hint); template<typename... Args> [[nodiscard, gnu::noinline]] EvalErrorBuilder<T> & diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc index e15781404..bb3e6f3bd 100644 --- a/src/libexpr/eval.cc +++ b/src/libexpr/eval.cc @@ -812,14 +812,16 @@ void EvalState::runDebugRepl(const Error * error, const Env & env, const Expr & } } -void EvalState::addErrorTrace(Error & e, const char * s, const std::string & s2) const +template<typename... Args> +void EvalState::addErrorTrace(Error & e, const Args & ... formatArgs) const { - e.addTrace(nullptr, s, s2); + e.addTrace(nullptr, HintFmt(formatArgs...)); } -void EvalState::addErrorTrace(Error & e, const PosIdx pos, const char * s, const std::string & s2, bool frame) const +template<typename... Args> +void EvalState::addErrorTrace(Error & e, const PosIdx pos, const Args & ... formatArgs) const { - e.addTrace(positions[pos], HintFmt(s, s2), frame); + e.addTrace(positions[pos], HintFmt(formatArgs...)); } template<typename... Args> @@ -1606,9 +1608,8 @@ void EvalState::callFunction(Value & fun, size_t nrArgs, Value * * args, Value & "while calling %s", lambda.name ? concatStrings("'", symbols[lambda.name], "'") - : "anonymous lambda", - true); - if (pos) addErrorTrace(e, pos, "from call site%s", "", true); + : "anonymous lambda"); + if (pos) addErrorTrace(e, pos, "from call site"); } throw; } diff --git a/src/libexpr/eval.hh b/src/libexpr/eval.hh index 5cdf34a47..d2d8140e9 100644 --- a/src/libexpr/eval.hh +++ b/src/libexpr/eval.hh @@ -434,10 +434,12 @@ public: std::string_view forceString(Value & v, NixStringContext & context, const PosIdx pos, std::string_view errorCtx); std::string_view forceStringNoCtx(Value & v, const PosIdx pos, std::string_view errorCtx); + template<typename... Args> [[gnu::noinline]] - void addErrorTrace(Error & e, const char * s, const std::string & s2) const; + void addErrorTrace(Error & e, const Args & ... formatArgs) const; + template<typename... Args> [[gnu::noinline]] - void addErrorTrace(Error & e, const PosIdx pos, const char * s, const std::string & s2, bool frame = false) const; + void addErrorTrace(Error & e, const PosIdx pos, const Args & ... formatArgs) const; public: /** diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc index b5b28efcd..83eccb818 100644 --- a/src/libexpr/primops.cc +++ b/src/libexpr/primops.cc @@ -805,7 +805,7 @@ static void prim_addErrorContext(EvalState & state, const PosIdx pos, Value * * auto message = state.coerceToString(pos, *args[0], context, "while evaluating the error message passed to builtins.addErrorContext", false, false).toOwned(); - e.addTrace(nullptr, HintFmt(message), true); + e.addTrace(nullptr, HintFmt(message)); throw; } } @@ -1069,7 +1069,7 @@ static void prim_derivationStrict(EvalState & state, const PosIdx pos, Value * * e.addTrace(nullptr, HintFmt( "while evaluating derivation '%s'\n" " whose name attribute is located at %s", - drvName, pos), true); + drvName, pos)); throw; } } @@ -1227,8 +1227,7 @@ drvName, Bindings * attrs, Value & v) } catch (Error & e) { e.addTrace(state.positions[i->pos], - HintFmt("while evaluating attribute '%1%' of derivation '%2%'", key, drvName), - true); + HintFmt("while evaluating attribute '%1%' of derivation '%2%'", key, drvName)); throw; } } |