Changeset

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
parents 5785:b2d6c5f94aa5
children 5787:9a22586f67eb
files util/debug.lua
diffstat 1 files changed, 6 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/util/debug.lua	Sat Aug 10 20:30:40 2013 +0100
+++ b/util/debug.lua	Sat Aug 10 20:40:45 2013 +0100
@@ -24,11 +24,13 @@
 end
 module("debugx", package.seeall);
 
-function get_locals_table(level)
-	level = level + 1; -- Skip this function itself
+function get_locals_table(thread, level)
+	if not thread then
+		level = level + 1; -- Skip this function itself
+	end
 	local locals = {};
 	for local_num = 1, math.huge do
-		local name, value = debug.getlocal(level, local_num);
+		local name, value = debug.getlocal(thread, level, local_num);
 		if not name then break; end
 		table.insert(locals, { name = name, value = value });
 	end
@@ -97,7 +99,7 @@
 		levels[(level-start_level)+1] = {
 			level = level;
 			info = info;
-			locals = not thread and get_locals_table(level+1);
+			locals = get_locals_table(thread, level+(thread and 0 or 1));
 			upvalues = get_upvalues_table(info.func);
 		};
 	end