@@ -120,7 +120,7 @@ void Debugger::Hook(lua_State* L, lua_Debug* ar) {
120120 luaThreadExecutors.clear ();
121121 }
122122 auto * bp = FindBreakPoint (L, ar);
123- if (bp && ProcessBreakPoint (bp)) {
123+ if (bp && ProcessBreakPoint (L, bp)) {
124124 HandleBreak (L);
125125 return ;
126126 }
@@ -485,7 +485,7 @@ void Debugger::EnterDebugMode(lua_State* L) {
485485 lockEval.unlock ();
486486 const bool skip = skipHook;
487487 skipHook = true ;
488- evalContext->success = DoEval (evalContext);
488+ evalContext->success = DoEval (currentStateL, evalContext);
489489 skipHook = skip;
490490 EmmyFacade::Get ()->OnEvalResult (evalContext);
491491 continue ;
@@ -595,9 +595,9 @@ int EnvIndexFunction(lua_State* L) {
595595 return 0 ;
596596}
597597
598- bool Debugger::CreateEnv (int stackLevel) {
599- assert (currentStateL);
600- const auto L = currentStateL;
598+ bool Debugger::CreateEnv (lua_State* L, int stackLevel) {
599+ // assert(currentStateL);
600+ // const auto L = currentStateL;
601601
602602 lua_Debug ar{};
603603 if (!lua_getstack (L, stackLevel, &ar)) {
@@ -657,11 +657,11 @@ bool Debugger::CreateEnv(int stackLevel) {
657657 return true ;
658658}
659659
660- bool Debugger::ProcessBreakPoint (BreakPoint* bp) {
660+ bool Debugger::ProcessBreakPoint (lua_State* L, BreakPoint* bp) {
661661 if (!bp->condition .empty ()) {
662662 EvalContext ctx{};
663663 ctx.expr = bp->condition ;
664- bool suc = DoEval (&ctx);
664+ bool suc = DoEval (L, &ctx);
665665 return suc && ctx.result .valueType == LUA_TBOOLEAN && ctx.result .value == " true" ;
666666 }
667667 if (!bp->logMessage .empty ()) {
@@ -720,7 +720,7 @@ void Debugger::CheckDoString(lua_State* L) {
720720// message thread
721721bool Debugger::Eval (EvalContext* evalContext, bool force) {
722722 if (force)
723- return DoEval (evalContext);
723+ return DoEval (currentStateL, evalContext);
724724 if (!blocking)
725725 return false ;
726726 std::unique_lock<std::mutex> lock (mutexEval);
@@ -731,10 +731,10 @@ bool Debugger::Eval(EvalContext* evalContext, bool force) {
731731}
732732
733733// host thread
734- bool Debugger::DoEval (EvalContext* evalContext) {
735- assert (currentStateL );
734+ bool Debugger::DoEval (lua_State* L, EvalContext* evalContext) {
735+ assert (L );
736736 assert (evalContext);
737- auto * const L = currentStateL;
737+ // auto* const L = currentStateL;
738738 // From "cacheId"
739739 if (evalContext->cacheId > 0 ) {
740740 lua_getfield (L, LUA_REGISTRYINDEX, CACHE_TABLE_NAME); // 1: cacheTable|nil
@@ -758,7 +758,7 @@ bool Debugger::DoEval(EvalContext* evalContext) {
758758 // call
759759 const int fIdx = lua_gettop (L);
760760 // create env
761- if (!CreateEnv (evalContext->stackLevel ))
761+ if (!CreateEnv (L, evalContext->stackLevel ))
762762 return false ;
763763 // setup env
764764#ifndef EMMY_USE_LUA_SOURCE
0 commit comments