Software /
code /
prosody
Changeset
5785:b2d6c5f94aa5
util.debug: Fixes to make coroutine tracebacks work properly
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sat, 10 Aug 2013 20:30:40 +0100 |
parents | 5784:02217725454b |
children | 5786:d50005796a26 |
files | util/debug.lua |
diffstat | 1 files changed, 10 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/util/debug.lua Sat Aug 10 20:19:40 2013 +0200 +++ b/util/debug.lua Sat Aug 10 20:30:40 2013 +0100 @@ -88,7 +88,7 @@ for level = start_level, math.huge do local info; if thread then - info = debug.getinfo(thread, level+1); + info = debug.getinfo(thread, level); else info = debug.getinfo(level+1); end @@ -97,7 +97,7 @@ levels[(level-start_level)+1] = { level = level; info = info; - locals = get_locals_table(level+1); + locals = not thread and get_locals_table(level+1); upvalues = get_upvalues_table(info.func); }; end @@ -134,12 +134,12 @@ return nil; -- debug.traceback() does this end - level = level or 1; + level = level or 0; message = message and (message.."\n") or ""; - -- +3 counts for this function, and the pcall() and wrapper above us - local levels = get_traceback_table(thread, level+3); + -- +3 counts for this function, and the pcall() and wrapper above us, the +1... I don't know. + local levels = get_traceback_table(thread, level+(thread == nil and 4 or 0)); local last_source_desc; @@ -171,9 +171,11 @@ nlevel = nlevel-1; table.insert(lines, "\t"..(nlevel==0 and ">" or " ")..getstring(styles.level_num, "("..nlevel..") ")..line); local npadding = (" "):rep(#tostring(nlevel)); - local locals_str = string_from_var_table(level.locals, optimal_line_length, "\t "..npadding); - if locals_str then - table.insert(lines, "\t "..npadding.."Locals: "..locals_str); + if level.locals then + local locals_str = string_from_var_table(level.locals, optimal_line_length, "\t "..npadding); + if locals_str then + table.insert(lines, "\t "..npadding.."Locals: "..locals_str); + end end local upvalues_str = string_from_var_table(level.upvalues, optimal_line_length, "\t "..npadding); if upvalues_str then