pkulchenko / MobDebug

Remote debugger for Lua.
Other
885 stars 192 forks source link

Support for VSCode DAP protocol #71

Open moteus opened 2 years ago

moteus commented 2 years ago

I'll try to add comments in the code

mavriq-dev commented 2 years ago

This is a is very handy to have. Being able to support multiple debuggers is a huge win.

muescha commented 1 year ago

whats the protocol used before by mobdebug? i would like to study the specs

muescha commented 1 year ago

found answer to my question here:

https://github.com/pkulchenko/MobDebug/blob/f27d479f8c1693f6fce00b69cffd1754244b6bf6/src/mobdebug.lua#L1541-L1561

and in https://github.com/pkulchenko/MobDebug/issues/32

muescha commented 1 year ago

i asked the question because: when the functionality is equal to both debug protocols then i would not mix the implementation into one file. when something changes then it need to implemented in both protocols on 2 places (DRY)

i would like to see some main functionality and then implement the adapter pattern either for mobdebug protocol or for debug adapter protocol.

 local mobdebug = require("mobdebug").adapter("dap").start()
 local mobdebug = require("mobdebug").start()
moteus commented 1 year ago

I thought about it and even tried to do such a split, but I couldn't do this. The mobdebug.lua file is a self-contained module with a debug server and debug client simultaneously. It contains code that depends on a file name and a call stack size. So as a result, I got some unexplainable errors when adding additional layers to this code. I had code with two classes, DapLoop and MobDebugLoop, but I could not fix or even understood some glitches and ended up with a more straightforward implementation. If speaking about require("mobdebug").adapter("dap").start() right now, I see no necessity in such because it is pretty easy to detect client protocol by the first message.

PS. Right now, I use my module with ZBS, and several colleagues use it with VSCode without any issues.

KuDeSnik33ra commented 1 year ago

Is there some manual on how to use it with vscode? Isn't there any chance to have multiple connections from debugged application to singe vscode server to debug multiple lua VMs simultaneousely without starting multiple debugging sessions in VSCode?