From 2a843e02867468f740a8436285299c9932c8f774 Mon Sep 17 00:00:00 2001 From: fesil Date: Mon, 26 Feb 2024 13:46:59 +0800 Subject: [PATCH] add lua_getinfo_game --- src/lj_arch.h | 4 ++++ src/lj_debug.c | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/lj_arch.h b/src/lj_arch.h index ed22273f..c639c0a3 100644 --- a/src/lj_arch.h +++ b/src/lj_arch.h @@ -797,4 +797,8 @@ extern void *LJ_WIN_LOADLIBA(const char *path); #define LJ_DS_STR_HASH_PATCH LJ_DS #endif +#ifndef LJ_DS_DEBUG_GETINFO_PATCH +#define LJ_DS_DEBUG_GETINFO_PATCH LJ_DS +#endif + #endif diff --git a/src/lj_debug.c b/src/lj_debug.c index 8d8b9eb5..03bb44a8 100644 --- a/src/lj_debug.c +++ b/src/lj_debug.c @@ -538,6 +538,18 @@ LUA_API int lua_getinfo(lua_State *L, const char *what, lua_Debug *ar) return lj_debug_getinfo(L, what, (lj_Debug *)ar, 0); } +#ifdef LJ_DS_DEBUG_GETINFO_PATCH +// the api skip the @ path +LUA_API int lua_getinfo_game(lua_State *L, const char *what, lua_Debug *ar) +{ + int res = lj_debug_getinfo(L, what, (lj_Debug *)ar, 0); + if (res) { + ar->source = ar->source[0] == '@' ? ar->source + 1 : ar->source; + } + return res; +} +#endif + LUA_API int lua_getstack(lua_State *L, int level, lua_Debug *ar) { int size;