Skip to content

Commit bf00b9c

Browse files
committed
fix bug
1 parent 336c9be commit bf00b9c

File tree

7 files changed

+53
-19
lines changed

7 files changed

+53
-19
lines changed

.github/workflows/build.yml

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,33 +15,42 @@ jobs:
1515
- { os: macos-latest, target: darwin, platform: darwin-x64}
1616
- { os: macos-latest, target: darwin, platform: darwin-arm64}
1717
steps:
18-
- uses: actions/checkout@v2
18+
- name: Env
19+
run: |
20+
if [[ ${{ github.ref }} == refs/tags/* ]]; then
21+
TAG=${{ github.ref }}
22+
TAG=${TAG#refs/tags/}
23+
echo echo "TAG=$TAG" >> $GITHUB_ENV
24+
else
25+
echo echo "TAG=DEV" >> $GITHUB_ENV
26+
fi
1927
28+
- uses: actions/checkout@v2
2029
- name: Build-windows
2130
if: startsWith(matrix.os, 'windows')
2231
run: |
2332
mkdir build
2433
cd build
25-
cmake .. ${{ matrix.cmake_arch }} -G "Visual Studio 17 2022" -DCMAKE_USER_MAKE_RULES_OVERRIDE="${{ github.workspace }}/cmake/flags_override.cmake"
26-
cmake --build . --config RelWithDebInfo
27-
cmake --install . --config RelWithDebInfo --prefix ${{ github.workspace }}/artifact/
34+
cmake .. ${{ matrix.cmake_arch }} -G "Visual Studio 17 2022" -DCMAKE_USER_MAKE_RULES_OVERRIDE="${{ github.workspace }}/cmake/flags_override.cmake" -DEMMY_CORE_VERSION=${{env.TAG}}
35+
cmake --build . --config Release
36+
cmake --install . --config Release --prefix ${{ github.workspace }}/artifact/
2837
- name: Build-linux
2938
if: startsWith(matrix.os, 'ubuntu')
3039
run: |
3140
mkdir build
3241
cd build
33-
cmake ..
34-
cmake --build . --config RelWithDebInfo
35-
cmake --install . --config RelWithDebInfo --prefix ${{ github.workspace }}/artifact/
42+
cmake .. -DCMAKE_BUILD_TYPE=Release -DEMMY_CORE_VERSION=${{env.TAG}}
43+
cmake --build . --config Release
44+
cmake --install . --config Release --prefix ${{ github.workspace }}/artifact/
3645
- name: Build-macosx
3746
if: startsWith(matrix.os, 'macos')
3847
run: |
3948
mkdir build
4049
cd build
4150
if [[ "${{ matrix.platform }}" = darwin-arm64 ]]; then
42-
cmake .. -DCMAKE_OSX_ARCHITECTURES=arm64
51+
cmake .. -DCMAKE_OSX_ARCHITECTURES=arm64 -DCMAKE_BUILD_TYPE=Release -DEMMY_CORE_VERSION=${{env.TAG}}
4352
else
44-
cmake .. -DCMAKE_OSX_ARCHITECTURES=x86_64
53+
cmake .. -DCMAKE_OSX_ARCHITECTURES=x86_64 -DCMAKE_BUILD_TYPE=Release -DEMMY_CORE_VERSION=${{env.TAG}}
4554
fi
4655
cmake --build . --config Release
4756
cmake --install . --config Release --prefix ${{ github.workspace }}/artifact/

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ set(CMAKE_INSTALL_PREFIX install)
66
set(CMAKE_CXX_STANDARD 11)
77

88
set(EMMY_LUA_VERSION "54" CACHE STRING "Lua version: jit/51/52/53/54")
9+
set(EMMY_CORE_VERSION "DEV" CACHE STRING "Emmy core version: DEV/version number")
910

1011
if(${EMMY_LUA_VERSION} STREQUAL "54")
1112
set(EMMY_LUA_DIR "lua-5.4.0")
@@ -26,7 +27,7 @@ elseif(${EMMY_LUA_VERSION} STREQUAL "jit")
2627
#add_definitions(-DEMMY_LUA_JIT_SUPPORT_LUA_SETFUNCS)
2728
endif()
2829

29-
add_definitions(-DEMMY_CORE_VERSION="1.5.2")
30+
add_definitions(-DEMMY_CORE_VERSION="${EMMY_CORE_VERSION}")
3031

3132
if(EMMY_USE_LUA_SOURCE)
3233
add_definitions(-DEMMY_USE_LUA_SOURCE)

emmy_debugger/include/emmy_debugger/debugger/emmy_debugger.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@ class Debugger: public std::enable_shared_from_this<Debugger>
8888
void SetHookState(std::shared_ptr<HookState> newState);
8989
EmmyDebuggerManager* GetEmmyDebuggerManager();
9090

91+
void SetVariableArena(Arena<Variable> *arena);
92+
93+
Arena<Variable> *GetVariableArena();
94+
95+
void ClearVariableArenaRef();
96+
9197
private:
9298
std::shared_ptr<BreakPoint> FindBreakPoint(lua_Debug* ar);
9399
std::shared_ptr<BreakPoint> FindBreakPoint(const std::string& file, int line);
@@ -129,4 +135,6 @@ class Debugger: public std::enable_shared_from_this<Debugger>
129135

130136
std::mutex evalMtx;
131137
std::queue<std::shared_ptr<EvalContext>> evalQueue;
138+
139+
Arena<Variable> *arenaRef;
132140
};

emmy_debugger/include/emmy_debugger/debugger/extension_point.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ class ExtensionPoint {
88
public:
99
static std::string ExtensionTable;
1010

11-
static Arena<Variable> *Arena;
12-
1311
ExtensionPoint();
1412

1513
void Initialize(lua_State *L);

emmy_debugger/include/emmy_debugger/emmy_facade.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,6 @@ class EmmyFacade
8989

9090
void OnReceiveMessage(nlohmann::json document);
9191

92-
// void Remove
93-
9492
// Start hook 作为成员存在
9593
std::function<void()> StartHook;
9694

emmy_debugger/src/debugger/emmy_debugger.cpp

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ Debugger::Debugger(lua_State *L, EmmyDebuggerManager *manager)
4040
hookState(nullptr),
4141
running(false),
4242
skipHook(false),
43-
blocking(false) {
43+
blocking(false),
44+
arenaRef(nullptr) {
4445
}
4546

4647
Debugger::~Debugger() {
@@ -200,7 +201,9 @@ bool Debugger::GetStacks(std::vector<Stack> &stacks) {
200201
// add local variable
201202
auto var = stack.variableArena->Alloc();
202203
var->name = name;
204+
SetVariableArena(stack.variableArena.get());
203205
GetVariable(L, var, -1, 1);
206+
ClearVariableArenaRef();
204207
lua_pop(L, 1);
205208
stack.localVariables.push_back(var);
206209
}
@@ -216,7 +219,9 @@ bool Debugger::GetStacks(std::vector<Stack> &stacks) {
216219
// add up variable
217220
auto var = stack.variableArena->Alloc();
218221
var->name = name;
222+
SetVariableArena(stack.variableArena.get());
219223
GetVariable(L, var, -1, 1);
224+
ClearVariableArenaRef();
220225
lua_pop(L, 1);
221226
stack.upvalueVariables.push_back(var);
222227
}
@@ -793,6 +798,18 @@ EmmyDebuggerManager *Debugger::GetEmmyDebuggerManager() {
793798
return manager;
794799
}
795800

801+
void Debugger::SetVariableArena(Arena<Variable> *arena) {
802+
arenaRef = arena;
803+
}
804+
805+
Arena<Variable> * Debugger::GetVariableArena() {
806+
return arenaRef;
807+
}
808+
809+
void Debugger::ClearVariableArenaRef() {
810+
arenaRef = nullptr;
811+
}
812+
796813
int Debugger::GetStackLevel(bool skipC) const {
797814
if (!currentL) {
798815
return 0;
@@ -898,7 +915,9 @@ bool Debugger::DoEval(std::shared_ptr<EvalContext> evalContext) {
898915
lua_getfield(L, LUA_REGISTRYINDEX, CACHE_TABLE_NAME);// 1: cacheTable|nil
899916
if (lua_type(L, -1) == LUA_TTABLE) {
900917
lua_getfield(L, -1, std::to_string(evalContext->cacheId).c_str());// 1: cacheTable, 2: value
918+
SetVariableArena(evalContext->result.GetArena());
901919
GetVariable(L, evalContext->result, -1, evalContext->depth);
920+
ClearVariableArenaRef();
902921
lua_pop(L, 2);
903922
return true;
904923
}
@@ -937,7 +956,9 @@ bool Debugger::DoEval(std::shared_ptr<EvalContext> evalContext) {
937956
r = lua_pcall(L, 0, 1, 0);
938957
if (r == LUA_OK) {
939958
evalContext->result->name = evalContext->expr;
959+
SetVariableArena(evalContext->result.GetArena());
940960
GetVariable(L, evalContext->result, -1, evalContext->depth);
961+
ClearVariableArenaRef();
941962
lua_pop(L, 1);
942963
return true;
943964
}

emmy_debugger/src/debugger/extension_point.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#include "emmy_debugger/emmy_facade.h"
33

44
std::string ExtensionPoint::ExtensionTable = "emmyHelper";
5-
Arena<Variable> *ExtensionPoint::Arena = nullptr;
65

76
int metaQuery(lua_State *L) {
87
const int argN = lua_gettop(L);
@@ -80,8 +79,9 @@ void pushVariable(lua_State *L, Idx<Variable> variable) {
8079
}
8180

8281
int createNode(lua_State *L) {
83-
if (ExtensionPoint::Arena) {
84-
auto idx = ExtensionPoint::Arena->Alloc();
82+
auto arenaRef = EmmyFacade::Get().GetDebugger(L)->GetVariableArena();
83+
if (arenaRef) {
84+
auto idx = arenaRef->Alloc();
8585
pushVariable(L, idx);
8686
return 1;
8787
} else {
@@ -131,7 +131,6 @@ bool ExtensionPoint::QueryVariable(lua_State *L, Idx<Variable> variable, const c
131131
if (lua_istable(L, -1)) {
132132
lua_getfield(L, -1, "queryVariable");
133133
if (lua_isfunction(L, -1)) {
134-
ExtensionPoint::Arena = variable.GetArena();
135134
pushVariable(L, variable);
136135
lua_pushvalue(L, object);
137136
lua_pushstring(L, typeName);

0 commit comments

Comments
 (0)