Lua suspend, continue, stop

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Lua suspend, continue, stop

Steve Dekorte-2
I'm working on the debbuger for my GUI based Lua dev tools, and
I'm using the hooks(lua_callhook and lua_linehook) to implement
breakpoints, and code stepping.

The debugging APIs that are available in Lua are really nice.
But what seems to be missing is a way for me to tell Lua to suspend and
later to continue or stop execution. This is an issue, since I really
need to be able to let the owner appliction (which my debbuger is in)
return to it's appliction loop so I can use the GUI to do things like
inspect the stack, variable values, etc.

Is there an API for this that I missed?

Steve

Reply | Threaded
Open this post in threaded view
|

Re: Lua suspend, continue, stop

Roberto Ierusalimschy
> But what seems to be missing is a way for me to tell Lua to suspend and
> later to continue or stop execution. [...]
>
> Is there an API for this that I missed?

No. This problem is related to multi-threading in Lua. The point here is that,
when Lua calls a function (a Lua function), the interpreter calls itself
recursively. So, when you get a break-point there is a lot of C stack behind
you, not only Lua stack, and the only way to have a "suspend, continue, stop"
feature is having this in C, too. Some people have changed the interpreter to
avoid this recursive structure, but this is not a trivial task, and does not
work for all cases (for instance, "dostring" and "dofile" must call the
interpreter again...). 

-- Roberto

Reply | Threaded
Open this post in threaded view
|

Re: Lua suspend, continue, stop

Steve Dekorte-2
>But what seems to be missing is a way for me to tell Lua to suspend and
>later to continue or stop execution. [...]
>
>Is there an API for this that I missed?
>
>No. This problem is related to multi-threading in Lua. The point here is that,
>when Lua calls a function (a Lua function), the interpreter calls itself
>recursively. So, when you get a break-point there is a lot of C stack behind
>you, not only Lua stack, and the only way to have a "suspend, continue, stop"
>feature is having this in C, too. Some people have changed the interpreter to
>avoid this recursive structure, but this is not a trivial task, and does not
>work for all cases (for instance, "dostring" and "dofile" must call the
>interpreter again...).
>
>-- Roberto

Ok, so how might I implement breakpoints? (points were I can stop Lua
execution, and view/change variables, etc and then continue Lua execution
where it left off)

Steve