Skip to content

Commit a1fdc12

Browse files
CppCXYtangzx
authored andcommitted
修复条件断点计算,修改部分函数签名
1 parent 6d9530b commit a1fdc12

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

emmy_core/emmy_debugger.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -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
721721
bool 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

emmy_core/emmy_debugger.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ class Debugger {
101101
void HandleBreak(lua_State* L);
102102
void SetHookState(lua_State* L, HookState* newState);
103103
void CheckDoString(lua_State* L);
104-
bool CreateEnv(int stackLevel);
105-
bool ProcessBreakPoint(BreakPoint* bp);
106-
bool DoEval(EvalContext* evalContext);
104+
bool CreateEnv(lua_State* L, int stackLevel);
105+
bool ProcessBreakPoint(lua_State* L, BreakPoint* bp);
106+
bool DoEval(lua_State* L,EvalContext* evalContex);
107107
bool MatchFileName(const std::string& chunkName, const std::string& fileName) const;
108108
void CacheValue(lua_State* L, int valueIndex, Variable* variable) const;
109109
void ClearCache(lua_State* L) const;

0 commit comments

Comments
 (0)