Permalink
Browse files

reset trace.on

  • Loading branch information...
1 parent 66355a2 commit e2d36ce89bdf90a19658c96b9f6e447857ade841 @cloudwu committed Mar 21, 2012
Showing with 12 additions and 6 deletions.
  1. +9 −2 main.lua
  2. +3 −4 trace.lua
View
@@ -7,10 +7,17 @@ local function factorial(n)
return factorial(n-1) * n
end
-function foo()
- trace.trace("n s",3)
+function foo(n)
+ trace.trace("n s",n)
local s = factorial(100)
return s
end
+function hello()
+ print "hello"
+end
+
+foo(3)
+hello()
foo()
+
View
@@ -116,15 +116,13 @@ local function hook(var , level)
end
local function f (mode, line)
if mode == 'return' then
- if call < 0 then
+ if call <= 0 then
debug.sethook()
+ trace.on = nil
return
end
setname(3)
call = call - 1
--- if call < level then
--- dump_local(3)
--- end
if call == level then
debug.sethook(f,'crl')
end
@@ -161,6 +159,7 @@ function trace.trace(var , level)
if trace.on then
return
end
+
trace.on = true
info.last = {}
debug.sethook(up(2 , hook(var or "" , level or 0)) , 'cr')

0 comments on commit e2d36ce

Please sign in to comment.