lua-users home
lua-l archive

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

On 21 May 2016 at 00:19, Paul K <> wrote:
>> Not yet as I am still wondering how to implement 'step out' and 'step
>> over'. I see that other implementations basically maintain a stack
>> level indicator that is incremented when a Call is encountered and
>> decremented when a Return is encountered, but thinking about it I
>> cannot see how this would work when errors are thrown.
> I do the same thing, but, as you noticed, it's not reliable as there
> are several cases that produce an incorrect value: error(),
> pcall(load, ''), or coroutine.resume call to a function that doesn't
> have any other instructions to execute (for example, when yield() was
> the last instruction). There are probably other cases as well (for
> example, tail call/return events), so I ended up "fixing" the stack
> level in the line hook, but only traversing from the current stack
> level, so the additional processing is fairly "cheap".

I was wondering if the line hook should provide the current stack
level and whether this is cheap to work out. The CallInfo structures
are maintained in a linked list so there is no way to find the level
other than traversing the list -- except perhaps if a level field was
added to the CallInfo structure and maintained every time new CallInfo
is added. This would enable the line hook to cheaply provide the stack
level - and then the tracking of 'step in' and 'step out' should be
more straightforward.