MobDebug
MobDebug copied to clipboard
Documentation to implement servers
Is there some handy documentation on how to implement the server? What commands should be sent and how each part relates to each other.
I have been reading the source but I have to look for commands all over the place I have found a few but I'm not sure of what they do and what the arguments are (Please correct this information if something is wrong)
SETB %FILE% %LINE% #Sets breakpoint
DELB %FILE% %LINE% #Delete breakpoint
SETW %EXPRESSION% #Sets a watcher (gives the result of an expression)
DELW %EXPRESSION% #Deletes a watcher
DONE #Finish debugging
EXIT #Finish debugging and quit
RUN #Runs the program?
SUSPEND #Does nothing?
EXEC %CHUNK% #?
OVER #?
OUT #?
BASEDIR %DIRECTORY% #?
STACK #?
OUTPUT %STREAM% %MODE% #?
LOAD %SIZE% %NAME% #?
Some more questions:
- What are the possible responses for each command?
- What are the common error messages I should handle?
- Does the client send commands to the server? Which?
- Which commands do I need to continually send and which are permanent? (I guess
SET[B/W]andDEL[B/W]are permanents)
PS: I wanna make a debugger for Atom, but I want to use JavaScript to create the server so there is no requirement for Lua to be installed. The server needs to be compatible with the MobDebug commands.
@Positive07, there is no detailed documentation, but there are couple of places you can check. At the bottom of mobdebug.lua, there is a list of commands and their descriptions (this should answer at least some questions).
I think we need to settle on the terminology as I'm not sure what you call "server". The debugger has two parts: one part runs in the application (this is instantiated by calling require('mobdebug').start() for example), let's call it a client and the second part runs somewhere else -- a controller -- that accepts user commands and communicates those commands to the application (like step, set breakpoint, run, and so on). Maybe the latter part (controller) is what you call server.
The client initiates the debugging session, but all commands are sent from the controller to the client and the client only sends the information back.
I think the easiest way to get some basic information about the sequence of commands and their responses is to get ZeroBrane Studio, add debugger.verbose=true to its config and then start debugging. You should see all the commands sent by the controller and all the responses that the client sends back.
The responses are usually 200 OK or 400 Bad Request, but there are variations, for example, 202 Paused may be returned on a breakpoint (including file/line information) or 203 Paused on a watchpoint. Most of the responses are one line, but some responses include a number that shows the number of bytes sent in the following message (for example, EXEC command).
All right! Now I understand some more
Maybe the latter part (controller) is what you call server.
Yes, that's what I call a server and what I'm currently trying to implement in JavaScript.
So let me ask some questions (I will install ZeroBrane and do what you proposed but asking can't hurt):
- What are the differences of
STEP,OVERandOUT? What does "run until next line, stepping into/over/returning functions" mean? - When you say that some commands return bytes sent in the following messages like
EXEC, do you mean that I get a response like26followed by26 characters in this line, and I must assume that those 26 characters come from theEXECresponse right? - What's the stack trace response format? (Probably need to check it out with zerobrane but since I may not find all the features I'm asking)
- When I capture and redirect the io stream with
OUTPUTthe responses are somewhat like those ofEXECright? A number followed byncharacters wherenwas the number sent - Does this happen only when I ask or does the client send a response every time there is a print out? How do I know it belongs to the
OUTPUTcommand? - Can I register to multiple streams with the
OUTPUTcommand? If so, how can they be differenced? - What's the difference between
EVALandEXEC? They both executes a piece of code in the current context
Well I guess I'll install ZeroBrane and try to find this stuff. Will report back here all my findings so that people with some of this doubts can come back here and maybe find it useful!
Thanks @pkulchenko I really appreciate your help!
Well ZeroBrane is not that helpful either, I want to know more about the underlying stuff, ZeroBrane shows which functions of MobDebug it calls, and what are the parameters received. I would like to know what MobDebug sends and receives.
So for example delallb is not actually a command sent by MobDebug, it's actually sending multiple DELB commands, I would like to see all the DELB commands sent and the answer for each of them with the 200 ok or whatever the response message is.
I won't be working with the Lua library, that is why the executed functions and the return values of those functions are not actually helpful to what I'm trying to do. I think I'll keep on looking at the source code.
There's another approach you might like. You can do debugging session and record the commands with network sniffer. This is mainly Wireshark. Then you look at the pure network conversation between the client and controller in that same Wireshark
It is great to look at comments to get the big picture.
I am used to gdbserver <port> <app> and gdb -ex 'target remote <ip:port>' relationship.
From what I have read, mobdebug's picture is different. In lua debug setting, application being debugged is not server waitting for attach, but the one initiates request to a server and wait for server to send commands.
And I have to setup contorller, the server, first to listen to application's request.
Is above statement correct?
@Piping,
From what I have read, mobdebug's picture is different. In lua debug setting, application being debugged is not server waitting for attach, but the one initiates request to a server and wait for server to send commands. And I have to setup contorller, the server, first to listen to application's request. Is above statement correct?
That's correct.