mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-27 16:16:16 +02:00
add env to DebugTrace
This commit is contained in:
parent
84aeb74377
commit
c51b527c28
3 changed files with 12 additions and 4 deletions
|
@ -927,6 +927,7 @@ void runRepl(
|
||||||
DebugTrace
|
DebugTrace
|
||||||
{.pos = debugError->info().errPos,
|
{.pos = debugError->info().errPos,
|
||||||
.expr = expr,
|
.expr = expr,
|
||||||
|
.env = *repl->env,
|
||||||
.hint = debugError->info().msg
|
.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>
|
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>(
|
return std::unique_ptr<DebugTraceStacker>(
|
||||||
new DebugTraceStacker(
|
new DebugTraceStacker(
|
||||||
|
@ -921,6 +921,7 @@ LocalNoInline(std::unique_ptr<DebugTraceStacker>
|
||||||
DebugTrace
|
DebugTrace
|
||||||
{.pos = pos,
|
{.pos = pos,
|
||||||
.expr = expr,
|
.expr = expr,
|
||||||
|
.env = env,
|
||||||
.hint = hintfmt(s, s2)
|
.hint = hintfmt(s, s2)
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
@ -1161,6 +1162,7 @@ void EvalState::cacheFile(
|
||||||
makeDebugTraceStacker(
|
makeDebugTraceStacker(
|
||||||
*this,
|
*this,
|
||||||
*e,
|
*e,
|
||||||
|
this->baseEnv,
|
||||||
(e->getPos() ? std::optional(ErrPos(*e->getPos())) : std::nullopt),
|
(e->getPos() ? std::optional(ErrPos(*e->getPos())) : std::nullopt),
|
||||||
"while evaluating the file '%1%':", resolvedPath)
|
"while evaluating the file '%1%':", resolvedPath)
|
||||||
: nullptr;
|
: nullptr;
|
||||||
|
@ -1394,6 +1396,7 @@ void ExprSelect::eval(EvalState & state, Env & env, Value & v)
|
||||||
makeDebugTraceStacker(
|
makeDebugTraceStacker(
|
||||||
state,
|
state,
|
||||||
*this,
|
*this,
|
||||||
|
env,
|
||||||
*pos2,
|
*pos2,
|
||||||
"while evaluating the attribute '%1%'",
|
"while evaluating the attribute '%1%'",
|
||||||
showAttrPath(state, env, attrPath))
|
showAttrPath(state, env, attrPath))
|
||||||
|
@ -1543,7 +1546,7 @@ void EvalState::callFunction(Value & fun, size_t nrArgs, Value * * args, Value &
|
||||||
try {
|
try {
|
||||||
auto dts =
|
auto dts =
|
||||||
debuggerHook ?
|
debuggerHook ?
|
||||||
makeDebugTraceStacker(*this, *lambda.body, lambda.pos,
|
makeDebugTraceStacker(*this, *lambda.body, env2, lambda.pos,
|
||||||
"while evaluating %s",
|
"while evaluating %s",
|
||||||
(lambda.name.set()
|
(lambda.name.set()
|
||||||
? "'" + (string) lambda.name + "'"
|
? "'" + (string) lambda.name + "'"
|
||||||
|
@ -1948,7 +1951,7 @@ void EvalState::forceValueDeep(Value & v)
|
||||||
debuggerHook ?
|
debuggerHook ?
|
||||||
// if the value is a thunk, we're evaling. otherwise no trace necessary.
|
// if the value is a thunk, we're evaling. otherwise no trace necessary.
|
||||||
(i.value->isThunk() ?
|
(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)
|
"while evaluating the attribute '%1%'", i.name)
|
||||||
: nullptr)
|
: nullptr)
|
||||||
: nullptr;
|
: nullptr;
|
||||||
|
|
|
@ -77,6 +77,7 @@ std::shared_ptr<RegexCache> makeRegexCache();
|
||||||
struct DebugTrace {
|
struct DebugTrace {
|
||||||
std::optional<ErrPos> pos;
|
std::optional<ErrPos> pos;
|
||||||
const Expr &expr;
|
const Expr &expr;
|
||||||
|
const Env &env;
|
||||||
hintformat hint;
|
hintformat hint;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -203,7 +204,7 @@ public:
|
||||||
trivial (i.e. doesn't require arbitrary computation). */
|
trivial (i.e. doesn't require arbitrary computation). */
|
||||||
void evalFile(const Path & path, Value & v, bool mustBeTrivial = false);
|
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(
|
void cacheFile(
|
||||||
const Path & path,
|
const Path & path,
|
||||||
const Path & resolvedPath,
|
const Path & resolvedPath,
|
||||||
|
@ -416,6 +417,9 @@ class DebugTraceStacker {
|
||||||
DebugTraceStacker(EvalState &evalState, DebugTrace t)
|
DebugTraceStacker(EvalState &evalState, DebugTrace t)
|
||||||
:evalState(evalState), trace(t)
|
:evalState(evalState), trace(t)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// evalState.debuggerHook(const Error & error, const Env & env, const Expr & expr);
|
||||||
|
|
||||||
evalState.debugTraces.push_front(t);
|
evalState.debugTraces.push_front(t);
|
||||||
}
|
}
|
||||||
~DebugTraceStacker()
|
~DebugTraceStacker()
|
||||||
|
|
Loading…
Reference in a new issue