FreeKill/lua/core/debug.lua
notify b75d8afe62
Scheduler (#194)
简单协程调度器的实现,详细说明请看 docs/dev/scheduler.rst
2023-06-16 10:56:33 +08:00

40 lines
912 B
Lua

-- SPDX-License-Identifier: GPL-3.0-or-later
---@diagnostic disable: lowercase-global
inspect = require "inspect"
dbg = require "debugger"
function PrintWhere()
local info = debug.getinfo(2)
local name = info.name
local line = info.currentline
local namewhat = info.namewhat
local shortsrc = info.short_src
if (namewhat == "method") and
(shortsrc ~= "[C]") and
(not string.find(shortsrc, "/lib")) then
print(shortsrc .. ":" .. line .. ": " .. name)
end
end
--debug.sethook(PrintWhere, "l")
function Traceback()
print(debug.traceback())
end
local msgh = function(err)
fk.qCritical(err)
print(debug.traceback(nil, 2))
end
function Pcall(f, ...)
local ret = { xpcall(f, msgh, ...) }
local err = table.remove(ret, 1)
if err ~= false then
return table.unpack(ret)
end
end
function p(v) print(inspect(v)) end
function pt(t) for k, v in pairs(t) do print(k, v) end end