-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebugOutOfMemory.lua
More file actions
35 lines (35 loc) · 1.27 KB
/
Copy pathdebugOutOfMemory.lua
File metadata and controls
35 lines (35 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
local data, running
function dbg()
if running then
debug.sethook()
running = false
io.save("mlog.txt", table.concat(data, "\r\n"))
return
end
running = true
data = {}
local func
debug.sethook(function(event, line)
local info = debug.getinfo(2, "nSf")
if event == "line" then
if not func or func ~= info.func then
table.insert(data, string.format(
"%s:%d: function %s (what: %s), func type: %s", info.short_src, line, info.name or "", info.namewhat or "", info.what or ""
))
func = info.func
else
table.insert(data, string.format(
"%s:%d", info.short_src, line
))
end
elseif event == "return" then
table.insert(data, string.format(
"%s: RETURN FROM function %s (what: %s), func type: %s", info.short_src, info.name or "", info.namewhat or "", info.what or ""
))
elseif event == "call" then
table.insert(data, string.format(
"%s: CALL function %s (what: %s), func type: %s", info.short_src, info.name or "", info.namewhat or "", info.what or ""
))
end
end, "crl")
end