tomblind / local-lua-debugger-vscode

Local Lua Debugger for VSCode
MIT License
107 stars 26 forks source link

Breakpoints not working on custom engine using physfs #82

Closed tanis2000 closed 1 year ago

tanis2000 commented 1 year ago

I have my own engine which is using physfs to map the path of the lua files to a virtual directory. This means that the breakpoints are being set with the full path of the files, e.g.:

[command] break set /Users/tanis/Documents/binocle-player-games/simple/boot.lua:6
[message] {"breakpoints":[{"enabled":true,"line":6,"file":"/Users/tanis/Documents/binocle-player-games/simple/boot.lua"}],"tag":"$luaDebug","type":"breakpoints"}

But inside my engine, the lua files are loaded from a virtual "/assets" folder. Thus, the file name looks different. I noticed this by turning on the stopOnEntry flag. The reported path is the following:

[message] {"frames":[{"source":"/assets/boot.lua","line":6,"active":true,"func":"function: 0x010daa9710"}],"tag":"$luaDebug","type":"stack"}

Is there any way to let the debugger understand that /Users/tanis/Documents/binocle-player-games/simple should be mapped to /assets/simple and the other way around?

tanis2000 commented 1 year ago

I solved this issue by changing the implementation on my custom engine to provide the full name of the lua file instead of the module name when loading it. It looks like this does the trick. In my case, when loading module main, I add .lua to it and set it as the name of the loaded file in luaL_loadbuffer.