debugger refactor

This commit is contained in:
kepler155c@gmail.com
2020-05-30 20:06:30 -06:00
parent 6394a48766
commit d203510527
7 changed files with 58 additions and 22 deletions

View File

@@ -6,10 +6,8 @@ local fs = _G.fs
local dbg = {
hooks = { },
waits = { },
debugger = nil,
breakpoints = nil,
}
_G._dbg = dbg -- for testing purposes
local function breakpointHook(info)
if dbg.breakpoints then
@@ -155,12 +153,7 @@ local function hook()
while dbg.waits[1] ~= h do
os.sleep(.1)
end
os.queueEvent('debuggerX', dbg.debugger.uid, snapshot)
local e, cmd, param
repeat
e, cmd, param = os.pullEvent('debugger')
until e == 'debugger'
local cmd, param = dbg.read(snapshot)
table.remove(dbg.waits, 1)
@@ -187,7 +180,7 @@ function dbg.call(fn, ...)
local args = { ... }
return xpcall(
function()
fn(table.unpack(args))
return fn(table.unpack(args))
end,
function(err)
dbg.hooks[coroutine.running()].eval = stepHook()