> You can use the debug library to insert the appropriate hook callbacks.
In certain cases, yes.
In the case when your Lua VM is already running, you would generally need to do something else, and things get involved pretty quickly depending on how general you want your approach to be.
And then there is the case when the Lua code calls into a native function that does not feel like returning any time soon :)
Cheers,
V.