Changeset

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
parents 5786:d50005796a26
children 5788:3556f338caa3
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:40:45 2013 +0100
+++ b/util/debug.lua	Sun Aug 11 10:42:58 2013 +0100
@@ -25,12 +25,14 @@
 module("debugx", package.seeall);
 
 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(thread, level, local_num);
+		local name, value;
+		if thread then
+			name, value = debug.getlocal(thread, level, local_num);
+		else
+			name, value = debug.getlocal(level+1, local_num);
+		end
 		if not name then break; end
 		table.insert(locals, { name = name, value = value });
 	end