pkulchenko/MobDebug

Usage examples

Closed this issue · 13 comments

Hi, I love being able to debug in Lua, finally!
But I have some doubts about how to use some functions, like

setw <exp>            -- adds a new watch expression
delw <index>          -- removes the watch expression at index
delallw               -- removes all watch expressions
reload                -- restarts the current debugging session
stack                 -- reports stack trace
output stdout <d|c|r> -- capture and redirect io stream (default|copy|redirect)

Is there some tutorials / examples about this stuff?

Thank you very much

Moreover, basedir, without any argument, does nothing...
And it is supposed to output the base dir.

OK, I found some examples about how to use the watch from the RemDebug Example of Execution.
Everything worked fine but basedir.

Now I've to find out how to use the last three items I mentioned before, i.e.

reload                -- restarts the current debugging session
stack                 -- reports stack trace
output stdout <d|c|r> -- capture and redirect io stream (default|copy|redirect)

@Atcold, why didn't basedir work for you? It only sets the folder relative to which all the file paths will be reported, which has impact on how breakpoints are handled.

basedir is supposed to output the current working directory if no argument is passed. Well, typing basedir does not return anything.

What about the last three commands? I cannot figure out how to use them. Would you mind writing a couple of line of example?

Thank you very much

@Atcold, I think the reason basedir didn't return anything is that the basedir hasn't been set yet. For example, I've updated examples/autotest.lua to add stack and basedir commands and here is the output it generates:

> stack
{nil, "auto/test.lua", 0, 15, "main", "", "auto/test.lua"}
> basedir foo
New base directory is foo/
> basedir
foo/

You can also explore all these commands from ZeroBrane Studio IDE, which is using Mobdebug as its debugger. You can turn verbose debugging on (by setting debugger.verbose=true in its configuration file) and this will show all the commands that the IDE sends to the debugger and responses it gets back.

reload reloads the current file and restart the debugging session (but keeps the breakpoints). See examples/autotest.lua for how it's used.

output stdout is used to send "print" output from the application to the controller; 'd' means default (no copying), 'c' means copy (print and send remotely) and 'r' means redirect (only send remotely).

I've added these commands to autotest.lua as well, so you can see how they work.

Perhaps this is a silly observation, but what I get from luarocks is not updated stuff...
How do I install the latest version?

@Atcold, thank you for the reminder; I should update luarocks for 0.61, but this won't still give you the latest version as those changes will need to be packaged as 0.62, which is not released yet. I usually take some time for any reports about issues to come in before making a new release. You can always install the module yourself, since it's only one file.

Yeah, that's what I did :)
Thank you very much.

Ah, I'm writing a tutorial about your debugger! You can find it here, if you are interested :)

Alfredo, this is cool; thank you for sharing. BTW, there is zbs-torch repository and I have plans for providing out-of-the-box integration for Torch in ZBS (but it does need a bit of work).

Wow! So, if I may suggest, could you add the functionality to show Tensors with eval?
Right now, if I need to evaluate a tensor, I need to exec print(Tensor).
It would be very nice to just eval Tensor!

could you add the functionality to show Tensors with eval?

Alfredo, what can't you use eval Tensor? Do you mean that you want to see

 68  24  20
 74  26  21
 80  32  24
[torch.DoubleTensor of dimension 3x3]

instead of " 68 24 20\n 74 26 21\n 80 32 24\n[torch.DoubleTensor of dimension 3x3]\n"?

Yes, you got that perfectly! 👍