diff options
author | Ben Burdette <bburdette@protonmail.com> | 2022-05-22 21:45:24 -0600 |
---|---|---|
committer | Ben Burdette <bburdette@protonmail.com> | 2022-05-22 21:45:24 -0600 |
commit | 13d02af0799f5d2f7a53825936d587e22edcacb6 (patch) | |
tree | 171eafe55521519d5b821aa7bec083cd2d1aa4ed /src | |
parent | 7ccb2700c0401c553631e07aeb49e08f976274a3 (diff) |
remove redundant 'debugMode' flag
Diffstat (limited to 'src')
-rw-r--r-- | src/libcmd/command.cc | 2 | ||||
-rw-r--r-- | src/libcmd/repl.cc | 14 | ||||
-rw-r--r-- | src/libexpr/eval.cc | 12 | ||||
-rw-r--r-- | src/libexpr/eval.hh | 6 | ||||
-rw-r--r-- | src/libexpr/nixexpr.cc | 38 | ||||
-rw-r--r-- | src/libexpr/primops.cc | 2 |
6 files changed, 35 insertions, 39 deletions
diff --git a/src/libcmd/command.cc b/src/libcmd/command.cc index c1d9eefc6..7f8072d75 100644 --- a/src/libcmd/command.cc +++ b/src/libcmd/command.cc @@ -119,8 +119,6 @@ ref<EvalState> EvalCommand::getEvalState() #endif ; - evalState->debugMode = startReplOnEvalErrors; - if (startReplOnEvalErrors) { evalState->debugRepl = &runRepl; }; diff --git a/src/libcmd/repl.cc b/src/libcmd/repl.cc index d335a56cd..940a287c7 100644 --- a/src/libcmd/repl.cc +++ b/src/libcmd/repl.cc @@ -280,7 +280,7 @@ void NixRepl::mainLoop(const std::vector<std::string> & files) // in debugger mode, an EvalError should trigger another repl session. // when that session returns the exception will land here. No need to show it again; // show the error for this repl session instead. - if (state.debugMode && !state.debugTraces.empty()) + if (state.debugRepl && !state.debugTraces.empty()) showDebugTrace(std::cout, state.positions, state.debugTraces.front()); else printMsg(lvlError, e.msg()); @@ -493,7 +493,7 @@ bool NixRepl::processLine(std::string line) << " :log <expr> Show logs for a derivation\n" << " :te [bool] Enable, disable or toggle showing traces for errors\n" ; - if (state.debugMode) { + if (state.debugRepl) { std::cout << "\n" << " Debug mode commands\n" @@ -508,14 +508,14 @@ bool NixRepl::processLine(std::string line) } - else if (state.debugMode && (command == ":bt" || command == ":backtrace")) { + else if (state.debugRepl && (command == ":bt" || command == ":backtrace")) { for (const auto & [idx, i] : enumerate(state.debugTraces)) { std::cout << "\n" << ANSI_BLUE << idx << ANSI_NORMAL << ": "; showDebugTrace(std::cout, state.positions, i); } } - else if (state.debugMode && (command == ":env")) { + else if (state.debugRepl && (command == ":env")) { for (const auto & [idx, i] : enumerate(state.debugTraces)) { if (idx == debugTraceIndex) { printEnvBindings(state, i.expr, i.env); @@ -524,7 +524,7 @@ bool NixRepl::processLine(std::string line) } } - else if (state.debugMode && (command == ":st")) { + else if (state.debugRepl && (command == ":st")) { try { // change the DebugTrace index. debugTraceIndex = stoi(arg); @@ -542,13 +542,13 @@ bool NixRepl::processLine(std::string line) } } - else if (state.debugMode && (command == ":s" || command == ":step")) { + else if (state.debugRepl && (command == ":s" || command == ":step")) { // set flag to stop at next DebugTrace; exit repl. state.debugStop = true; return false; } - else if (state.debugMode && (command == ":c" || command == ":continue")) { + else if (state.debugRepl && (command == ":c" || command == ":continue")) { // set flag to run to next breakpoint or end of program; exit repl. state.debugStop = false; return false; diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc index 5faecdbe3..c457df380 100644 --- a/src/libexpr/eval.cc +++ b/src/libexpr/eval.cc @@ -813,7 +813,7 @@ std::unique_ptr<ValMap> mapStaticEnvBindings(const SymbolTable & st, const Stati void EvalState::runDebugRepl(const Error * error, const Env & env, const Expr & expr) { - // double check we've got the debugRepl ftn pointer. + // double check we've got the debugRepl function pointer. if (!debugRepl) return; @@ -1073,7 +1073,7 @@ DebugTraceStacker::DebugTraceStacker(EvalState & evalState, DebugTrace t) , trace(std::move(t)) { evalState.debugTraces.push_front(trace); - if (evalState.debugStop && evalState.debugMode) + if (evalState.debugStop && evalState.debugRepl) evalState.runDebugRepl(nullptr, trace.env, trace.expr); } @@ -1271,7 +1271,7 @@ void EvalState::cacheFile( fileParseCache[resolvedPath] = e; try { - auto dts = debugMode + auto dts = debugRepl ? makeDebugTraceStacker( *this, *e, @@ -1505,7 +1505,7 @@ void ExprSelect::eval(EvalState & state, Env & env, Value & v) e->eval(state, env, vTmp); try { - auto dts = state.debugMode + auto dts = state.debugRepl ? makeDebugTraceStacker( state, *this, @@ -1674,7 +1674,7 @@ void EvalState::callFunction(Value & fun, size_t nrArgs, Value * * args, Value & /* Evaluate the body. */ try { - auto dts = debugMode + auto dts = debugRepl ? makeDebugTraceStacker( *this, *lambda.body, env2, positions[lambda.pos], "while evaluating %s", @@ -2102,7 +2102,7 @@ void EvalState::forceValueDeep(Value & v) for (auto & i : *v.attrs) try { // If the value is a thunk, we're evaling. Otherwise no trace necessary. - auto dts = debugMode && i.value->isThunk() + auto dts = debugRepl && i.value->isThunk() ? makeDebugTraceStacker(*this, *i.value->thunk.expr, *i.value->thunk.env, positions[i.pos], "while evaluating the attribute '%1%'", symbols[i.name]) : nullptr; diff --git a/src/libexpr/eval.hh b/src/libexpr/eval.hh index 90bd5497b..c86075ae3 100644 --- a/src/libexpr/eval.hh +++ b/src/libexpr/eval.hh @@ -128,8 +128,6 @@ public: /* Debugger */ void (* debugRepl)(EvalState & es, const ValMap & extraEnv); - - bool debugMode; bool debugStop; bool debugQuit; std::list<DebugTrace> debugTraces; @@ -149,7 +147,7 @@ public: [[gnu::noinline, gnu::noreturn]] void debugThrow(const E &error, const Env & env, const Expr & expr) { - if (debugMode) + if (debugRepl) runDebugRepl(&error, env, expr); throw error; @@ -162,7 +160,7 @@ public: // Call this in the situation where Expr and Env are inaccessible. // The debugger will start in the last context that's in the // DebugTrace stack. - if (debugMode && !debugTraces.empty()) { + if (debugRepl && !debugTraces.empty()) { const DebugTrace & last = debugTraces.front(); runDebugRepl(&e, last.env, last.expr); } diff --git a/src/libexpr/nixexpr.cc b/src/libexpr/nixexpr.cc index 52d48122c..7c623a07d 100644 --- a/src/libexpr/nixexpr.cc +++ b/src/libexpr/nixexpr.cc @@ -299,31 +299,31 @@ void Expr::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> & env void ExprInt::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> & env) { - if (es.debugMode) + if (es.debugRepl) es.exprEnvs.insert(std::make_pair(this, env)); } void ExprFloat::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> & env) { - if (es.debugMode) + if (es.debugRepl) es.exprEnvs.insert(std::make_pair(this, env)); } void ExprString::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> & env) { - if (es.debugMode) + if (es.debugRepl) es.exprEnvs.insert(std::make_pair(this, env)); } void ExprPath::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> & env) { - if (es.debugMode) + if (es.debugRepl) es.exprEnvs.insert(std::make_pair(this, env)); } void ExprVar::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> & env) { - if (es.debugMode) + if (es.debugRepl) es.exprEnvs.insert(std::make_pair(this, env)); /* Check whether the variable appears in the environment. If so, @@ -359,7 +359,7 @@ void ExprVar::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> & void ExprSelect::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> & env) { - if (es.debugMode) + if (es.debugRepl) es.exprEnvs.insert(std::make_pair(this, env)); e->bindVars(es, env); @@ -371,7 +371,7 @@ void ExprSelect::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> void ExprOpHasAttr::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> & env) { - if (es.debugMode) + if (es.debugRepl) es.exprEnvs.insert(std::make_pair(this, env)); e->bindVars(es, env); @@ -382,7 +382,7 @@ void ExprOpHasAttr::bindVars(EvalState & es, const std::shared_ptr<const StaticE void ExprAttrs::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> & env) { - if (es.debugMode) + if (es.debugRepl) es.exprEnvs.insert(std::make_pair(this, env)); if (recursive) { @@ -415,7 +415,7 @@ void ExprAttrs::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> void ExprList::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> & env) { - if (es.debugMode) + if (es.debugRepl) es.exprEnvs.insert(std::make_pair(this, env)); for (auto & i : elems) @@ -424,7 +424,7 @@ void ExprList::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> & void ExprLambda::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> & env) { - if (es.debugMode) + if (es.debugRepl) es.exprEnvs.insert(std::make_pair(this, env)); auto newEnv = std::make_shared<StaticEnv>( @@ -451,7 +451,7 @@ void ExprLambda::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> void ExprCall::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> & env) { - if (es.debugMode) + if (es.debugRepl) es.exprEnvs.insert(std::make_pair(this, env)); fun->bindVars(es, env); @@ -461,7 +461,7 @@ void ExprCall::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> & void ExprLet::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> & env) { - if (es.debugMode) + if (es.debugRepl) es.exprEnvs.insert(std::make_pair(this, env)); auto newEnv = std::make_shared<StaticEnv>(false, env.get(), attrs->attrs.size()); @@ -480,7 +480,7 @@ void ExprLet::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> & void ExprWith::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> & env) { - if (es.debugMode) + if (es.debugRepl) es.exprEnvs.insert(std::make_pair(this, env)); /* Does this `with' have an enclosing `with'? If so, record its @@ -495,7 +495,7 @@ void ExprWith::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> & break; } - if (es.debugMode) + if (es.debugRepl) es.exprEnvs.insert(std::make_pair(this, env)); attrs->bindVars(es, env); @@ -505,7 +505,7 @@ void ExprWith::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> & void ExprIf::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> & env) { - if (es.debugMode) + if (es.debugRepl) es.exprEnvs.insert(std::make_pair(this, env)); cond->bindVars(es, env); @@ -515,7 +515,7 @@ void ExprIf::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> & e void ExprAssert::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> & env) { - if (es.debugMode) + if (es.debugRepl) es.exprEnvs.insert(std::make_pair(this, env)); cond->bindVars(es, env); @@ -524,7 +524,7 @@ void ExprAssert::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> void ExprOpNot::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> & env) { - if (es.debugMode) + if (es.debugRepl) es.exprEnvs.insert(std::make_pair(this, env)); e->bindVars(es, env); @@ -532,7 +532,7 @@ void ExprOpNot::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> void ExprConcatStrings::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> & env) { - if (es.debugMode) + if (es.debugRepl) es.exprEnvs.insert(std::make_pair(this, env)); for (auto & i : *this->es) @@ -541,7 +541,7 @@ void ExprConcatStrings::bindVars(EvalState & es, const std::shared_ptr<const Sta void ExprPos::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> & env) { - if (es.debugMode) + if (es.debugRepl) es.exprEnvs.insert(std::make_pair(this, env)); } diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc index 60a70f336..b24d4c68a 100644 --- a/src/libexpr/primops.cc +++ b/src/libexpr/primops.cc @@ -757,7 +757,7 @@ static RegisterPrimOp primop_break({ )", .fun = [](EvalState & state, const PosIdx pos, Value * * args, Value & v) { - if (state.debugMode && !state.debugTraces.empty()) { + if (state.debugRepl && !state.debugTraces.empty()) { auto error = Error(ErrorInfo { .level = lvlInfo, .msg = hintfmt("breakpoint reached"), |