summaryrefslogtreecommitdiff
path: root/lualibs-util-deb.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lualibs-util-deb.lua')
-rw-r--r--lualibs-util-deb.lua46
1 files changed, 25 insertions, 21 deletions
diff --git a/lualibs-util-deb.lua b/lualibs-util-deb.lua
index 785373f..ee732b3 100644
--- a/lualibs-util-deb.lua
+++ b/lualibs-util-deb.lua
@@ -92,37 +92,41 @@ end
function debugger.disable()
debug.sethook()
---~ counters[debug.getinfo(2,"f").func] = nil
+ -- counters[debug.getinfo(2,"f").func] = nil
end
---~ debugger.enable()
-
---~ print(math.sin(1*.5))
---~ print(math.sin(1*.5))
---~ print(math.sin(1*.5))
---~ print(math.sin(1*.5))
---~ print(math.sin(1*.5))
-
---~ debugger.disable()
-
---~ print("")
---~ debugger.showstats()
---~ print("")
---~ debugger.showstats(print,3)
-
+-- debugger.enable()
+--
+-- print(math.sin(1*.5))
+-- print(math.sin(1*.5))
+-- print(math.sin(1*.5))
+-- print(math.sin(1*.5))
+-- print(math.sin(1*.5))
+--
+-- debugger.disable()
+--
+-- print("")
+-- debugger.showstats()
+-- print("")
+-- debugger.showstats(print,3)
+--
-- from the lua book:
-function traceback()
- local level = 1
+local function showtraceback(rep) -- from lua site / adapted
+ local level = 2 -- we don't want this function to be reported
+ local reporter = rep or report
while true do
- local info = debug.getinfo(level, "Sl")
+ local info = getinfo(level, "Sl")
if not info then
break
elseif info.what == "C" then
- print(format("%3i : C function",level))
+ reporter("%2i : %s",level-1,"C function")
else
- print(format("%3i : [%s]:%d",level,info.short_src,info.currentline))
+ reporter("%2i : %s : %s",level-1,info.short_src,info.currentline)
end
level = level + 1
end
end
+
+debugger.showtraceback = showtraceback
+-- debug.showtraceback = showtraceback