makeDebugTraceStacker
This commit is contained in:
parent
1bda6a01e1
commit
deb1fd66e8
|
@ -49,10 +49,8 @@ class DebugTraceStacker {
|
|||
// assert(evalState.debugTraces.front() == trace);
|
||||
evalState.debugTraces.pop_front();
|
||||
}
|
||||
|
||||
EvalState &evalState;
|
||||
Trace trace;
|
||||
|
||||
};
|
||||
|
||||
static char * dupString(const char * s)
|
||||
|
@ -882,7 +880,6 @@ LocalNoInlineNoReturn(void throwUndefinedVarError(const Pos & pos, const char *
|
|||
});
|
||||
|
||||
if (debuggerHook && expr) {
|
||||
|
||||
std::cout << "throwUndefinedVarError debuggerHook" << std::endl;
|
||||
debuggerHook(error, env, *expr);
|
||||
}
|
||||
|
@ -913,15 +910,17 @@ LocalNoInline(void addErrorTrace(Error & e, const Pos & pos, const char * s, con
|
|||
e.addTrace(pos, s, s2);
|
||||
}
|
||||
|
||||
// LocalNoInline(void makeErrorTrace(Error & e, const char * s, const string & s2))
|
||||
// {
|
||||
// Trace { .pos = e, .hint = hint }
|
||||
// }
|
||||
LocalNoInline(std::unique_ptr<DebugTraceStacker>
|
||||
makeDebugTraceStacker(EvalState &state, std::optional<ErrPos> pos, const char * s, const string & s2))
|
||||
{
|
||||
return std::unique_ptr<DebugTraceStacker>(
|
||||
new DebugTraceStacker(
|
||||
state,
|
||||
Trace {.pos = pos,
|
||||
.hint = hintfmt(s, s2)
|
||||
}));
|
||||
}
|
||||
|
||||
// LocalNoInline(void makeErrorTrace(Error & e, const Pos & pos, const char * s, const string & s2))
|
||||
// {
|
||||
// return Trace { .pos = e, .hint = hintfmt(s, s2); };
|
||||
// }
|
||||
|
||||
void mkString(Value & v, const char * s)
|
||||
{
|
||||
|
@ -1127,20 +1126,6 @@ void EvalState::resetFileCache()
|
|||
fileParseCache.clear();
|
||||
}
|
||||
|
||||
// class DebugTraceStacker {
|
||||
// DebugTraceStacker(std::ref<EvalState> evalState, std::ref<Trace> t)
|
||||
// :evalState(evalState), trace(t)
|
||||
// {
|
||||
// evalState->debugTraces.push_front(t);
|
||||
// }
|
||||
// ~DebugTraceStacker() {
|
||||
// assert(evalState->debugTraces.pop_front() == trace);
|
||||
// }
|
||||
|
||||
// std::ref<EvalState> evalState;
|
||||
// std::ref<Trace> trace;
|
||||
|
||||
// };
|
||||
|
||||
|
||||
|
||||
|
@ -1154,15 +1139,14 @@ void EvalState::cacheFile(
|
|||
fileParseCache[resolvedPath] = e;
|
||||
|
||||
try {
|
||||
std::unique_ptr<DebugTraceStacker> dts = debuggerHook ?
|
||||
std::unique_ptr<DebugTraceStacker>(new DebugTraceStacker(*this,
|
||||
Trace { .pos = (e->getPos() ? std::optional(ErrPos(*e->getPos())) : std::nullopt),
|
||||
.hint = hintfmt("while evaluating the file '%1%':", resolvedPath)
|
||||
}
|
||||
)) : std::unique_ptr<DebugTraceStacker>();
|
||||
std::unique_ptr<DebugTraceStacker> dts =
|
||||
debuggerHook ?
|
||||
makeDebugTraceStacker(
|
||||
*this,
|
||||
(e->getPos() ? std::optional(ErrPos(*e->getPos())) : std::nullopt),
|
||||
"while evaluating the file '%1%':", resolvedPath)
|
||||
: std::unique_ptr<DebugTraceStacker>();
|
||||
|
||||
// Trace( .pos = (e->getPos() ? std::optional(ErrPos(*e->getPos())):
|
||||
// std::nullopt), hintfmt("while evaluating the file '%1%':", resolvedPath));
|
||||
// Enforce that 'flake.nix' is a direct attrset, not a
|
||||
// computation.
|
||||
if (mustBeTrivial &&
|
||||
|
@ -1389,14 +1373,11 @@ void ExprSelect::eval(EvalState & state, Env & env, Value & v)
|
|||
try {
|
||||
std::unique_ptr<DebugTraceStacker> dts =
|
||||
debuggerHook ?
|
||||
std::unique_ptr<DebugTraceStacker>(
|
||||
new DebugTraceStacker(
|
||||
makeDebugTraceStacker(
|
||||
state,
|
||||
Trace { .pos = *pos2,
|
||||
.hint = hintfmt(
|
||||
*pos2,
|
||||
"while evaluating the attribute '%1%'",
|
||||
showAttrPath(state, env, attrPath))
|
||||
}))
|
||||
: std::unique_ptr<DebugTraceStacker>();
|
||||
|
||||
for (auto & i : attrPath) {
|
||||
|
@ -1543,19 +1524,13 @@ void EvalState::callFunction(Value & fun, size_t nrArgs, Value * * args, Value &
|
|||
try {
|
||||
std::unique_ptr<DebugTraceStacker> dts =
|
||||
debuggerHook ?
|
||||
std::unique_ptr<DebugTraceStacker>(
|
||||
new DebugTraceStacker(
|
||||
*this,
|
||||
Trace {.pos = lambda.pos,
|
||||
.hint = hintfmt(
|
||||
makeDebugTraceStacker(*this, lambda.pos,
|
||||
"while evaluating %s",
|
||||
(lambda.name.set()
|
||||
? "'" + (string) lambda.name + "'"
|
||||
: "anonymous lambda"))
|
||||
}))
|
||||
: std::unique_ptr<DebugTraceStacker>();
|
||||
|
||||
|
||||
lambda.body->eval(*this, env2, vCur);
|
||||
} catch (Error & e) {
|
||||
std::cout << "eval showErrorInfo showTrace: " << loggerSettings.showTrace.get() << std::endl;
|
||||
|
@ -1952,16 +1927,10 @@ void EvalState::forceValueDeep(Value & v)
|
|||
try {
|
||||
std::unique_ptr<DebugTraceStacker> dts =
|
||||
debuggerHook ?
|
||||
std::unique_ptr<DebugTraceStacker>(
|
||||
new DebugTraceStacker(
|
||||
*this,
|
||||
Trace { .pos = *i.pos,
|
||||
.hint = hintfmt(
|
||||
makeDebugTraceStacker(*this, *i.pos,
|
||||
"while evaluating the attribute '%1%'", i.name)
|
||||
}))
|
||||
: std::unique_ptr<DebugTraceStacker>();
|
||||
|
||||
|
||||
recurse(*i.value);
|
||||
} catch (Error & e) {
|
||||
addErrorTrace(e, *i.pos, "while evaluating the attribute '%1%'", i.name);
|
||||
|
|
Loading…
Reference in a new issue