[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Debugger / coroutine question
- From: Andrew Starks <andrew.starks@...>
- Date: Sat, 24 Jan 2015 14:47:31 -0600
I'm contemplating an extension of mobdebug. I want it to trace the execution of a program from thread to thread, so that I can represent things as a stack of stacks. Currently, mobdebug works in all coroutines, but it only shows the running thread's stack.
My working theory is to wrap `resume` and `yield`. Between two Lua functions, I would just wrap resume and trap the result of `coroutine.running()` and `coroutine.running(coro)` prior to executing the resume. I would maintain a stack of threads, connected by these hand offs and thus know the entire execution chain.
Trapping a resume from C could be handled by also wrapping yield. The unresolved limitation is yielding/resuming from C into C. There are probably other limitations I'm not seeing.
Does that sound accurate? Does the approach seem reasonable? Trapping every hand off would be great, but it's not required. I might consider wrapping the C API, controlling my wrapped version with the `_DEBUG` flag. My preference is to stay in Lua, however.
-Andrew
Come to think of it, that seems pretty easy, except for when I resume into C... But that would still work.
(As you can see I'm thinking this through)
Anyway, does this seem like a sane approach, given my goal, which is to be able