Software /
code /
prosody
Comparison
util/debug.lua @ 5786:d50005796a26
util.debug: Further fix to display locals in extended tracebacks
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sat, 10 Aug 2013 20:40:45 +0100 |
parent | 5785:b2d6c5f94aa5 |
child | 5787:9a22586f67eb |
comparison
equal
deleted
inserted
replaced
5785:b2d6c5f94aa5 | 5786:d50005796a26 |
---|---|
22 location = _("yellow"); | 22 location = _("yellow"); |
23 }; | 23 }; |
24 end | 24 end |
25 module("debugx", package.seeall); | 25 module("debugx", package.seeall); |
26 | 26 |
27 function get_locals_table(level) | 27 function get_locals_table(thread, level) |
28 level = level + 1; -- Skip this function itself | 28 if not thread then |
29 level = level + 1; -- Skip this function itself | |
30 end | |
29 local locals = {}; | 31 local locals = {}; |
30 for local_num = 1, math.huge do | 32 for local_num = 1, math.huge do |
31 local name, value = debug.getlocal(level, local_num); | 33 local name, value = debug.getlocal(thread, level, local_num); |
32 if not name then break; end | 34 if not name then break; end |
33 table.insert(locals, { name = name, value = value }); | 35 table.insert(locals, { name = name, value = value }); |
34 end | 36 end |
35 return locals; | 37 return locals; |
36 end | 38 end |
95 if not info then break; end | 97 if not info then break; end |
96 | 98 |
97 levels[(level-start_level)+1] = { | 99 levels[(level-start_level)+1] = { |
98 level = level; | 100 level = level; |
99 info = info; | 101 info = info; |
100 locals = not thread and get_locals_table(level+1); | 102 locals = get_locals_table(thread, level+(thread and 0 or 1)); |
101 upvalues = get_upvalues_table(info.func); | 103 upvalues = get_upvalues_table(info.func); |
102 }; | 104 }; |
103 end | 105 end |
104 return levels; | 106 return levels; |
105 end | 107 end |