mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
add 'step' and 'resume' commands
This commit is contained in:
parent
5972bc769b
commit
9372a5226e
6 changed files with 91 additions and 42 deletions
|
|
@ -2,8 +2,16 @@
|
|||
-- may be reused one global ffi buffer per lua_State
|
||||
|
||||
local breakpoints = {}
|
||||
local dbg_steps_mode = false
|
||||
local hook_lock = false
|
||||
|
||||
debug.sethook(function (e, line)
|
||||
if dbg_steps_mode and not hook_lock then
|
||||
hook_lock = true
|
||||
debug.breakpoint()
|
||||
debug.pull_events()
|
||||
end
|
||||
hook_lock = false
|
||||
local bps = breakpoints[line]
|
||||
if not bps then
|
||||
return
|
||||
|
|
@ -18,6 +26,9 @@ end, "l")
|
|||
|
||||
local DBG_EVENT_SET_BREAKPOINT = 1
|
||||
local DBG_EVENT_RM_BREAKPOINT = 2
|
||||
local DBG_EVENT_STEP = 3
|
||||
local DBG_EVENT_STEP_INTO_FUNCTION = 4
|
||||
local DBG_EVENT_RESUME = 5
|
||||
local __pull_events = debug.__pull_events
|
||||
debug.__pull_events = nil
|
||||
|
||||
|
|
@ -31,6 +42,10 @@ function debug.pull_events()
|
|||
debug.set_breakpoint(event[2], event[3])
|
||||
elseif event[1] == DBG_EVENT_RM_BREAKPOINT then
|
||||
debug.remove_breakpoint(event[2], event[3])
|
||||
elseif event[1] == DBG_EVENT_STEP then
|
||||
dbg_steps_mode = true
|
||||
elseif event[1] == DBG_EVENT_RESUME then
|
||||
dbg_steps_mode = false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue