-
Notifications
You must be signed in to change notification settings - Fork 201
Support for VSCode DAP protocol #71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Fix. Strip error message for evaluate command Add. Logging configuration.
| if jit and jit.off then jit.off() end | ||
|
|
||
| local socket = require "socket" | ||
| local state = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Packed local variables into state table. This is done because of the limitations of some environment. In my case I have limit to 120 local variables and I faced with it.
| end | ||
| end | ||
|
|
||
| local Socket = {} do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class incapsulate buffered IO and IO pending detection
| mobdebug.dump = serpent.dump | ||
| mobdebug.linemap = nil | ||
| mobdebug.loadstring = loadstring | ||
| mobdebug.print = print |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This allows to redirect print to e.g. logs inside debuggee application
| or string_match(file, [[^.:]]) | ||
| end | ||
|
|
||
| local function removebasedir(path, basedir) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just reformat code and reduce the number if nested levels
| return (file:gsub("^(/?)%.%./", "%1")) | ||
| end | ||
|
|
||
| local function is_soucer_file_path(file) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code from debug_hook without changes
| if not ( | ||
| step_into or step_over or breakpoints[line] or watchescnt > 0 | ||
| or is_pending(server) | ||
| ) then checkcount = checkcount + 1; return end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The checkcount logic movet to the Socket class
| end | ||
|
|
||
| if is_pending(server) then handle_breakpoint(server) end | ||
| local possible_pending_io = debugger.loop_pending_io() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case this function returns true that means there exists some pending data and this data have to be processed inside main loop.
E.g. debugger receive only part of message and we do not want to wait too long inside IO. In this case this function can return false, server:is_pending() will be true, but there no reason to yield to the main loop.
| state.basedir = "" -- to reset basedir in case the same module/state is reused | ||
| end | ||
|
|
||
| local mobdebug_debugger = {} do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Submodule that implements MobDebug protocol.
| if not jit then | ||
| for co, debugged in pairs(coroutines) do | ||
| if debugged then debug.sethook(co) end | ||
| function mobdebug_debugger.send_response(status, message, data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I extract all commant parsing and sendig responses to separate functions.
| -- Handling command from inside debug hook during run state | ||
| function mobdebug_debugger.pending_io() | ||
| local possible_pending_io = false | ||
| while server:is_pending() do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main changes that this loop allows to handle multiple commands.
Fix. Honor the sync flag in the header receiving operation
|
This is a is very handy to have. Being able to support multiple debuggers is a huge win. |
|
whats the protocol used before by mobdebug? i would like to study the specs |
|
found answer to my question here: Lines 1541 to 1561 in f27d479
and in #32 |
|
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() |
|
I thought about it and even tried to do such a split, but I couldn't do this. PS. Right now, I use my module with ZBS, and several colleagues use it with VSCode without any issues. |
|
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? |
I'll try to add comments in the code