Re: Stack frame restart

  • From: Denis Golovan <denis.golovan@xxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Sun, 21 Sep 2014 23:06:08 +0300

Well.
Yes, I saw that debug thing. And yes, that seems to be a quite simple
task to step _forward_.

The real difficulty is to replace/restart current stack frame with
completely new set of local vars and let VM continue later. Just
calling the new/modified function is not enough.

Actually, I was even about to write a macro-like wrapper for functions
having "break" inside them. Conceptually it is just a (x)pcall
catching specially crafted error "exception" and restarting a stack
frame. But then I decided to ask the community :)


2014-09-21 22:43 GMT+03:00 Elias Hogstvedt <eliashogstvedt@xxxxxxxxx>:
> You can sort of simulate "break" by calling a function which would do an
> infinite loop. Using this with debug.sethook and you can step to the next
> line.
>
> As for jumping back or restarting you could maybe call the function you're
> in again (using debug.getinfo) with the same arguments (using
> debug.getlocal) but this sounds very hacky and unreliable. I'm not sure if
> the debug library is 100% in luajit but I do know that you need to disable
> jit compilation to get an accurate call stack.
>
> On Sun, Sep 21, 2014 at 9:01 PM, Denis Golovan <denis.golovan@xxxxxxxxx>
> wrote:
>>
>> Hi all
>>
>> I am wondering, is it possible to create/simulate/force LuaJIT restart
>> current stack frame?
>>
>> What I mean by that is something similar to some Common Lisp/APL
>> implementations have.
>>
>> That is roughly following set of actions:
>> - setting a breakpoint inside some function
>> - waiting for it to trigger "debugger"
>> - change/recompile current function code
>> - and finally restart current stack frame using function new body
>> without restarting the entire stack/all related functions.
>>
>> That thing is actually a killer feature...
>>
>> BR,
>> Denis
>>
>

Other related posts: