Skip to content

Commit bf27331

Browse files
committed
Update default and bundled gems
1 parent 079eac0 commit bf27331

File tree

190 files changed

+462
-276
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

190 files changed

+462
-276
lines changed

lib/gems/gems/debug-1.9.1/ext/debug/debug_version.h

-1
This file was deleted.

lib/gems/gems/debug-1.9.1/Gemfile renamed to lib/gems/gems/debug-1.9.2/Gemfile

+1
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ gem "rake-compiler"
77
gem "test-unit", "~> 3.0"
88
gem "test-unit-rr"
99
gem "json-schema"
10+
gem "test-unit-launchable"

lib/gems/gems/debug-1.9.1/README.md renamed to lib/gems/gems/debug-1.9.2/README.md

+33-9
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ New debug.rb has several advantages:
1313
* TCP/IP
1414
* Integration with rich debugger frontends
1515

16-
Frontend | [Console](https://github.com/ruby/debug#invoke-as-a-remote-debuggee) | [VSCode](https://github.com/ruby/debug#vscode-integration) | [Chrome DevTool](#chrome-devtool-integration) |
17-
---|---|---|---|
18-
Connection | UDS, TCP/IP | UDS, TCP/IP | TCP/IP |
19-
Requirement | No | [vscode-rdbg](https://marketplace.visualstudio.com/items?itemName=KoichiSasada.vscode-rdbg) | Chrome |
16+
| Frontend | [Console](https://github.com/ruby/debug#invoke-as-a-remote-debuggee) | [VSCode](https://github.com/ruby/debug#vscode-integration) | [Chrome DevTool](#chrome-devtool-integration) |
17+
| ----------- | -------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | --------------------------------------------- |
18+
| Connection | UDS, TCP/IP | UDS, TCP/IP | TCP/IP |
19+
| Requirement | No | [vscode-rdbg](https://marketplace.visualstudio.com/items?itemName=KoichiSasada.vscode-rdbg) | Chrome |
2020

2121
* Extensible: application can introduce debugging support in several ways:
2222
* By `rdbg` command
@@ -289,10 +289,10 @@ You can run your application as a remote debuggee, and the remote debugger conso
289289

290290
There are multiple ways to run your program as a debuggee:
291291

292-
Stop at program start | [`rdbg` option](https://github.com/ruby/debug#rdbg---open-or-rdbg--o-for-short) | [require](https://github.com/ruby/debug#require-debugopen-in-a-program) | [debugger API](https://github.com/ruby/debug#start-by-method)
293-
---|---|---|---|
294-
Yes | `rdbg --open` | `require "debug/open"` | `DEBUGGER__.open`
295-
No | `rdbg --open --nonstop` | `require "debug/open_nonstop"` | `DEBUGGER__.open(nonstop: true)`
292+
| Stop at program start | [`rdbg` option](https://github.com/ruby/debug#rdbg---open-or-rdbg--o-for-short) | [require](https://github.com/ruby/debug#require-debugopen-in-a-program) | [debugger API](https://github.com/ruby/debug#start-by-method) |
293+
| --------------------- | ------------------------------------------------------------------------------- | ----------------------------------------------------------------------- | ------------------------------------------------------------- |
294+
| Yes | `rdbg --open` | `require "debug/open"` | `DEBUGGER__.open` |
295+
| No | `rdbg --open --nonstop` | `require "debug/open_nonstop"` | `DEBUGGER__.open(nonstop: true)` |
296296

297297
#### `rdbg --open` (or `rdbg -O` for short)
298298

@@ -713,7 +713,7 @@ The `<...>` notation means the argument.
713713
* `eval <expr>`
714714
* Evaluate `<expr>` on the current frame.
715715
* `irb`
716-
* Invoke `irb` on the current frame.
716+
* Activate and switch to `irb:rdbg` console
717717

718718
### Trace
719719

@@ -784,6 +784,30 @@ The `<...>` notation means the argument.
784784
* Show help for the given command.
785785

786786

787+
### Using IRB as the Debug Console
788+
789+
Starting from version `v1.9`, you can now use IRB as the debug console. This integration brings additional features such as:
790+
791+
* Autocompletion
792+
* Support for multi-line input
793+
* Access to commands not available in `debug`, like `show_source` or `show_doc`
794+
* [Configurable command aliases](https://docs.ruby-lang.org/en/master/IRB.html#module-IRB-label-Command+Aliases)
795+
796+
To switch to the IRB console, simply use the `irb` command in the debug console.
797+
798+
Once activated, you'll notice the prompt changes to:
799+
800+
```txt
801+
irb:rdbg(main):001>
802+
```
803+
804+
If you want to make IRB the default console for all sessions, configure the `irb_console` setting by either:
805+
806+
* Setting the `RUBY_DEBUG_IRB_CONSOLE=true` environment variable
807+
* Or adding `config set irb_console 1` to your `~/.rdbgrc`
808+
809+
To disable the IRB console in the current session, execute `config set irb_console 0` in the console.
810+
787811
## Debugger API
788812

789813
### Start debugging
File renamed without changes.

lib/gems/gems/debug-1.9.1/ext/debug/debug.c renamed to lib/gems/gems/debug-1.9.2/ext/debug/debug.c

+10-10
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ static VALUE rb_mDebugger;
88

99
// iseq
1010
typedef struct rb_iseq_struct rb_iseq_t;
11+
const rb_iseq_t *rb_iseqw_to_iseq(VALUE iseqw);
1112
VALUE rb_iseq_realpath(const rb_iseq_t *iseq);
1213

1314
static VALUE
1415
iseq_realpath(VALUE iseqw)
1516
{
16-
rb_iseq_t *iseq = DATA_PTR(iseqw);
17-
return rb_iseq_realpath(iseq);
17+
return rb_iseq_realpath(rb_iseqw_to_iseq(iseqw));
1818
}
1919

2020
static VALUE rb_cFrameInfo;
@@ -121,26 +121,26 @@ frame_depth(VALUE self)
121121

122122
// iseq
123123

124-
const struct rb_iseq *rb_iseqw_to_iseq(VALUE iseqw);
124+
const rb_iseq_t *rb_iseqw_to_iseq(VALUE iseqw);
125125

126126
#ifdef HAVE_RB_ISEQ_TYPE
127-
VALUE rb_iseq_type(const struct rb_iseq *);
127+
VALUE rb_iseq_type(const rb_iseq_t *);
128128

129129
static VALUE
130130
iseq_type(VALUE iseqw)
131131
{
132-
const struct rb_iseq *iseq = rb_iseqw_to_iseq(iseqw);
132+
const rb_iseq_t *iseq = rb_iseqw_to_iseq(iseqw);
133133
return rb_iseq_type(iseq);
134134
}
135135
#endif
136136

137137
#ifdef HAVE_RB_ISEQ_PARAMETERS
138-
VALUE rb_iseq_parameters(const struct rb_iseq *, int is_proc);
138+
VALUE rb_iseq_parameters(const rb_iseq_t *, int is_proc);
139139

140140
static VALUE
141141
iseq_parameters_symbols(VALUE iseqw)
142142
{
143-
const struct rb_iseq *iseq = rb_iseqw_to_iseq(iseqw);
143+
const rb_iseq_t *iseq = rb_iseqw_to_iseq(iseqw);
144144
VALUE params = rb_iseq_parameters(iseq, 0);
145145
VALUE ary = rb_ary_new();
146146

@@ -167,12 +167,12 @@ iseq_parameters_symbols(VALUE iseqw)
167167
#endif
168168

169169
#ifdef HAVE_RB_ISEQ_CODE_LOCATION
170-
void rb_iseq_code_location(const struct rb_iseq *, int *first_lineno, int *first_column, int *last_lineno, int *last_column);
170+
void rb_iseq_code_location(const rb_iseq_t *, int *first_lineno, int *first_column, int *last_lineno, int *last_column);
171171

172172
static VALUE
173173
iseq_first_line(VALUE iseqw)
174174
{
175-
const struct rb_iseq *iseq = rb_iseqw_to_iseq(iseqw);
175+
const rb_iseq_t *iseq = rb_iseqw_to_iseq(iseqw);
176176
int line;
177177
rb_iseq_code_location(iseq, &line, NULL, NULL, NULL);
178178
return INT2NUM(line);
@@ -181,7 +181,7 @@ iseq_first_line(VALUE iseqw)
181181
static VALUE
182182
iseq_last_line(VALUE iseqw)
183183
{
184-
const struct rb_iseq *iseq = rb_iseqw_to_iseq(iseqw);
184+
const rb_iseq_t *iseq = rb_iseqw_to_iseq(iseqw);
185185
int line;
186186
rb_iseq_code_location(iseq, NULL, NULL, &line, NULL);
187187
return INT2NUM(line);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#define RUBY_DEBUG_VERSION "1.9.2"

lib/gems/gems/debug-1.9.1/ext/debug/extconf.rb renamed to lib/gems/gems/debug-1.9.2/ext/debug/extconf.rb

+2-11
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
11
require 'mkmf'
2-
if defined?(::TruffleRuby)
3-
# hardcode the version here to avoid depending on version.rb which is not copied to src/main/c/debug
4-
require "json"
5-
filename = File.expand_path("../../../../versions.json", __dir__)
6-
version = JSON.load(File.read(filename)).dig("gems", "bundled", "debug")
7-
8-
File.write("debug_version.h", "#define RUBY_DEBUG_VERSION \"#{version}\"\n")
9-
else
10-
require_relative '../../lib/debug/version'
11-
File.write("debug_version.h", "#define RUBY_DEBUG_VERSION \"#{DEBUGGER__::VERSION}\"\n")
12-
end
2+
require_relative '../../lib/debug/version'
3+
File.write("debug_version.h", "#define RUBY_DEBUG_VERSION \"#{DEBUGGER__::VERSION}\"\n")
134
$distcleanfiles << "debug_version.h"
145

156
if defined? RubyVM

lib/gems/gems/debug-1.9.1/lib/debug/config.rb renamed to lib/gems/gems/debug-1.9.2/lib/debug/config.rb

+16
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,22 @@ def update conf
158158
SESSION.set_no_sigint_hook old, new
159159
end
160160
end
161+
162+
if_updated old_conf, conf, :irb_console do |old, new|
163+
if defined?(SESSION) && SESSION.active?
164+
# irb_console is switched from true to false
165+
if old
166+
SESSION.deactivate_irb_integration
167+
# irb_console is switched from false to true
168+
else
169+
if CONFIG[:open]
170+
SESSION.instance_variable_get(:@ui).puts "\nIRB is not supported on the remote console."
171+
else
172+
SESSION.activate_irb_integration
173+
end
174+
end
175+
end
176+
end
161177
end
162178

163179
private def if_updated old_conf, new_conf, key

lib/gems/gems/debug-1.9.1/lib/debug/console.rb renamed to lib/gems/gems/debug-1.9.2/lib/debug/console.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def history
143143
rescue LoadError
144144
def readline prompt
145145
print prompt
146-
gets
146+
$stdin.gets
147147
end
148148

149149
def history

lib/gems/gems/debug-1.9.1/lib/debug/irb_integration.rb renamed to lib/gems/gems/debug-1.9.2/lib/debug/irb_integration.rb

+10
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,14 @@ def activate_irb_integration
2424
IRB::Context.prepend(IrbPatch)
2525
end
2626
end
27+
28+
class Session
29+
def deactivate_irb_integration
30+
Reline.completion_proc = nil
31+
Reline.output_modifier_proc = nil
32+
Reline.autocompletion = false
33+
Reline.dig_perfect_match_proc = nil
34+
reset_ui UI_LocalConsole.new
35+
end
36+
end
2737
end

lib/gems/gems/debug-1.9.1/lib/debug/prelude.rb renamed to lib/gems/gems/debug-1.9.2/lib/debug/prelude.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
# Put the following line in your login script (e.g. ~/.bash_profile) with modified path:
77
#
8-
# export RUBYOPT="-r /path/to/debug/prelude $(RUBYOPT)"
8+
# export RUBYOPT="-r /path/to/debug/prelude ${RUBYOPT}"
99
#
1010
module Kernel
1111
def debugger(*a, up_level: 0, **kw)

lib/gems/gems/debug-1.9.1/lib/debug/server_cdp.rb renamed to lib/gems/gems/debug-1.9.2/lib/debug/server_cdp.rb

+8-9
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
require 'json'
44
require 'digest/sha1'
5-
require 'base64'
65
require 'securerandom'
76
require 'stringio'
87
require 'open3'
@@ -131,7 +130,7 @@ def run_new_chrome
131130
stdout.close
132131
data = stderr.readpartial 4096
133132
stderr.close
134-
if data.match /DevTools listening on ws:\/\/127.0.0.1:(\d+)(.*)/
133+
if data.match(/DevTools listening on ws:\/\/127.0.0.1:(\d+)(.*)/)
135134
port = $1
136135
path = $2
137136
end
@@ -158,7 +157,7 @@ def run_new_chrome
158157
raise NotFoundChromeEndpointError
159158
end
160159
stderr.close
161-
if data.match /DevTools listening on ws:\/\/127.0.0.1:(\d+)(.*)/
160+
if data.match(/DevTools listening on ws:\/\/127.0.0.1:(\d+)(.*)/)
162161
port = $1
163162
path = $2
164163
end
@@ -190,7 +189,7 @@ def get_devtools_endpoint tf
190189
while i < ITERATIONS
191190
i += 1
192191
if File.exist?(tf) && data = File.read(tf)
193-
if data.match /DevTools listening on ws:\/\/127.0.0.1:(\d+)(.*)/
192+
if data.match(/DevTools listening on ws:\/\/127.0.0.1:(\d+)(.*)/)
194193
port = $1
195194
path = $2
196195
return [port, path]
@@ -297,8 +296,8 @@ def handshake port, path
297296
res = @sock.readpartial 4092
298297
show_protocol :<, res
299298

300-
if res.match /^Sec-WebSocket-Accept: (.*)\r\n/
301-
correct_key = Base64.strict_encode64 Digest::SHA1.digest "#{key}==258EAFA5-E914-47DA-95CA-C5AB0DC85B11"
299+
if res.match(/^Sec-WebSocket-Accept: (.*)\r\n/)
300+
correct_key = Digest::SHA1.base64digest "#{key}==258EAFA5-E914-47DA-95CA-C5AB0DC85B11"
302301
raise "The Sec-WebSocket-Accept value: #{$1} is not valid" unless $1 == correct_key
303302
else
304303
raise "Unknown response: #{res}"
@@ -378,8 +377,8 @@ def handshake
378377
req = @sock.readpartial 4096
379378
show_protocol '>', req
380379

381-
if req.match /^Sec-WebSocket-Key: (.*)\r\n/
382-
accept = Base64.strict_encode64 Digest::SHA1.digest "#{$1}258EAFA5-E914-47DA-95CA-C5AB0DC85B11"
380+
if req.match(/^Sec-WebSocket-Key: (.*)\r\n/)
381+
accept = Digest::SHA1.base64digest "#{$1}258EAFA5-E914-47DA-95CA-C5AB0DC85B11"
383382
res = "HTTP/1.1 101 Switching Protocols\r\nUpgrade: websocket\r\nConnection: Upgrade\r\nSec-WebSocket-Accept: #{accept}\r\n\r\n"
384383
@sock.print res
385384
show_protocol :<, res
@@ -658,7 +657,7 @@ def get_source_code path
658657

659658
def activate_bp bps
660659
bps.each_key{|k|
661-
if k.match /^\d+:(\d+):(.*)/
660+
if k.match(/^\d+:(\d+):(.*)/)
662661
line = $1
663662
path = $2
664663
SESSION.add_line_breakpoint(path, line.to_i + 1)

lib/gems/gems/debug-1.9.1/lib/debug/session.rb renamed to lib/gems/gems/debug-1.9.2/lib/debug/session.rb

+16-8
Original file line numberDiff line numberDiff line change
@@ -202,18 +202,19 @@ def activate ui = nil, on_fork: false
202202
end
203203
@tp_thread_end.enable
204204

205-
if CONFIG[:irb_console] && !CONFIG[:open]
206-
require_relative "irb_integration"
207-
thc.activate_irb_integration
208-
end
209-
210205
# session start
211206
q << true
212207
session_server_main
213208
end
214209
first_q << :ok
215210

216211
q.pop
212+
213+
# For activating irb:rdbg with startup config like `RUBY_DEBUG_IRB_CONSOLE=1`
214+
# Because in that case the `Config#if_updated` callback would not be triggered
215+
if CONFIG[:irb_console] && !CONFIG[:open]
216+
activate_irb_integration
217+
end
217218
end
218219

219220
def deactivate
@@ -938,14 +939,15 @@ def register_default_command
938939
end
939940

940941
# * `irb`
941-
# * Invoke `irb` on the current frame.
942+
# * Activate and switch to `irb:rdbg` console
942943
register_command 'irb' do |arg|
943944
if @ui.remote?
944945
@ui.puts "\nIRB is not supported on the remote console."
945-
:retry
946946
else
947-
request_eval :irb, nil
947+
config_set :irb_console, true
948948
end
949+
950+
:retry
949951
end
950952

951953
### Trace
@@ -1876,6 +1878,12 @@ def check_unsafe
18761878
end
18771879
end
18781880

1881+
def activate_irb_integration
1882+
require_relative "irb_integration"
1883+
thc = get_thread_client(@session_server)
1884+
thc.activate_irb_integration
1885+
end
1886+
18791887
def enter_postmortem_session exc
18801888
return unless exc.instance_variable_defined? :@__debugger_postmortem_frames
18811889

lib/gems/gems/debug-1.9.1/lib/debug/thread_client.rb renamed to lib/gems/gems/debug-1.9.2/lib/debug/thread_client.rb

+2-5
Original file line numberDiff line numberDiff line change
@@ -989,7 +989,7 @@ def wait_next_action_
989989
true
990990
else
991991
true if depth >= DEBUGGER__.frame_depth - 3 &&
992-
caller_locations(2, 1).first.label == target_location_label
992+
caller_locations(2, 1).first.base_label == target_location_label
993993
# TODO: imcomplete condition
994994
end
995995
end
@@ -1005,7 +1005,7 @@ def wait_next_action_
10051005
true if pat === tp.callee_id.to_s
10061006
else # :return, :b_return
10071007
true if depth >= DEBUGGER__.frame_depth - 3 &&
1008-
caller_locations(2, 1).first.label == target_location_label
1008+
caller_locations(2, 1).first.base_label == target_location_label
10091009
# TODO: imcomplete condition
10101010
end
10111011
end
@@ -1056,9 +1056,6 @@ def wait_next_action_
10561056
end
10571057
when :call
10581058
result = frame_eval(eval_src)
1059-
when :irb
1060-
require_relative "irb_integration"
1061-
activate_irb_integration
10621059
when :display, :try_display
10631060
failed_results = []
10641061
eval_src.each_with_index{|src, i|
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module DEBUGGER__
4-
VERSION = "1.9.1"
4+
VERSION = "1.9.2"
55
end

0 commit comments

Comments
 (0)