lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hooks are thread-local, so the hook does not get called inside the listener loop (another convenience of using coroutines for the listener :-) ). And the first coroutine.resume, inside start(), starts the listener loop if there is a connection, the first yield is supposed to return from start() and fall back to your program (which called start). The way to use remdebug is to put remdebug.engine.start() at some place in your program that gets executed regularly, then run the controller in the console when you want to debug it. remdebug.engine is a library that your app requires, controller.lua is a Lua script that you run.

The server-client inversion (the controller listens for the TCP connection) is to make remote debugging of web applications possible even if your application is running behind a firewall that only lets http and ftp through, for example. It does make using it for local debugging a little awkward, but for that there are other pretty nice solutions from the Lua community.

--
Fabio Mascarenhas

On Thu, Aug 21, 2008 at 8:14 PM, Hugo Schmitt <hugows@gmail.com> wrote:
Ok, thanks for the clarification.
A couple more questions, if you remember:

1) How do you prevent the debugger from debugging itself (or you don't) ?
2)  How do you coroutine.yield to the correct coroutine.resume (the
one inside the loop) ? Your first coroutine.resume is outside the
"loop", when you set the line hook. How come the next coroutine.yield
doesn't get you back here (hence exiting the program) ?

Thanks again,

Hugo Schmitt (Porto Alegre, Brasil)

On Thu, Aug 21, 2008 at 5:10 PM, Fabio Mascarenhas <mascarenhas@acm.org> wrote:
>
> Hi,
>
> Convenience. With coroutines I could write the engine's listener loop (that answers commands from the controller) as an actual loop. It could be implemented as a function that gets called by the debug hook, but IMHO it would make the code more complex.
>
> --
> Fabio Mascarenhas
>
> On Wed, Aug 20, 2008 at 11:06 PM, Hugo Schmitt <hugows@gmail.com> wrote:
>>
>> (I tried kepler project list, but maybe this one is more appropriate)
>>
>> Hi folks.
>> I don't know if remdebug's author reads this list, but I'm trying here first.
>>
>> I looked at remdebug's source (engine.lua on this case) but could not find out why are coroutines needed for this implementation.
>> Anyone cares to explain?
>>
>> Thanks a lot,
>> hugo