add debug.get_pack_by_frame
This commit is contained in:
parent
be2dc1abe5
commit
0e2b203fb2
@ -1,3 +1,40 @@
|
|||||||
|
function crc32(bytes, chksum)
|
||||||
|
local chksum = chksum or 0
|
||||||
|
|
||||||
|
local length = #bytes
|
||||||
|
if type(bytes) == "table" then
|
||||||
|
local buffer_len = _ffi.new('int[1]', length)
|
||||||
|
local buffer = _ffi.new(
|
||||||
|
string.format("char[%s]", length)
|
||||||
|
)
|
||||||
|
for i=1, length do
|
||||||
|
buffer[i - 1] = bytes[i]
|
||||||
|
end
|
||||||
|
bytes = _ffi.string(buffer, buffer_len[0])
|
||||||
|
end
|
||||||
|
return _crc32(bytes, chksum)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Check if given table is an array
|
||||||
|
function is_array(x)
|
||||||
|
if #x > 0 then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
for k, v in pairs(x) do
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Get entry-point and filename from `entry-point:filename` path
|
||||||
|
function parse_path(path)
|
||||||
|
local index = string.find(path, ':')
|
||||||
|
if index == nil then
|
||||||
|
error("invalid path syntax (':' missing)")
|
||||||
|
end
|
||||||
|
return string.sub(path, 1, index-1), string.sub(path, index+1, -1)
|
||||||
|
end
|
||||||
|
|
||||||
local breakpoints = {}
|
local breakpoints = {}
|
||||||
local dbg_steps_mode = false
|
local dbg_steps_mode = false
|
||||||
local dbg_step_into_func = false
|
local dbg_step_into_func = false
|
||||||
@ -5,6 +42,7 @@ local hook_lock = false
|
|||||||
local current_func
|
local current_func
|
||||||
local current_func_stack_size
|
local current_func_stack_size
|
||||||
|
|
||||||
|
local __parse_path = parse_path
|
||||||
local _debug_getinfo = debug.getinfo
|
local _debug_getinfo = debug.getinfo
|
||||||
local _debug_getlocal = debug.getlocal
|
local _debug_getlocal = debug.getlocal
|
||||||
local __pause = debug.pause
|
local __pause = debug.pause
|
||||||
@ -74,6 +112,11 @@ local __sendvalue = debug.__sendvalue
|
|||||||
debug.__pull_events = nil
|
debug.__pull_events = nil
|
||||||
debug.__sendvalue = nil
|
debug.__sendvalue = nil
|
||||||
|
|
||||||
|
function debug.get_pack_by_frame(func)
|
||||||
|
local prefix, _ = __parse_path(_debug_getinfo(func, "S").source)
|
||||||
|
return prefix
|
||||||
|
end
|
||||||
|
|
||||||
function debug.pull_events()
|
function debug.pull_events()
|
||||||
if not is_debugging then
|
if not is_debugging then
|
||||||
return
|
return
|
||||||
@ -194,43 +237,6 @@ function __vc_Canvas_set_data(self, data)
|
|||||||
self:_set_data(tostring(_ffi.cast("uintptr_t", canvas_ffi_buffer)))
|
self:_set_data(tostring(_ffi.cast("uintptr_t", canvas_ffi_buffer)))
|
||||||
end
|
end
|
||||||
|
|
||||||
function crc32(bytes, chksum)
|
|
||||||
local chksum = chksum or 0
|
|
||||||
|
|
||||||
local length = #bytes
|
|
||||||
if type(bytes) == "table" then
|
|
||||||
local buffer_len = _ffi.new('int[1]', length)
|
|
||||||
local buffer = _ffi.new(
|
|
||||||
string.format("char[%s]", length)
|
|
||||||
)
|
|
||||||
for i=1, length do
|
|
||||||
buffer[i - 1] = bytes[i]
|
|
||||||
end
|
|
||||||
bytes = _ffi.string(buffer, buffer_len[0])
|
|
||||||
end
|
|
||||||
return _crc32(bytes, chksum)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Check if given table is an array
|
|
||||||
function is_array(x)
|
|
||||||
if #x > 0 then
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
for k, v in pairs(x) do
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Get entry-point and filename from `entry-point:filename` path
|
|
||||||
function parse_path(path)
|
|
||||||
local index = string.find(path, ':')
|
|
||||||
if index == nil then
|
|
||||||
error("invalid path syntax (':' missing)")
|
|
||||||
end
|
|
||||||
return string.sub(path, 1, index-1), string.sub(path, index+1, -1)
|
|
||||||
end
|
|
||||||
|
|
||||||
function pack.is_installed(packid)
|
function pack.is_installed(packid)
|
||||||
return file.isfile(packid..":package.json")
|
return file.isfile(packid..":package.json")
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user