mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-23 22:46:16 +02:00
makeDebugTraceStacker
This commit is contained in:
parent
1bda6a01e1
commit
deb1fd66e8
1 changed files with 31 additions and 62 deletions
|
@ -49,10 +49,8 @@ class DebugTraceStacker {
|
||||||
// assert(evalState.debugTraces.front() == trace);
|
// assert(evalState.debugTraces.front() == trace);
|
||||||
evalState.debugTraces.pop_front();
|
evalState.debugTraces.pop_front();
|
||||||
}
|
}
|
||||||
|
|
||||||
EvalState &evalState;
|
EvalState &evalState;
|
||||||
Trace trace;
|
Trace trace;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static char * dupString(const char * s)
|
static char * dupString(const char * s)
|
||||||
|
@ -882,8 +880,7 @@ LocalNoInlineNoReturn(void throwUndefinedVarError(const Pos & pos, const char *
|
||||||
});
|
});
|
||||||
|
|
||||||
if (debuggerHook && expr) {
|
if (debuggerHook && expr) {
|
||||||
|
std::cout << "throwUndefinedVarError debuggerHook" << std::endl;
|
||||||
std::cout << "throwUndefinedVarError debuggerHook" << std::endl;
|
|
||||||
debuggerHook(error, env, *expr);
|
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);
|
e.addTrace(pos, s, s2);
|
||||||
}
|
}
|
||||||
|
|
||||||
// LocalNoInline(void makeErrorTrace(Error & e, const char * s, const string & s2))
|
LocalNoInline(std::unique_ptr<DebugTraceStacker>
|
||||||
// {
|
makeDebugTraceStacker(EvalState &state, std::optional<ErrPos> pos, const char * s, const string & s2))
|
||||||
// Trace { .pos = e, .hint = hint }
|
{
|
||||||
// }
|
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)
|
void mkString(Value & v, const char * s)
|
||||||
{
|
{
|
||||||
|
@ -1127,20 +1126,6 @@ void EvalState::resetFileCache()
|
||||||
fileParseCache.clear();
|
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;
|
fileParseCache[resolvedPath] = e;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
std::unique_ptr<DebugTraceStacker> dts = debuggerHook ?
|
std::unique_ptr<DebugTraceStacker> dts =
|
||||||
std::unique_ptr<DebugTraceStacker>(new DebugTraceStacker(*this,
|
debuggerHook ?
|
||||||
Trace { .pos = (e->getPos() ? std::optional(ErrPos(*e->getPos())) : std::nullopt),
|
makeDebugTraceStacker(
|
||||||
.hint = hintfmt("while evaluating the file '%1%':", resolvedPath)
|
*this,
|
||||||
}
|
(e->getPos() ? std::optional(ErrPos(*e->getPos())) : std::nullopt),
|
||||||
)) : std::unique_ptr<DebugTraceStacker>();
|
"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
|
// Enforce that 'flake.nix' is a direct attrset, not a
|
||||||
// computation.
|
// computation.
|
||||||
if (mustBeTrivial &&
|
if (mustBeTrivial &&
|
||||||
|
@ -1389,14 +1373,11 @@ void ExprSelect::eval(EvalState & state, Env & env, Value & v)
|
||||||
try {
|
try {
|
||||||
std::unique_ptr<DebugTraceStacker> dts =
|
std::unique_ptr<DebugTraceStacker> dts =
|
||||||
debuggerHook ?
|
debuggerHook ?
|
||||||
std::unique_ptr<DebugTraceStacker>(
|
makeDebugTraceStacker(
|
||||||
new DebugTraceStacker(
|
state,
|
||||||
state,
|
*pos2,
|
||||||
Trace { .pos = *pos2,
|
"while evaluating the attribute '%1%'",
|
||||||
.hint = hintfmt(
|
showAttrPath(state, env, attrPath))
|
||||||
"while evaluating the attribute '%1%'",
|
|
||||||
showAttrPath(state, env, attrPath))
|
|
||||||
}))
|
|
||||||
: std::unique_ptr<DebugTraceStacker>();
|
: std::unique_ptr<DebugTraceStacker>();
|
||||||
|
|
||||||
for (auto & i : attrPath) {
|
for (auto & i : attrPath) {
|
||||||
|
@ -1543,19 +1524,13 @@ void EvalState::callFunction(Value & fun, size_t nrArgs, Value * * args, Value &
|
||||||
try {
|
try {
|
||||||
std::unique_ptr<DebugTraceStacker> dts =
|
std::unique_ptr<DebugTraceStacker> dts =
|
||||||
debuggerHook ?
|
debuggerHook ?
|
||||||
std::unique_ptr<DebugTraceStacker>(
|
makeDebugTraceStacker(*this, lambda.pos,
|
||||||
new DebugTraceStacker(
|
|
||||||
*this,
|
|
||||||
Trace {.pos = lambda.pos,
|
|
||||||
.hint = hintfmt(
|
|
||||||
"while evaluating %s",
|
"while evaluating %s",
|
||||||
(lambda.name.set()
|
(lambda.name.set()
|
||||||
? "'" + (string) lambda.name + "'"
|
? "'" + (string) lambda.name + "'"
|
||||||
: "anonymous lambda"))
|
: "anonymous lambda"))
|
||||||
}))
|
|
||||||
: std::unique_ptr<DebugTraceStacker>();
|
: std::unique_ptr<DebugTraceStacker>();
|
||||||
|
|
||||||
|
|
||||||
lambda.body->eval(*this, env2, vCur);
|
lambda.body->eval(*this, env2, vCur);
|
||||||
} catch (Error & e) {
|
} catch (Error & e) {
|
||||||
std::cout << "eval showErrorInfo showTrace: " << loggerSettings.showTrace.get() << std::endl;
|
std::cout << "eval showErrorInfo showTrace: " << loggerSettings.showTrace.get() << std::endl;
|
||||||
|
@ -1952,16 +1927,10 @@ void EvalState::forceValueDeep(Value & v)
|
||||||
try {
|
try {
|
||||||
std::unique_ptr<DebugTraceStacker> dts =
|
std::unique_ptr<DebugTraceStacker> dts =
|
||||||
debuggerHook ?
|
debuggerHook ?
|
||||||
std::unique_ptr<DebugTraceStacker>(
|
makeDebugTraceStacker(*this, *i.pos,
|
||||||
new DebugTraceStacker(
|
|
||||||
*this,
|
|
||||||
Trace { .pos = *i.pos,
|
|
||||||
.hint = hintfmt(
|
|
||||||
"while evaluating the attribute '%1%'", i.name)
|
"while evaluating the attribute '%1%'", i.name)
|
||||||
}))
|
|
||||||
: std::unique_ptr<DebugTraceStacker>();
|
: std::unique_ptr<DebugTraceStacker>();
|
||||||
|
|
||||||
|
|
||||||
recurse(*i.value);
|
recurse(*i.value);
|
||||||
} catch (Error & e) {
|
} catch (Error & e) {
|
||||||
addErrorTrace(e, *i.pos, "while evaluating the attribute '%1%'", i.name);
|
addErrorTrace(e, *i.pos, "while evaluating the attribute '%1%'", i.name);
|
||||||
|
|
Loading…
Reference in a new issue