diff options
author | Philipp Gesang <phg42.2a@gmail.com> | 2014-05-05 07:47:48 +0200 |
---|---|---|
committer | Philipp Gesang <phg42.2a@gmail.com> | 2014-05-05 07:47:48 +0200 |
commit | cc7cbd37b22131aa81a58be88da43ad15ea18436 (patch) | |
tree | 056896d2b982ad976e9db1af641913b10c27afce /lualibs-util-deb.lua | |
parent | d758aba692b362c8653e1e4b1b5c13df4346652b (diff) | |
parent | c1310e04a23cfe5d3d795b7e09d91599a3c916a5 (diff) | |
download | lualibs-cc7cbd37b22131aa81a58be88da43ad15ea18436.tar.gz |
Merge pull request #24 from phi-gamma/master
update to 2.1b
Diffstat (limited to 'lualibs-util-deb.lua')
-rw-r--r-- | lualibs-util-deb.lua | 46 |
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 |