Merge pull request #9920 from 9999years/forbid-nested-debuggers
Forbid nested debuggers (cherry picked from commit e164b39ee90fd655dbb7f479fdd4fbe38cc883bd) Change-Id: Iff62f40fd251116516a63e2d3f9fb5b21480b16d
This commit is contained in:
committed by
eldritch horrors
parent
45623f077f
commit
6c29016a09
+17
-2
@@ -778,10 +778,24 @@ std::unique_ptr<ValMap> mapStaticEnvBindings(const SymbolTable & st, const Stati
|
||||
return vm;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets `inDebugger` to true on construction and false on destruction.
|
||||
*/
|
||||
class DebuggerGuard {
|
||||
bool & inDebugger;
|
||||
public:
|
||||
DebuggerGuard(bool & inDebugger) : inDebugger(inDebugger) {
|
||||
inDebugger = true;
|
||||
}
|
||||
~DebuggerGuard() {
|
||||
inDebugger = false;
|
||||
}
|
||||
};
|
||||
|
||||
void EvalState::runDebugRepl(const Error * error, const Env & env, const Expr & expr)
|
||||
{
|
||||
// double check we've got the debugRepl function pointer.
|
||||
if (!debugRepl)
|
||||
// Make sure we have a debugger to run and we're not already in a debugger.
|
||||
if (!debugRepl || inDebugger)
|
||||
return;
|
||||
|
||||
auto dts =
|
||||
@@ -808,6 +822,7 @@ void EvalState::runDebugRepl(const Error * error, const Env & env, const Expr &
|
||||
auto se = getStaticEnv(expr);
|
||||
if (se) {
|
||||
auto vm = mapStaticEnvBindings(symbols, *se.get(), env);
|
||||
DebuggerGuard _guard(inDebugger);
|
||||
auto exitStatus = (debugRepl)(ref<EvalState>(shared_from_this()), *vm);
|
||||
switch (exitStatus) {
|
||||
case ReplExitStatus::QuitAll:
|
||||
|
||||
Reference in New Issue
Block a user