mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-23 14:36:16 +02:00
add DebugTrace for the current error
This commit is contained in:
parent
6801a423fc
commit
9760fa8661
5 changed files with 30 additions and 19 deletions
|
@ -84,7 +84,7 @@ ref<EvalState> EvalCommand::getEvalState()
|
|||
if (expr.staticenv)
|
||||
{
|
||||
auto vm = mapStaticEnvBindings(*expr.staticenv.get(), env);
|
||||
runRepl(evalState, &error, *vm);
|
||||
runRepl(evalState, &error, expr, *vm);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -312,8 +312,10 @@ void printClosureDiff(
|
|||
const StorePath & afterPath,
|
||||
std::string_view indent);
|
||||
|
||||
|
||||
void runRepl(
|
||||
ref<EvalState> evalState,
|
||||
const Error *debugError,
|
||||
const Expr &expr,
|
||||
const std::map<std::string, Value *> & extraEnv);
|
||||
}
|
||||
|
|
|
@ -897,6 +897,7 @@ std::ostream & NixRepl::printValue(std::ostream & str, Value & v, unsigned int m
|
|||
void runRepl(
|
||||
ref<EvalState> evalState,
|
||||
const Error *debugError,
|
||||
const Expr &expr,
|
||||
const std::map<std::string, Value *> & extraEnv)
|
||||
{
|
||||
auto repl = std::make_unique<NixRepl>(evalState);
|
||||
|
@ -905,6 +906,15 @@ void runRepl(
|
|||
|
||||
repl->initEnv();
|
||||
|
||||
// tack on a final DebugTrace for the error position.
|
||||
DebugTraceStacker ldts(
|
||||
*evalState,
|
||||
DebugTrace
|
||||
{.pos = debugError->info().errPos,
|
||||
.expr = expr,
|
||||
.hint = debugError->info().msg
|
||||
});
|
||||
|
||||
// add 'extra' vars.
|
||||
std::set<std::string> names;
|
||||
for (auto & [name, value] : extraEnv) {
|
||||
|
|
|
@ -38,21 +38,6 @@ namespace nix {
|
|||
|
||||
std::function<void(const Error & error, const Env & env, const Expr & expr)> debuggerHook;
|
||||
|
||||
class DebugTraceStacker {
|
||||
public:
|
||||
DebugTraceStacker(EvalState &evalState, DebugTrace t)
|
||||
:evalState(evalState), trace(t)
|
||||
{
|
||||
evalState.debugTraces.push_front(t);
|
||||
}
|
||||
~DebugTraceStacker() {
|
||||
// assert(evalState.debugTraces.front() == trace);
|
||||
evalState.debugTraces.pop_front();
|
||||
}
|
||||
EvalState &evalState;
|
||||
DebugTrace trace;
|
||||
};
|
||||
|
||||
static char * dupString(const char * s)
|
||||
{
|
||||
char * t;
|
||||
|
@ -701,7 +686,7 @@ void printStaticEnvBindings(const StaticEnv &se, int lvl)
|
|||
std::cout << std::endl;
|
||||
|
||||
if (se.up) {
|
||||
printStaticEnvBindings(*se.up, ++lvl);
|
||||
printStaticEnvBindings(*se.up, ++lvl);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -76,11 +76,10 @@ std::shared_ptr<RegexCache> makeRegexCache();
|
|||
|
||||
struct DebugTrace {
|
||||
std::optional<ErrPos> pos;
|
||||
Expr &expr;
|
||||
const Expr &expr;
|
||||
hintformat hint;
|
||||
};
|
||||
|
||||
|
||||
class EvalState
|
||||
{
|
||||
public:
|
||||
|
@ -406,6 +405,21 @@ private:
|
|||
friend void prim_match(EvalState & state, const Pos & pos, Value * * args, Value & v);
|
||||
};
|
||||
|
||||
class DebugTraceStacker {
|
||||
public:
|
||||
DebugTraceStacker(EvalState &evalState, DebugTrace t)
|
||||
:evalState(evalState), trace(t)
|
||||
{
|
||||
evalState.debugTraces.push_front(t);
|
||||
}
|
||||
~DebugTraceStacker()
|
||||
{
|
||||
// assert(evalState.debugTraces.front() == trace);
|
||||
evalState.debugTraces.pop_front();
|
||||
}
|
||||
EvalState &evalState;
|
||||
DebugTrace trace;
|
||||
};
|
||||
|
||||
/* Return a string representing the type of the value `v'. */
|
||||
string showType(ValueType type);
|
||||
|
|
Loading…
Reference in a new issue