Skip to content

Commit c3d5e8c

Browse files
committed
Do not use HEAD request if 1 port
If there is only one opening debug port with UNIX domain socket, no need to use HEAD request. Before: ``` $ exe/rdbg -O target.rb DEBUGGER: Debugger can attach via UNIX domain socket (/run/user/1000/ruby-debug-ko1-223816) DEBUGGER: wait for debugger connection... DEBUGGER: Connected. DEBUGGER: GreetingError: HEAD request DEBUGGER: Disconnected. DEBUGGER: Connected. ``` After: ``` $ exe/rdbg -O target.rb DEBUGGER: Debugger can attach via UNIX domain socket (/run/user/1000/ruby-debug-ko1-223984) DEBUGGER: wait for debugger connection... DEBUGGER: Connected. ```
1 parent 2e130ff commit c3d5e8c

File tree

9 files changed

+17
-13
lines changed

9 files changed

+17
-13
lines changed

.github/workflows/protocol.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
strategy:
2222
fail-fast: false
2323
matrix:
24-
ruby-version: ['2.6', '2.7', '3.0', '3.1', 'head', 'debug']
24+
ruby-version: ["2.7", "3.0", "3.1", "head", "debug"]
2525

2626
steps:
2727
- uses: actions/checkout@v4

.github/workflows/ruby.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
strategy:
2222
fail-fast: false
2323
matrix:
24-
ruby-version: ['2.6', '2.7', '3.0', '3.1', '3.2', 'head', 'debug']
24+
ruby-version: ["2.7", "3.0", "3.1", "3.2", "head", "debug"]
2525

2626
steps:
2727
- uses: actions/checkout@v4

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,7 @@ config set no_color true
477477
* `RUBY_DEBUG_NO_RELINE` (`no_reline`): Do not use Reline library (default: false)
478478
* `RUBY_DEBUG_NO_HINT` (`no_hint`): Do not show the hint on the REPL (default: false)
479479
* `RUBY_DEBUG_NO_LINENO` (`no_lineno`): Do not show line numbers (default: false)
480+
* `RUBY_DEBUG_IRB_CONSOLE` (`irb_console`): Use IRB as the console (default: false)
480481

481482
* CONTROL
482483
* `RUBY_DEBUG_SKIP_PATH` (`skip_path`): Skip showing/entering frames for given paths

debug.gemspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
1010
spec.description = %q{Debugging functionality for Ruby. This is completely rewritten debug.rb which was contained by the ancient Ruby versions.}
1111
spec.homepage = "https://github.com/ruby/debug"
1212
spec.licenses = ["Ruby", "BSD-2-Clause"]
13-
spec.required_ruby_version = Gem::Requirement.new(">= 2.6.0")
13+
spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
1414

1515
spec.metadata["homepage_uri"] = spec.homepage
1616
spec.metadata["source_code_uri"] = spec.homepage
@@ -27,6 +27,6 @@ Gem::Specification.new do |spec|
2727
spec.require_paths = ["lib"]
2828
spec.extensions = ['ext/debug/extconf.rb']
2929

30-
spec.add_dependency "irb", ">= 1.5.0" # for binding.irb(show_code: false)
30+
spec.add_dependency "irb", ">= 1.8.3" # for irb:debug integration
3131
spec.add_dependency "reline", ">= 0.3.8"
3232
end

lib/debug/client.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,15 +165,16 @@ def connect_unix name = nil
165165
end
166166
else
167167
Client.cleanup_unix_domain_sockets
168-
files = Client.list_connections verbose: true
168+
files = Client.list_connections
169169

170170
case files.size
171171
when 0
172172
$stderr.puts "No debug session is available."
173173
exit
174174
when 1
175-
@s = Socket.unix(files.first.first)
175+
@s = Socket.unix(files.first)
176176
else
177+
files = Client.list_connections verbose: true
177178
$stderr.puts "Please select a debug session:"
178179
files.each{|(f, desc)|
179180
$stderr.puts " #{File.basename(f)} (#{desc})"

lib/debug/config.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ module DEBUGGER__
2222
no_reline: ['RUBY_DEBUG_NO_RELINE', "UI: Do not use Reline library", :bool, "false"],
2323
no_hint: ['RUBY_DEBUG_NO_HINT', "UI: Do not show the hint on the REPL", :bool, "false"],
2424
no_lineno: ['RUBY_DEBUG_NO_LINENO', "UI: Do not show line numbers", :bool, "false"],
25+
irb_console: ["RUBY_DEBUG_IRB_CONSOLE", "UI: Use IRB as the console", :bool, "false"],
2526

2627
# control setting
2728
skip_path: ['RUBY_DEBUG_SKIP_PATH', "CONTROL: Skip showing/entering frames for given paths", :path],

lib/debug/session.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,11 @@ def activate ui = nil, on_fork: false
202202
end
203203
@tp_thread_end.enable
204204

205+
if CONFIG[:irb_console]
206+
require_relative "irb_integration"
207+
thc.activate_irb_integration
208+
end
209+
205210
# session start
206211
q << true
207212
session_server_main

lib/debug/thread_client.rb

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,13 +1048,8 @@ def wait_next_action_
10481048
when :call
10491049
result = frame_eval(eval_src)
10501050
when :irb
1051-
require 'irb' # prelude's binding.irb doesn't have show_code option
1052-
begin
1053-
result = frame_eval('binding.irb(show_code: false)', binding_location: true)
1054-
ensure
1055-
# workaround: https://github.com/ruby/debug/issues/308
1056-
Reline.prompt_proc = nil if defined? Reline
1057-
end
1051+
require_relative "irb_integration"
1052+
activate_irb_integration
10581053
when :display, :try_display
10591054
failed_results = []
10601055
eval_src.each_with_index{|src, i|

test/support/console_test_case.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ def prepare_test_environment(program, test_steps, &block)
217217
ENV['RUBY_DEBUG_TEST_UI'] = 'terminal'
218218
ENV['RUBY_DEBUG_NO_RELINE'] = 'true'
219219
ENV['RUBY_DEBUG_HISTORY_FILE'] = ''
220+
ENV['TERM'] = 'dumb'
220221

221222
write_temp_file(strip_line_num(program))
222223
@scenario = []

0 commit comments

Comments
 (0)