forked from lix-project/lix
add env to DebugTrace
This commit is contained in:
parent
84aeb74377
commit
c51b527c28
|
@ -927,6 +927,7 @@ void runRepl(
|
|||
DebugTrace
|
||||
{.pos = debugError->info().errPos,
|
||||
.expr = expr,
|
||||
.env = *repl->env,
|
||||
.hint = debugError->info().msg
|
||||
});
|
||||
|
||||
|
|
|
@ -913,7 +913,7 @@ LocalNoInline(void addErrorTrace(Error & e, const Pos & pos, const char * s, con
|
|||
}
|
||||
|
||||
LocalNoInline(std::unique_ptr<DebugTraceStacker>
|
||||
makeDebugTraceStacker(EvalState &state, Expr &expr, std::optional<ErrPos> pos, const char * s, const string & s2))
|
||||
makeDebugTraceStacker(EvalState &state, Expr &expr, Env &env, std::optional<ErrPos> pos, const char * s, const string & s2))
|
||||
{
|
||||
return std::unique_ptr<DebugTraceStacker>(
|
||||
new DebugTraceStacker(
|
||||
|
@ -921,6 +921,7 @@ LocalNoInline(std::unique_ptr<DebugTraceStacker>
|
|||
DebugTrace
|
||||
{.pos = pos,
|
||||
.expr = expr,
|
||||
.env = env,
|
||||
.hint = hintfmt(s, s2)
|
||||
}));
|
||||
}
|
||||
|
@ -1161,6 +1162,7 @@ void EvalState::cacheFile(
|
|||
makeDebugTraceStacker(
|
||||
*this,
|
||||
*e,
|
||||
this->baseEnv,
|
||||
(e->getPos() ? std::optional(ErrPos(*e->getPos())) : std::nullopt),
|
||||
"while evaluating the file '%1%':", resolvedPath)
|
||||
: nullptr;
|
||||
|
@ -1394,6 +1396,7 @@ void ExprSelect::eval(EvalState & state, Env & env, Value & v)
|
|||
makeDebugTraceStacker(
|
||||
state,
|
||||
*this,
|
||||
env,
|
||||
*pos2,
|
||||
"while evaluating the attribute '%1%'",
|
||||
showAttrPath(state, env, attrPath))
|
||||
|
@ -1543,7 +1546,7 @@ void EvalState::callFunction(Value & fun, size_t nrArgs, Value * * args, Value &
|
|||
try {
|
||||
auto dts =
|
||||
debuggerHook ?
|
||||
makeDebugTraceStacker(*this, *lambda.body, lambda.pos,
|
||||
makeDebugTraceStacker(*this, *lambda.body, env2, lambda.pos,
|
||||
"while evaluating %s",
|
||||
(lambda.name.set()
|
||||
? "'" + (string) lambda.name + "'"
|
||||
|
@ -1948,7 +1951,7 @@ void EvalState::forceValueDeep(Value & v)
|
|||
debuggerHook ?
|
||||
// if the value is a thunk, we're evaling. otherwise no trace necessary.
|
||||
(i.value->isThunk() ?
|
||||
makeDebugTraceStacker(*this, *v.thunk.expr, *i.pos,
|
||||
makeDebugTraceStacker(*this, *v.thunk.expr, *v.thunk.env, *i.pos,
|
||||
"while evaluating the attribute '%1%'", i.name)
|
||||
: nullptr)
|
||||
: nullptr;
|
||||
|
|
|
@ -77,6 +77,7 @@ std::shared_ptr<RegexCache> makeRegexCache();
|
|||
struct DebugTrace {
|
||||
std::optional<ErrPos> pos;
|
||||
const Expr &expr;
|
||||
const Env &env;
|
||||
hintformat hint;
|
||||
};
|
||||
|
||||
|
@ -203,7 +204,7 @@ public:
|
|||
trivial (i.e. doesn't require arbitrary computation). */
|
||||
void evalFile(const Path & path, Value & v, bool mustBeTrivial = false);
|
||||
|
||||
/* Like `cacheFile`, but with an already parsed expression. */
|
||||
/* Like `evalFile`, but with an already parsed expression. */
|
||||
void cacheFile(
|
||||
const Path & path,
|
||||
const Path & resolvedPath,
|
||||
|
@ -416,6 +417,9 @@ class DebugTraceStacker {
|
|||
DebugTraceStacker(EvalState &evalState, DebugTrace t)
|
||||
:evalState(evalState), trace(t)
|
||||
{
|
||||
|
||||
// evalState.debuggerHook(const Error & error, const Env & env, const Expr & expr);
|
||||
|
||||
evalState.debugTraces.push_front(t);
|
||||
}
|
||||
~DebugTraceStacker()
|
||||
|
|
Loading…
Reference in a new issue