Skip to content
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

Documentation to implement servers #32

Open
pablomayobre opened this issue Feb 24, 2017 · 6 comments
Open

Documentation to implement servers #32

pablomayobre opened this issue Feb 24, 2017 · 6 comments
Assignees

Comments

@pablomayobre
Copy link

pablomayobre commented Feb 24, 2017

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] and DEL[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.

@pkulchenko
Copy link
Owner

@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).

@pkulchenko pkulchenko self-assigned this Feb 26, 2017
@pablomayobre
Copy link
Author

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, OVER and OUT? 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 like 26 followed by 26 characters in this line, and I must assume that those 26 characters come from the EXEC response 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 OUTPUT the responses are somewhat like those of EXEC right? A number followed by n characters where n was 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 OUTPUT command?
  • Can I register to multiple streams with the OUTPUT command? If so, how can they be differenced?
  • What's the difference between EVAL and EXEC? 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!

@pablomayobre
Copy link
Author

pablomayobre commented Feb 26, 2017

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.

@ildar
Copy link

ildar commented Jun 6, 2019

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

@Piping
Copy link

Piping commented Aug 30, 2019

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?

@pkulchenko
Copy link
Owner

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants