Software /
code /
prosody
Comparison
util/debug.lua @ 5787:9a22586f67eb
util.debug: Fix level of locals when inspecting a coroutine
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sun, 11 Aug 2013 10:42:58 +0100 |
parent | 5786:d50005796a26 |
child | 6777:5de6b93d0190 |
comparison
equal
deleted
inserted
replaced
5786:d50005796a26 | 5787:9a22586f67eb |
---|---|
23 }; | 23 }; |
24 end | 24 end |
25 module("debugx", package.seeall); | 25 module("debugx", package.seeall); |
26 | 26 |
27 function get_locals_table(thread, level) | 27 function get_locals_table(thread, level) |
28 if not thread then | |
29 level = level + 1; -- Skip this function itself | |
30 end | |
31 local locals = {}; | 28 local locals = {}; |
32 for local_num = 1, math.huge do | 29 for local_num = 1, math.huge do |
33 local name, value = debug.getlocal(thread, level, local_num); | 30 local name, value; |
31 if thread then | |
32 name, value = debug.getlocal(thread, level, local_num); | |
33 else | |
34 name, value = debug.getlocal(level+1, local_num); | |
35 end | |
34 if not name then break; end | 36 if not name then break; end |
35 table.insert(locals, { name = name, value = value }); | 37 table.insert(locals, { name = name, value = value }); |
36 end | 38 end |
37 return locals; | 39 return locals; |
38 end | 40 end |