Builtin Library
README.md
probe.onLine
Fire when execution reaches a line, without stopping it.
This is the target that reaches code no name can address: a local inside a
module, a helper a component never exported, a branch you want to know is
taken. path is the script's chunk name, VFS path, or require identity, and
line snaps to the next executable line.
probe.onLine("Ticker", 9, {
notice = "score got big",
when = "doubled >= 6",
run = "return locals.doubled",
})
The world is not stopped. The line runs on, and the body sees the frame it was
in: locals and upvalues are that frame's, read at the moment of the hit.
Where to put a comparison. when is evaluated inside that frame, so it
reads the frame's own variables by their own names and with their own types —
doubled >= 6. locals in the body is that frame rendered as text, which is
what you want for reporting and not what you want for arithmetic. Compare in
when, report from locals. A hit whose condition does not hold never reaches
the body at all.
Set one on a script that has not loaded yet and it waits, then installs itself when the script loads.
The cost worth knowing. An unarmed line costs the virtual machine nothing, but a breakpoint drops the function containing it out of native code until that script reloads, and cancelling the probe does not bring native code back. On a function that runs every frame that is a real cost, so cancel when you are done rather than leaving it armed.