[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: RE: Debug hook not called on "local" lines in some cases
- From: Dan Tull <dtull@...>
- Date: Wed, 30 Jan 2013 14:09:34 -0800
> (Paul K)
> So, it seems like both Lua and LuaJIT don't produce LOADNIL or similar
> command in some cases and as a result, don't trigger debug hooks...
It does generate one, but LOADNIL supports operating on a range of
registers, so consecutive variable declarations can be done in 1 opcode
and the other lines have no opcodes, so there's no place for the hook
to notice the new line.
When you break them up by adding a non-nil assignment, it breaks the
contiguous sequence and has to be done in multiple opcodes.
Also, a LOADNIL is only used if it is necessary to ensure a given register
has a nil value. For locals that represent the first use of a given slot in
the function body, no LOADNIL will be generated at all.
$ luac -l -p -
main <stdin:0,0> (1 instruction, 4 bytes at 0x15f0e0)
0+ params, 4 slots, 0 upvalues, 4 locals, 0 constants, 0 functions
1  RETURN 0 1
I always figured those were intentional optimizations.
> (Paul K)
> This is more than a mere curiosity as the debugger steps over those
> lines, which confuses users...
I've run across this as well. In my case, people wondered why their
breakpoints weren't stopping because several of the lines did not
have any opcodes (so you can't break on those lines).
I wound up adding some hints to indicate which lines do and do not
have opcodes on which to stop.