diff options
author | sanine <sanine.not@pm.me> | 2022-08-23 13:38:27 -0500 |
---|---|---|
committer | sanine <sanine.not@pm.me> | 2022-08-23 13:38:27 -0500 |
commit | 3afbf2a13b2dada445fb667bf25600407fea480a (patch) | |
tree | 551329e6f74fc9f177616de0d6739e8b5331ae96 /libs/lua-5.1.5/test/trace-calls.lua | |
parent | 261e3f991221fbad6bbf262f5e65b773e4b6c73e (diff) | |
parent | 25ed7eb9f84e9a822f698ad803901fbb2a5354cf (diff) |
:wMerge branch 'gl-window' into main
Diffstat (limited to 'libs/lua-5.1.5/test/trace-calls.lua')
-rw-r--r-- | libs/lua-5.1.5/test/trace-calls.lua | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/libs/lua-5.1.5/test/trace-calls.lua b/libs/lua-5.1.5/test/trace-calls.lua new file mode 100644 index 0000000..6d7a7b3 --- /dev/null +++ b/libs/lua-5.1.5/test/trace-calls.lua @@ -0,0 +1,32 @@ +-- trace calls +-- example: lua -ltrace-calls bisect.lua + +local level=0 + +local function hook(event) + local t=debug.getinfo(3) + io.write(level," >>> ",string.rep(" ",level)) + if t~=nil and t.currentline>=0 then io.write(t.short_src,":",t.currentline," ") end + t=debug.getinfo(2) + if event=="call" then + level=level+1 + else + level=level-1 if level<0 then level=0 end + end + if t.what=="main" then + if event=="call" then + io.write("begin ",t.short_src) + else + io.write("end ",t.short_src) + end + elseif t.what=="Lua" then +-- table.foreach(t,print) + io.write(event," ",t.name or "(Lua)"," <",t.linedefined,":",t.short_src,">") + else + io.write(event," ",t.name or "(C)"," [",t.what,"] ") + end + io.write("\n") +end + +debug.sethook(hook,"cr") +level=0 |