aboutsummaryrefslogtreecommitdiff
path: root/libs/lua/test/trace-calls.lua
diff options
context:
space:
mode:
authorPavel Labath <pavelo@centrum.sk>2011-05-16 10:58:21 (GMT)
committerPavel Labath <pavelo@centrum.sk>2011-11-01 09:52:45 (GMT)
commit3c1d7bb1c521e824dfa46903fd4014722d0f5a29 (patch)
treeb9d8ab1f95aa608cbef817550ccc4bd42534dcd6 /libs/lua/test/trace-calls.lua
parent2223c879bf41d2b4f40fa43db478ba1bce8523de (diff)
downloadfluxbox_paul-3c1d7bb1c521e824dfa46903fd4014722d0f5a29.zip
fluxbox_paul-3c1d7bb1c521e824dfa46903fd4014722d0f5a29.tar.bz2
Add lua as an internal library in libs/lua
Diffstat (limited to 'libs/lua/test/trace-calls.lua')
-rw-r--r--libs/lua/test/trace-calls.lua32
1 files changed, 32 insertions, 0 deletions
diff --git a/libs/lua/test/trace-calls.lua b/libs/lua/test/trace-calls.lua
new file mode 100644
index 0000000..6d7a7b3
--- /dev/null
+++ b/libs/lua/test/trace-calls.lua
@@ -0,0 +1,32 @@
1-- trace calls
2-- example: lua -ltrace-calls bisect.lua
3
4local level=0
5
6local function hook(event)
7 local t=debug.getinfo(3)
8 io.write(level," >>> ",string.rep(" ",level))
9 if t~=nil and t.currentline>=0 then io.write(t.short_src,":",t.currentline," ") end
10 t=debug.getinfo(2)
11 if event=="call" then
12 level=level+1
13 else
14 level=level-1 if level<0 then level=0 end
15 end
16 if t.what=="main" then
17 if event=="call" then
18 io.write("begin ",t.short_src)
19 else
20 io.write("end ",t.short_src)
21 end
22 elseif t.what=="Lua" then
23-- table.foreach(t,print)
24 io.write(event," ",t.name or "(Lua)"," <",t.linedefined,":",t.short_src,">")
25 else
26 io.write(event," ",t.name or "(C)"," [",t.what,"] ")
27 end
28 io.write("\n")
29end
30
31debug.sethook(hook,"cr")
32level=0