11--
22-- MobDebug -- Lua remote debugger
3- -- Copyright 2011-15 Paul Kulchenko
3+ -- Copyright 2011-18 Paul Kulchenko
44-- Based on RemDebug 1.0 Copyright Kepler Project 2005
55--
66
@@ -19,7 +19,7 @@ end)("os")
1919
2020local mobdebug = {
2121 _NAME = " mobdebug" ,
22- _VERSION = " 0.70 " ,
22+ _VERSION = " 0.703 " ,
2323 _COPYRIGHT = " Paul Kulchenko" ,
2424 _DESCRIPTION = " Mobile Remote Debugger for the Lua programming language" ,
2525 port = os and os.getenv and tonumber ((os.getenv (" MOBDEBUG_PORT" ))) or 8172 ,
130130local function q (s ) return string.gsub (s , ' ([%(%)%.%%%+%-%*%?%[%^%$%]])' ,' %%%1' ) end
131131
132132local serpent = (function () ---- include Serpent module for serialization
133- local n , v = " serpent" , " 0.30 " -- (C) 2012-17 Paul Kulchenko; MIT License
133+ local n , v = " serpent" , " 0.301 " -- (C) 2012-17 Paul Kulchenko; MIT License
134134local c , d = " Paul Kulchenko" , " Lua serializer and pretty printer"
135135local snum = {[tostring (1 / 0 )]= ' 1/0 --[[math.huge]]' ,[tostring (- 1 / 0 )]= ' -1/0 --[[-math.huge]]' ,[tostring (0 / 0 )]= ' 0/0' }
136136local badtype = {thread = true , userdata = true , cdata = true }
@@ -183,10 +183,10 @@ local function s(t, opts)
183183 sref [# sref + 1 ] = spath .. space .. ' =' .. space .. seen [t ]
184184 return tag .. ' nil' .. comment (' ref' , level ) end
185185 -- protect from those cases where __tostring may fail
186- if type (mt ) == ' table' then
186+ if type (mt ) == ' table' and metatostring ~= false then
187187 local to , tr = pcall (function () return mt .__tostring (t ) end )
188188 local so , sr = pcall (function () return mt .__serialize (t ) end )
189- if (opts . metatostring ~= false and to or so ) then -- knows how to serialize itself
189+ if (to or so ) then -- knows how to serialize itself
190190 seen [t ] = insref or spath
191191 t = so and sr or tr
192192 ttype = type (t )
@@ -1163,8 +1163,12 @@ local function controller(controller_host, controller_port, scratchpad)
11631163 if abort then
11641164 if tostring (abort ) == ' exit' then break end
11651165 else
1166- if status then -- normal execution is done
1167- break
1166+ if status then -- no errors
1167+ if corostatus (coro_debugee ) == " suspended" then
1168+ -- the script called `coroutine.yield` in the "main" thread
1169+ error (" attempt to yield from the main thread" , 3 )
1170+ end
1171+ break -- normal execution is done
11681172 elseif err and not string.find (tostring (err ), deferror ) then
11691173 -- report the error back
11701174 -- err is not necessarily a string, so convert to string to report
@@ -1401,9 +1405,9 @@ local function handle(params, client, options)
14011405 elseif command == " reload" then
14021406 client :send (" LOAD 0 -\n " )
14031407 elseif command == " loadstring" then
1404- local _ , _ , _ , file , lines = string.find (exp , " ^([\" '])(.-)%1%s+ (.+)" )
1408+ local _ , _ , _ , file , lines = string.find (exp , " ^([\" '])(.-)%1%s(.+)" )
14051409 if not file then
1406- _ , _ , file , lines = string.find (exp , " ^(%S+)%s+ (.+)" )
1410+ _ , _ , file , lines = string.find (exp , " ^(%S+)%s(.+)" )
14071411 end
14081412 client :send (" LOAD " .. tostring (# lines ) .. " " .. file .. " \n " )
14091413 client :send (lines )
0 commit comments