From ef1f7ec39ac52eb91f9bfe81c4a54087b8852e17 Mon Sep 17 00:00:00 2001 From: tsone Date: Wed, 1 Feb 2023 16:00:28 +0100 Subject: [PATCH] Renamed Lua debugger.getsymboladdress -> getsymboloffset and added the function documentation. --- src/lua-engine.cpp | 22 +++++++++++++++------- web/help/LuaFunctionsList.html | 4 ++++ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/lua-engine.cpp b/src/lua-engine.cpp index 8669b47c..431b14f8 100644 --- a/src/lua-engine.cpp +++ b/src/lua-engine.cpp @@ -5078,16 +5078,24 @@ static int debugger_resetinstructionscount(lua_State *L) return 0; } -// debugger.getsymboladdress() -static int debugger_getsymboladdress(lua_State *L) +// debugger.getsymboloffset() +static int debugger_getsymboloffset(lua_State *L) { - int bank = luaL_checkinteger(L, 1); - const char *name = luaL_checkstring(L, 2); + debugSymbol_t *sym = NULL; - debugSymbol_t *sym = debugSymbolTable.getSymbol(bank, name); + const char *name = luaL_checkstring(L, 1); - lua_pushinteger(L, sym ? sym->ofs & 0xFFFF : -1); + if (lua_type(L, 2) == LUA_TNUMBER) + { + int bank = luaL_checkinteger(L, 2); + sym = debugSymbolTable.getSymbol(bank, name); + } + else + { + sym = debugSymbolTable.getSymbolAtAnyBank(name); + } + lua_pushinteger(L, sym ? sym->ofs : -1); return 1; } @@ -6273,7 +6281,7 @@ static const struct luaL_reg debuggerlib[] = { {"getinstructionscount", debugger_getinstructionscount}, {"resetcyclescount", debugger_resetcyclescount}, {"resetinstructionscount", debugger_resetinstructionscount}, - {"getsymboladdress", debugger_getsymboladdress}, + {"getsymboloffset", debugger_getsymboloffset}, {NULL,NULL} }; diff --git a/web/help/LuaFunctionsList.html b/web/help/LuaFunctionsList.html index 02c74482..7176168a 100644 --- a/web/help/LuaFunctionsList.html +++ b/web/help/LuaFunctionsList.html @@ -504,6 +504,10 @@


Resets the instructions counter.


+

int debugger.getsymboloffset(string name [, int bank])

+


+

Gets the offset (usually the CPU address) of a debug symbol. Returns -1 if the symbol is not found.

+



Joypad Library