diff options
author | chai <chaifix@163.com> | 2018-12-07 01:18:45 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2018-12-07 01:18:45 +0800 |
commit | afc5ebdeece428d4ef72f4f1f4b178a92d1b9cba (patch) | |
tree | 664aff4bdf9841346f044cb2a2f3cb4b55eba386 /src/3rdparty/lua-5.1.5/test/trace-calls.lua | |
parent | 1acc1ecf398bc43bc304a449643fddbb65d1e733 (diff) |
+lua51
Diffstat (limited to 'src/3rdparty/lua-5.1.5/test/trace-calls.lua')
-rw-r--r-- | src/3rdparty/lua-5.1.5/test/trace-calls.lua | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/3rdparty/lua-5.1.5/test/trace-calls.lua b/src/3rdparty/lua-5.1.5/test/trace-calls.lua new file mode 100644 index 0000000..6d7a7b3 --- /dev/null +++ b/src/3rdparty/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 |