aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBen Burdette <bburdette@protonmail.com>2022-03-28 15:28:59 -0600
committerBen Burdette <bburdette@protonmail.com>2022-03-28 15:28:59 -0600
commit5ab7bdf0b14199da8423a8f2e433b2d6beef1e69 (patch)
treee9af4ba55c6574a98d0bac7f3ddb7a12f46500cb /src
parent14f515544bf7ea3c894fbc21d1393e69aa115784 (diff)
load debug trace staticenv on 'show'
Diffstat (limited to 'src')
-rw-r--r--src/libcmd/repl.cc35
1 files changed, 22 insertions, 13 deletions
diff --git a/src/libcmd/repl.cc b/src/libcmd/repl.cc
index f0a8ef676..2e3a3b6df 100644
--- a/src/libcmd/repl.cc
+++ b/src/libcmd/repl.cc
@@ -78,6 +78,7 @@ struct NixRepl
void addVarToScope(const Symbol & name, Value & v);
Expr * parseString(string s);
void evalString(string s, Value & v);
+ void loadDebugTraceEnv(DebugTrace &dt);
typedef set<Value *> ValuesSeen;
std::ostream & printValue(std::ostream & str, Value & v, unsigned int maxDepth);
@@ -427,6 +428,25 @@ std::ostream& showDebugTrace(std::ostream &out, const DebugTrace &dt)
return out;
}
+void NixRepl::loadDebugTraceEnv(DebugTrace &dt)
+{
+ if (dt.expr.staticenv)
+ {
+ initEnv();
+
+ auto vm = std::make_unique<valmap>(*(mapStaticEnvBindings(*dt.expr.staticenv.get(), dt.env)));
+
+ // add staticenv vars.
+ for (auto & [name, value] : *(vm.get())) {
+ this->addVarToScope(this->state->symbols.create(name), *value);
+ }
+ }
+ else
+ {
+ initEnv();
+ }
+}
+
bool NixRepl::processLine(string line)
{
if (line == "") return true;
@@ -491,31 +511,18 @@ bool NixRepl::processLine(string line)
++iter, ++idx) {
if (idx == this->debugTraceIndex)
{
- // std::cout << "\n" << ANSI_BLUE << idx << ANSI_NORMAL << ": ";
printStaticEnvBindings(iter->expr);
break;
}
- // std::cout << "\n" << ANSI_BLUE << idx << ANSI_NORMAL << ": ";
- // showDebugTrace(std::cout, *iter);
}
-
- // auto iter = this->state->debugTraces.begin();
- // if (iter != this->state->debugTraces.end()) {
- // printStaticEnvBindings(iter->expr);
- // }
}
else if (arg.compare(0,4,"show") == 0) {
try {
// change the DebugTrace index.
debugTraceIndex = stoi(arg.substr(4));
-
- // std::cout << "idx: " << idx << std::endl;
- // debugTraceIndex = idx;
-
}
catch (...)
{
- debugTraceIndex = 0;
}
int idx = 0;
@@ -526,6 +533,8 @@ bool NixRepl::processLine(string line)
{
std::cout << "\n" << ANSI_BLUE << idx << ANSI_NORMAL << ": ";
showDebugTrace(std::cout, *iter);
+ printStaticEnvBindings(iter->expr);
+ loadDebugTraceEnv(*iter);
break;
}
// std::cout << "\n" << ANSI_BLUE << idx << ANSI_NORMAL << ": ";