Skip to content

enable/disable breakpoints from line number #212

Answered by zeux
morgoth990 asked this question in Q&A
Discussion options

You must be logged in to vote

lua_breakpoint is called on a function object and automatically propagates breakpoints to child functions. As such, the best way for the debugger to use it is to keep the function object that is generated by luau_load by using lua_ref(L, -1) after successful luau_load - this returns a registry index that can be used to query it later.

After that, do something like

lua_getref(L, refidx);
lua_breakpoint(L, -1, line, true);
lua_pop(L, 1);

Note that if you support unloading scripts, you'd want to release the reference by calling lua_unref when you're done with the script, otherwise the function object will permanently stay in memory until the owning state is closed.

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@morgoth990
Comment options

@zeux
Comment options

@morgoth990
Comment options

Answer selected by morgoth990
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants