actboy168 / lua-debug

Lua Debug Adapter for Visual Studio Code
MIT License
439 stars 95 forks source link

Selecting lua version to compile against for rdebug #254

Closed thewhitegoatcb closed 1 year ago

thewhitegoatcb commented 1 year ago

Hello, Im trying to run the debugger on a game called Vermintide 2 it runs an older version of the original luajit 2.1 b3, also has some sandboxing measures for dofile,load,require,io,loadlib. I have managed to write my own loader to restore the original environment and the game works perfectly, however when im trying to either load the debugger with the pre compiled bins, it crashes when I attach VSCode (using the https://github.com/actboy168/lua-debug/tree/master/examples/attach as a base) the crash is inside of remotedebug.dll itself, couldn't pin point the exact issue. I recompiled luadebug as in README, now it crashes just as the rdebug tried to load in https://github.com/actboy168/lua-debug/blob/237e5594c652b7af2f0affeb460a47d2ce8a4fe3/src/luadebug/rdebug_hookmgr.cpp#LL509C7-L509C7

Is it possible to select the lua version to compile with? it seems to always copy the lua54 headers from bee

actboy168 commented 1 year ago

This is just the lua used internally by luadebug, and has nothing to do with the debug target.

If you compile luadebug correctly using luajit source files, it should not crash here, because only non-luajit will run here.

thewhitegoatcb commented 1 year ago

Thank you for the quick reply, It was an issue with lua version detection as tostring was replaced with their own version and this check failed if (tostring(assert):match('builtin') ~= nil) then I have restored the original, but now I have a different crash which is probably isn't surprising as the luajit is vastly different Im trying to compile it with the original luajit version but im getting "'LUA_MASKTHREAD': undeclared identifier", again not surprising but im not seeing where to disable defines like "LUA_HOOKTHREAD" as they aren't from the original source

actboy168 commented 1 year ago

Im trying to compile it with the original luajit version but im getting "'LUA_MASKTHREAD': undeclared identifier", again not surprising but im not seeing where to disable defines like "LUA_HOOKTHREAD" as they aren't from the original source

LUA_HOOKTHREAD is a patch to provide more debugging information to luadebug, it is optional.

thewhitegoatcb commented 1 year ago

Compiles fine now, Thank you. still crashes for some reason, I think im not using the correct luajit build they used in the game, btw how can I enable debug symbols for release builds? not sure if debug builds produce compatible luajit version

actboy168 commented 1 year ago

If you are using luamake, just need luamake -mode debug

thewhitegoatcb commented 1 year ago

Thanks for the help, I will close the issue for now as I didn't have time to sort the luajit issues that are unrelated to your plugin. If I have another issue with the correct luajit version I will open a new issue, much appreciated