[ZeroBrane Studio] Re: Step In , Step Out in LUA

  • From: Lucas Saraiva <lucassaraiva12@xxxxxxxxxxxx>
  • To: "zerobrane@xxxxxxxxxxxxx" <zerobrane@xxxxxxxxxxxxx>
  • Date: Sun, 24 Nov 2013 11:28:37 -0800 (PST)

Thanks for reply
I would ask only one more thing, mobDebug is a library aside, there is a way I 
can only use this function'' step in'' on a button that I have in my interface 
without me having to redeploy it?
My entire interface was built in WxLua and I have a button called '' step in'' 
and I need him to do just that, run command lines starting from a hook.




Em Domingo, 24 de Novembro de 2013 15:51, Paul K <paul@xxxxxxxxxxxxx> escreveu:
 
Hi Lucas,

ZeroBrane Studio is using Mobdebug debugger, which implements "step
in" and "step out" commands.

To answer your question, these commands work this way: the debugger
sets a line hook (using debug.sethook command), which then keeps track
of where in the script is the execution. When you run "step in"
command, it sets a flag to stop at the very next command. The hook
then checks for that flag
(https://github.com/pkulchenko/ZeroBraneStudio/blob/master/lualibs/mobdebug/mobdebug.lua#L514-L520;
the variable is step_into) and if it's set, it suspends the debugging
at that step.

"step out" is a bit more complex, but works in a similar way. When the
command is executed, the debugging keeps the current position in the
stack and only stops when the position in the stack is current-1. It
applies some logic to "fix" stack calculations in some cases and to
make it work for Lua and LuaJIT interpreters (see the explanation
here: 
https://github.com/pkulchenko/ZeroBraneStudio/blob/master/lualibs/mobdebug/mobdebug.lua#L451-L462).
It also checks for whether this code is running in a separate
coroutine as coroutines have their own stack.

Paul.


On Sun, Nov 24, 2013 at 8:08 AM, Lucas Saraiva
<lucassaraiva12@xxxxxxxxxxxx> wrote:
> Hello, my name is Lucas Scott student UFOP (Federal University of Ouro
> Preto) in the course of Information Systems.
> I have a project in a college laboratory (LEDs) made in 'lua' and 'wxlua',
> studying the software that you have created I saw that it has the function
> 'step in' 'step out'.
> For my project I need this feature and would like to know how you did this
> using only 'lua', took a look at the debug library 'lua' and I could not
> find anything.
>
> Thank you for your attention.

Other related posts: