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

Fix compatibility with Fiber Scheduler. #987

Merged
merged 4 commits into from
Dec 8, 2023
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
27 changes: 20 additions & 7 deletions lib/debug/thread_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@

require_relative 'color'

class ::Thread
attr_accessor :debug_thread_client
end

module DEBUGGER__
M_INSTANCE_VARIABLES = method(:instance_variables).unbind
M_INSTANCE_VARIABLE_GET = method(:instance_variable_get).unbind
Expand Down Expand Up @@ -48,12 +52,7 @@ def safe_global_variables

class ThreadClient
def self.current
if thc = Thread.current[:DEBUGGER__ThreadClient]
thc
else
thc = SESSION.get_thread_client
Thread.current[:DEBUGGER__ThreadClient] = thc
end
Thread.current.debug_thread_client ||= SESSION.get_thread_client
end

include Color
Expand Down Expand Up @@ -862,8 +861,22 @@ def make_breakpoint args
class SuspendReplay < Exception
end

if ::Fiber.respond_to?(:blocking)
private def fiber_blocking
::Fiber.blocking{yield}
end
elsif ::Fiber.method_defined?(:blocking?)
private def fiber_blocking
::Fiber.new(blocking: true){yield}.resume
end
else
private def fiber_blocking
yield
end
end

def wait_next_action
wait_next_action_
fiber_blocking{wait_next_action_}
rescue SuspendReplay
replay_suspend
end
Expand Down
2 changes: 1 addition & 1 deletion test/support/cdp_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def connect_to_cdp_server
MSG
end

TIMEOUT_SEC = (ENV['RUBY_DEBUG_TIMEOUT_SEC'] || 10).to_i
TIMEOUT_SEC = (ENV['RUBY_DEBUG_TIMEOUT_SEC'] || 30).to_i
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you extend the timeout?
this extension will introduce huge slowdown on some cases.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found the test runner was timing out on GitHub actions even in HEAD.

HOST = '127.0.0.1'

def run_cdp_scenario program, &msgs
Expand Down
2 changes: 1 addition & 1 deletion test/support/dap_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def connect_to_dap_server test_info
sock
end

TIMEOUT_SEC = (ENV['RUBY_DEBUG_TIMEOUT_SEC'] || 10).to_i
TIMEOUT_SEC = (ENV['RUBY_DEBUG_TIMEOUT_SEC'] || 30).to_i

def run_dap_scenario program, &msgs
begin
Expand Down
2 changes: 1 addition & 1 deletion test/support/protocol_test_case.rb
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ def send **kw
end
end

TIMEOUT_SEC = (ENV['RUBY_DEBUG_TIMEOUT_SEC'] || 10).to_i
TIMEOUT_SEC = (ENV['RUBY_DEBUG_TIMEOUT_SEC'] || 30).to_i

def assert_dap_response expected_def, result_res
return unless defined? DAP_HASH
Expand Down
2 changes: 1 addition & 1 deletion test/support/test_case.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def debug_print msg
RUBY = ENV['RUBY'] || RbConfig.ruby
RDBG_EXECUTABLE = "#{RUBY} #{__dir__}/../../exe/rdbg"

TIMEOUT_SEC = (ENV['RUBY_DEBUG_TIMEOUT_SEC'] || 10).to_i
TIMEOUT_SEC = (ENV['RUBY_DEBUG_TIMEOUT_SEC'] || 30).to_i

def get_target_ui
ENV['RUBY_DEBUG_TEST_UI']
Expand Down