This commit is contained in:
Ben Burdette 2021-12-27 16:28:45 -07:00
parent 2a66c120e6
commit 6801a423fc
2 changed files with 20 additions and 13 deletions

View file

@ -402,7 +402,6 @@ StorePath NixRepl::getDerivationPath(Value & v) {
return drvPath; return drvPath;
} }
bool NixRepl::processLine(string line) bool NixRepl::processLine(string line)
{ {
if (line == "") return true; if (line == "") return true;
@ -441,7 +440,8 @@ bool NixRepl::processLine(string line)
<< " :doc <expr> Show documentation of a builtin function\n" << " :doc <expr> Show documentation of a builtin function\n"
<< " :d <cmd> Debug mode commands\n" << " :d <cmd> Debug mode commands\n"
<< " :d stack Show call stack\n" << " :d stack Show call stack\n"
<< " :d stack <int> Detail for step N\n" // << " :d stack <int> Detail for stack level N\n"
<< " :d env Show env stack\n"
<< " :d error Show current error\n"; << " :d error Show current error\n";
} }
@ -466,17 +466,21 @@ bool NixRepl::processLine(string line)
} }
} }
} }
} else if (arg == "env") {
std::cout << "env stack:" << std::endl;
auto iter = this->state->debugTraces.begin();
if (iter != this->state->debugTraces.end()) {
printStaticEnvBindings(iter->expr);
}
} }
else if (arg == "error") { else if (arg == "error") {
if (this->debugError) { if (this->debugError) {
showErrorInfo(std::cout, debugError->info(), true); showErrorInfo(std::cout, debugError->info(), true);
} }
else else
{ {
notice("error information not available"); notice("error information not available");
} }
} }
} }

View file

@ -691,10 +691,14 @@ std::optional<EvalState::Doc> EvalState::getDoc(Value & v)
void printStaticEnvBindings(const StaticEnv &se, int lvl) void printStaticEnvBindings(const StaticEnv &se, int lvl)
{ {
std::cout << "Env level " << lvl << std::endl;
for (auto i = se.vars.begin(); i != se.vars.end(); ++i) for (auto i = se.vars.begin(); i != se.vars.end(); ++i)
{ {
std::cout << lvl << i->first << std::endl; std::cout << i->first << " ";
} }
std::cout << std::endl;
std::cout << std::endl;
if (se.up) { if (se.up) {
printStaticEnvBindings(*se.up, ++lvl); printStaticEnvBindings(*se.up, ++lvl);
@ -730,7 +734,6 @@ void mapStaticEnvBindings(const StaticEnv &se, const Env &env, valmap & vm)
} }
} }
valmap * mapStaticEnvBindings(const StaticEnv &se, const Env &env) valmap * mapStaticEnvBindings(const StaticEnv &se, const Env &env)
{ {
auto vm = new valmap(); auto vm = new valmap();