Skip to content
Merged
Show file tree
Hide file tree
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
23 changes: 17 additions & 6 deletions lib/debug/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ def initialize
@accept_m = Mutex.new
@accept_cv = ConditionVariable.new
@client_addr = nil
@q_msg = Queue.new
@q_ans = Queue.new
@q_msg = nil
@q_ans = nil
@unsent_messages = []
@width = 80

Expand All @@ -38,6 +38,9 @@ def initialize
@sock.puts m
}
@unsent_messages.clear

@q_msg = Queue.new
@q_ans = Queue.new
}

setup_interrupt do
Expand All @@ -50,7 +53,9 @@ def initialize
DEBUGGER__.message "Disconnected."
@sock = nil
@q_msg.close
@q_msg = nil
@q_ans.close
@q_ans = nil
end
end
end
Expand Down Expand Up @@ -83,9 +88,6 @@ def greeting
end

def process
@q_msg = Queue.new
@q_ans = Queue.new

pause

while line = @sock.gets
Expand Down Expand Up @@ -143,7 +145,15 @@ def sock skip: false
if s = @sock # already connection
# ok
elsif skip == true # skip process
return yield nil
no_sock = true
r = @accept_m.synchronize do
if @sock
no_sock = false
else
yield nil
end
end
return r if no_sock
else # wait for connection
until s = @sock
@accept_m.synchronize{
Expand Down Expand Up @@ -192,6 +202,7 @@ def puts str = nil
def readline
(sock do |s|
s.puts "input"
sleep 0.01 until @q_msg
@q_msg.pop
end || 'continue').strip
end
Expand Down
6 changes: 3 additions & 3 deletions test/support/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,15 @@ def debug_on_local boot_options

def debug_on_unix_domain_socket repl_prompt = '(rdbg:remote)'
@mode = 'UNIX DOMAIN SOCKET'
boot_options = '-r debug/open'
cmd = "#{__dir__}/../../exe/rdbg -A"
setup_remote_debuggee("#{RUBY} #{boot_options} #{temp_file_path}")
setup_remote_debuggee("#{__dir__}/../../exe/rdbg -O -- #{temp_file_path}")
run_test_scenario(cmd, repl_prompt)
end

def debug_on_tcpip repl_prompt = '(rdbg:remote)'
@mode = 'TCP/IP'
cmd = "#{__dir__}/../../exe/rdbg -A #{RUBY_DEBUG_TEST_PORT}"
setup_remote_debuggee("#{__dir__}/../../exe/rdbg -O --port=#{RUBY_DEBUG_TEST_PORT} #{temp_file_path}")
setup_remote_debuggee("#{__dir__}/../../exe/rdbg -O --port=#{RUBY_DEBUG_TEST_PORT} -- #{temp_file_path}")
run_test_scenario(cmd, repl_prompt)
end

Expand Down Expand Up @@ -103,6 +102,7 @@ def run_test_scenario(cmd, repl_prompt)
write.puts(cmd)
cmd = @queue.pop
end

write.puts(cmd)
@last_backlog.clear
next # INTERNAL_INFO shouldn't be pushed into @backlog and @last_backlog
Expand Down