Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src/mobdebug.lua: fix cases when the server sends the data before the mobdebug starts to receive it #77

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/mobdebug.lua
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ local step_level = 0
local stack_level = 0
local server
local buf
local start_input_line
local start_input_error
local outputs = {}
local iobase = {print = print}
local basedir = ""
Expand Down Expand Up @@ -778,7 +780,13 @@ local function debugger_loop(sev, svars, sfile, sline)
local line, err
if mobdebug.yield and server.settimeout then server:settimeout(mobdebug.yieldtimeout) end
while true do
line, err = server:receive("*l")
if start_input_line then
line, err = start_input_line, start_input_error
start_input_line = nil
start_input_error = nil
else
line, err = server:receive("*l")
end
if not line then
if err == "timeout" then
if mobdebug.yield then mobdebug.yield() end
Expand Down Expand Up @@ -1069,6 +1077,10 @@ local function start(controller_host, controller_port)
local err
server, err = mobdebug.connect(controller_host, controller_port)
if server then
local line, receive_err = server:receive("*l")
start_input_line = line
start_input_error = receive_err

-- correct stack depth which already has some calls on it
-- so it doesn't go into negative when those calls return
-- as this breaks subsequence checks in stack_depth().
Expand Down