From 6801a423fc9abdfd2cb7307f2970553bcfad089d Mon Sep 17 00:00:00 2001 From: Ben Burdette Date: Mon, 27 Dec 2021 16:28:45 -0700 Subject: [PATCH] :d env --- src/libcmd/repl.cc | 26 +++++++++++++++----------- src/libexpr/eval.cc | 7 +++++-- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/libcmd/repl.cc b/src/libcmd/repl.cc index 188bf75e4..3948ede02 100644 --- a/src/libcmd/repl.cc +++ b/src/libcmd/repl.cc @@ -402,7 +402,6 @@ StorePath NixRepl::getDerivationPath(Value & v) { return drvPath; } - bool NixRepl::processLine(string line) { if (line == "") return true; @@ -441,7 +440,8 @@ bool NixRepl::processLine(string line) << " :doc Show documentation of a builtin function\n" << " :d Debug mode commands\n" << " :d stack Show call stack\n" - << " :d stack Detail for step N\n" + // << " :d stack Detail for stack level N\n" + << " :d env Show env stack\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") { - if (this->debugError) { - showErrorInfo(std::cout, debugError->info(), true); - } - else - { - notice("error information not available"); - } + if (this->debugError) { + showErrorInfo(std::cout, debugError->info(), true); + } + else + { + notice("error information not available"); + } } } diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc index d99e73471..f1e6cfdf2 100644 --- a/src/libexpr/eval.cc +++ b/src/libexpr/eval.cc @@ -691,10 +691,14 @@ std::optional EvalState::getDoc(Value & v) 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) { - std::cout << lvl << i->first << std::endl; + std::cout << i->first << " "; } + std::cout << std::endl; + std::cout << std::endl; if (se.up) { 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) { auto vm = new valmap();