Skip to content

Commit

Permalink
Updated to allow debugging without debug.getupvalue.
Browse files Browse the repository at this point in the history
  • Loading branch information
pkulchenko committed Sep 24, 2023
1 parent f27d479 commit 457c86a
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/mobdebug.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ end)("os")

local mobdebug = {
_NAME = "mobdebug",
_VERSION = "0.803",
_VERSION = "0.804",
_COPYRIGHT = "Paul Kulchenko",
_DESCRIPTION = "Mobile Remote Debugger for the Lua programming language",
port = os and os.getenv and tonumber((os.getenv("MOBDEBUG_PORT"))) or 8172,
Expand Down Expand Up @@ -73,6 +73,7 @@ if not setfenv then -- Lua 5.2+
-- based on http://lua-users.org/lists/lua-l/2010-06/msg00314.html
-- this assumes f is a function
local function findenv(f)
if not debug.getupvalue then return nil end
local level = 1
repeat
local name, value = debug.getupvalue(f, level)
Expand Down Expand Up @@ -317,7 +318,7 @@ local function stack(start)
-- get upvalues
i = 1
local ups = {}
while func do -- check for func as it may be nil for tail calls
while func and debug.getupvalue do -- check for func as it may be nil for tail calls
local name, value = debug.getupvalue(func, i)
if not name then break end
ups[name] = {value, select(2,pcall(tostring,value))}
Expand Down Expand Up @@ -397,7 +398,7 @@ local function restore_vars(vars)

i = 1
local func = debug.getinfo(3, "f").func
while true do
while debug.getupvalue do
local name = debug.getupvalue(func, i)
if not name then break end
if not written_vars[name] then
Expand All @@ -417,7 +418,7 @@ local function capture_vars(level, thread)

local vars = {['...'] = {}}
local i = 1
while true do
while debug.getupvalue do
local name, value = debug.getupvalue(func, i)
if not name then break end
if string.sub(name, 1, 1) ~= '(' then vars[name] = value end
Expand Down

0 comments on commit 457c86a

Please sign in to comment.