debug 1.9.1 → 1.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/README.md +42 -14
- data/debug.gemspec +1 -0
- data/ext/debug/debug.c +10 -10
- data/lib/debug/config.rb +20 -0
- data/lib/debug/console.rb +1 -1
- data/lib/debug/irb_integration.rb +10 -0
- data/lib/debug/prelude.rb +1 -1
- data/lib/debug/server.rb +10 -1
- data/lib/debug/server_cdp.rb +9 -10
- data/lib/debug/server_dap.rb +1 -1
- data/lib/debug/session.rb +16 -8
- data/lib/debug/thread_client.rb +3 -6
- data/lib/debug/version.rb +1 -1
- data/misc/README.md.erb +39 -13
- metadata +5 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0abb44ebe9baa650e6fe0b811044aa50a5d3f7cf0636579ae4991193cf1467ec
|
4
|
+
data.tar.gz: 5decf010f8c581a30fe2543f6118541d0a34768b0d4f83451a728c47eeb6321c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1aad7e61ccedcb91f208a6edd92e0a255d8fb9e564b3b72dafceebbd88aff37b03500b63dc2e375874d27d7ad3767f174d70d3679cb3c47f31e29270952a5999
|
7
|
+
data.tar.gz: 87d2cf298f30052fb0b4f91abea28d5310d7a235173ef04deb3dd27a66c1b9016add6714a2ff29a6483670a5b3245b38091d0a437ede4db61a0a0d45ecfcb773
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -13,10 +13,10 @@ New debug.rb has several advantages:
|
|
13
13
|
* TCP/IP
|
14
14
|
* Integration with rich debugger frontends
|
15
15
|
|
16
|
-
Frontend
|
17
|
-
|
18
|
-
Connection
|
19
|
-
Requirement | No
|
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 |
|
20
20
|
|
21
21
|
* Extensible: application can introduce debugging support in several ways:
|
22
22
|
* By `rdbg` command
|
@@ -244,16 +244,16 @@ It will help if you want to know what the program is doing.
|
|
244
244
|
|
245
245
|
If you want to run a command written in Ruby like `rake`, `rails`, `bundle`, `rspec`, and so on, you can use `rdbg -c` option.
|
246
246
|
|
247
|
-
* Without `-c` option, `rdbg <name>` means that `<name>` is Ruby script and
|
248
|
-
* With `-c` option, `rdbg -c <name>` means that `<name>` is a command in `PATH` and simply invokes it with the debugger.
|
247
|
+
* Without the `-c` option, `rdbg <name>` means that `<name>` is a Ruby script and invokes it like `ruby <name>` with the debugger.
|
248
|
+
* With the `-c` option, `rdbg -c <name>` means that `<name>` is a command in `PATH` and simply invokes it with the debugger.
|
249
249
|
|
250
250
|
Examples:
|
251
251
|
* `rdbg -c -- rails server`
|
252
252
|
* `rdbg -c -- bundle exec ruby foo.rb`
|
253
253
|
* `rdbg -c -- bundle exec rake test`
|
254
|
-
* `rdbg -c -- ruby target.rb` is same as `rdbg target.rb`
|
254
|
+
* `rdbg -c -- ruby target.rb` is the same as `rdbg target.rb`
|
255
255
|
|
256
|
-
NOTE: `--` is needed to separate the command line options for `rdbg` and invoking command. For example, `rdbg -c rake -T` is recognized like `rdbg -c -T -- rake`. It should be `rdbg -c -- rake -T`.
|
256
|
+
NOTE: `--` is needed to separate the command line options for `rdbg` and the invoking command. For example, `rdbg -c rake -T` is recognized like `rdbg -c -T -- rake`. It should be `rdbg -c -- rake -T`.
|
257
257
|
|
258
258
|
NOTE: If you want to use bundler (`bundle` command), you need to write `gem debug` line in your `Gemfile`.
|
259
259
|
|
@@ -289,10 +289,10 @@ You can run your application as a remote debuggee, and the remote debugger conso
|
|
289
289
|
|
290
290
|
There are multiple ways to run your program as a debuggee:
|
291
291
|
|
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
|
295
|
-
No
|
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)` |
|
296
296
|
|
297
297
|
#### `rdbg --open` (or `rdbg -O` for short)
|
298
298
|
|
@@ -330,7 +330,9 @@ When `rdbg --attach` connects to the debuggee, you can use any debug commands (s
|
|
330
330
|
|
331
331
|
NOTE: If you use the `quit` command, only the remote console exits and the debuggee program continues to run (and you can connect it again). If you want to exit the debuggee program, use `kill` command.
|
332
332
|
|
333
|
-
If you want to use TCP/IP for the remote debugging, you need to specify the port and host with `--port` like `rdbg --open --port 12345` and it binds to `localhost:12345`.
|
333
|
+
If you want to use TCP/IP for the remote debugging, you need to specify the port and host with `--port` like `rdbg --open --port 12345` and it binds to `localhost:12345`. You can add an optional `--port_range` option to try multiple ports in a reliable way. For example, `rdbg --open --port 12345 --port_range 10` will try to bind to 12345, 12346, 12347, ... until it finds an available port.
|
334
|
+
|
335
|
+
```shell
|
334
336
|
|
335
337
|
To connect to the debuggee, you need to specify the port.
|
336
338
|
|
@@ -499,6 +501,7 @@ config set no_color true
|
|
499
501
|
* REMOTE
|
500
502
|
* `RUBY_DEBUG_OPEN` (`open`): Open remote port (same as `rdbg --open` option)
|
501
503
|
* `RUBY_DEBUG_PORT` (`port`): TCP/IP remote debugging: port
|
504
|
+
* `RUBY_DEBUG_PORT_RANGE` (`port_range`): TCP/IP remote debugging: length of port range
|
502
505
|
* `RUBY_DEBUG_HOST` (`host`): TCP/IP remote debugging: host (default: 127.0.0.1)
|
503
506
|
* `RUBY_DEBUG_SOCK_PATH` (`sock_path`): UNIX Domain Socket remote debugging: socket path
|
504
507
|
* `RUBY_DEBUG_SOCK_DIR` (`sock_dir`): UNIX Domain Socket remote debugging: socket directory
|
@@ -713,7 +716,7 @@ The `<...>` notation means the argument.
|
|
713
716
|
* `eval <expr>`
|
714
717
|
* Evaluate `<expr>` on the current frame.
|
715
718
|
* `irb`
|
716
|
-
*
|
719
|
+
* Activate and switch to `irb:rdbg` console
|
717
720
|
|
718
721
|
### Trace
|
719
722
|
|
@@ -784,6 +787,30 @@ The `<...>` notation means the argument.
|
|
784
787
|
* Show help for the given command.
|
785
788
|
|
786
789
|
|
790
|
+
### Using IRB as the Debug Console
|
791
|
+
|
792
|
+
Starting from version `v1.9`, you can now use IRB as the debug console. This integration brings additional features such as:
|
793
|
+
|
794
|
+
* Autocompletion
|
795
|
+
* Support for multi-line input
|
796
|
+
* Access to commands not available in `debug`, like `show_source` or `show_doc`
|
797
|
+
* [Configurable command aliases](https://docs.ruby-lang.org/en/master/IRB.html#module-IRB-label-Command+Aliases)
|
798
|
+
|
799
|
+
To switch to the IRB console, simply use the `irb` command in the debug console.
|
800
|
+
|
801
|
+
Once activated, you'll notice the prompt changes to:
|
802
|
+
|
803
|
+
```txt
|
804
|
+
irb:rdbg(main):001>
|
805
|
+
```
|
806
|
+
|
807
|
+
If you want to make IRB the default console for all sessions, configure the `irb_console` setting by either:
|
808
|
+
|
809
|
+
* Setting the `RUBY_DEBUG_IRB_CONSOLE=true` environment variable
|
810
|
+
* Or adding `config set irb_console 1` to your `~/.rdbgrc`
|
811
|
+
|
812
|
+
To disable the IRB console in the current session, execute `config set irb_console 0` in the console.
|
813
|
+
|
787
814
|
## Debugger API
|
788
815
|
|
789
816
|
### Start debugging
|
@@ -883,6 +910,7 @@ Debug console mode:
|
|
883
910
|
Now rdbg, vscode and chrome is supported.
|
884
911
|
--sock-path=SOCK_PATH UNIX Domain socket path
|
885
912
|
--port=PORT Listening TCP/IP port
|
913
|
+
--port-range=PORT_RANGE Number of ports to try to connect to
|
886
914
|
--host=HOST Listening TCP/IP host
|
887
915
|
--cookie=COOKIE Set a cookie for connection
|
888
916
|
--session-name=NAME Session name
|
data/debug.gemspec
CHANGED
@@ -14,6 +14,7 @@ Gem::Specification.new do |spec|
|
|
14
14
|
|
15
15
|
spec.metadata["homepage_uri"] = spec.homepage
|
16
16
|
spec.metadata["source_code_uri"] = spec.homepage
|
17
|
+
spec.metadata["changelog_uri"] = "#{spec.homepage}/releases/tag/v#{spec.version}"
|
17
18
|
|
18
19
|
# Specify which files should be added to the gem when it is released.
|
19
20
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
data/ext/debug/debug.c
CHANGED
@@ -8,13 +8,13 @@ static VALUE rb_mDebugger;
|
|
8
8
|
|
9
9
|
// iseq
|
10
10
|
typedef struct rb_iseq_struct rb_iseq_t;
|
11
|
+
const rb_iseq_t *rb_iseqw_to_iseq(VALUE iseqw);
|
11
12
|
VALUE rb_iseq_realpath(const rb_iseq_t *iseq);
|
12
13
|
|
13
14
|
static VALUE
|
14
15
|
iseq_realpath(VALUE iseqw)
|
15
16
|
{
|
16
|
-
|
17
|
-
return rb_iseq_realpath(iseq);
|
17
|
+
return rb_iseq_realpath(rb_iseqw_to_iseq(iseqw));
|
18
18
|
}
|
19
19
|
|
20
20
|
static VALUE rb_cFrameInfo;
|
@@ -121,26 +121,26 @@ frame_depth(VALUE self)
|
|
121
121
|
|
122
122
|
// iseq
|
123
123
|
|
124
|
-
const
|
124
|
+
const rb_iseq_t *rb_iseqw_to_iseq(VALUE iseqw);
|
125
125
|
|
126
126
|
#ifdef HAVE_RB_ISEQ_TYPE
|
127
|
-
VALUE rb_iseq_type(const
|
127
|
+
VALUE rb_iseq_type(const rb_iseq_t *);
|
128
128
|
|
129
129
|
static VALUE
|
130
130
|
iseq_type(VALUE iseqw)
|
131
131
|
{
|
132
|
-
const
|
132
|
+
const rb_iseq_t *iseq = rb_iseqw_to_iseq(iseqw);
|
133
133
|
return rb_iseq_type(iseq);
|
134
134
|
}
|
135
135
|
#endif
|
136
136
|
|
137
137
|
#ifdef HAVE_RB_ISEQ_PARAMETERS
|
138
|
-
VALUE rb_iseq_parameters(const
|
138
|
+
VALUE rb_iseq_parameters(const rb_iseq_t *, int is_proc);
|
139
139
|
|
140
140
|
static VALUE
|
141
141
|
iseq_parameters_symbols(VALUE iseqw)
|
142
142
|
{
|
143
|
-
const
|
143
|
+
const rb_iseq_t *iseq = rb_iseqw_to_iseq(iseqw);
|
144
144
|
VALUE params = rb_iseq_parameters(iseq, 0);
|
145
145
|
VALUE ary = rb_ary_new();
|
146
146
|
|
@@ -167,12 +167,12 @@ iseq_parameters_symbols(VALUE iseqw)
|
|
167
167
|
#endif
|
168
168
|
|
169
169
|
#ifdef HAVE_RB_ISEQ_CODE_LOCATION
|
170
|
-
void rb_iseq_code_location(const
|
170
|
+
void rb_iseq_code_location(const rb_iseq_t *, int *first_lineno, int *first_column, int *last_lineno, int *last_column);
|
171
171
|
|
172
172
|
static VALUE
|
173
173
|
iseq_first_line(VALUE iseqw)
|
174
174
|
{
|
175
|
-
const
|
175
|
+
const rb_iseq_t *iseq = rb_iseqw_to_iseq(iseqw);
|
176
176
|
int line;
|
177
177
|
rb_iseq_code_location(iseq, &line, NULL, NULL, NULL);
|
178
178
|
return INT2NUM(line);
|
@@ -181,7 +181,7 @@ iseq_first_line(VALUE iseqw)
|
|
181
181
|
static VALUE
|
182
182
|
iseq_last_line(VALUE iseqw)
|
183
183
|
{
|
184
|
-
const
|
184
|
+
const rb_iseq_t *iseq = rb_iseqw_to_iseq(iseqw);
|
185
185
|
int line;
|
186
186
|
rb_iseq_code_location(iseq, NULL, NULL, &line, NULL);
|
187
187
|
return INT2NUM(line);
|
data/lib/debug/config.rb
CHANGED
@@ -44,6 +44,7 @@ module DEBUGGER__
|
|
44
44
|
# remote setting
|
45
45
|
open: ['RUBY_DEBUG_OPEN', "REMOTE: Open remote port (same as `rdbg --open` option)"],
|
46
46
|
port: ['RUBY_DEBUG_PORT', "REMOTE: TCP/IP remote debugging: port"],
|
47
|
+
port_range: ['RUBY_DEBUG_PORT_RANGE', "REMOTE: TCP/IP remote debugging: length of port range"],
|
47
48
|
host: ['RUBY_DEBUG_HOST', "REMOTE: TCP/IP remote debugging: host", :string, "127.0.0.1"],
|
48
49
|
sock_path: ['RUBY_DEBUG_SOCK_PATH', "REMOTE: UNIX Domain Socket remote debugging: socket path"],
|
49
50
|
sock_dir: ['RUBY_DEBUG_SOCK_DIR', "REMOTE: UNIX Domain Socket remote debugging: socket directory"],
|
@@ -158,6 +159,22 @@ module DEBUGGER__
|
|
158
159
|
SESSION.set_no_sigint_hook old, new
|
159
160
|
end
|
160
161
|
end
|
162
|
+
|
163
|
+
if_updated old_conf, conf, :irb_console do |old, new|
|
164
|
+
if defined?(SESSION) && SESSION.active?
|
165
|
+
# irb_console is switched from true to false
|
166
|
+
if old
|
167
|
+
SESSION.deactivate_irb_integration
|
168
|
+
# irb_console is switched from false to true
|
169
|
+
else
|
170
|
+
if CONFIG[:open]
|
171
|
+
SESSION.instance_variable_get(:@ui).puts "\nIRB is not supported on the remote console."
|
172
|
+
else
|
173
|
+
SESSION.activate_irb_integration
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
161
178
|
end
|
162
179
|
|
163
180
|
private def if_updated old_conf, new_conf, key
|
@@ -336,6 +353,9 @@ module DEBUGGER__
|
|
336
353
|
o.on('--port=PORT', 'Listening TCP/IP port') do |port|
|
337
354
|
config[:port] = port
|
338
355
|
end
|
356
|
+
o.on('--port-range=PORT_RANGE', 'Number of ports to try to connect to') do |port_range|
|
357
|
+
config[:port_range] = port_range
|
358
|
+
end
|
339
359
|
o.on('--host=HOST', 'Listening TCP/IP host') do |host|
|
340
360
|
config[:host] = host
|
341
361
|
end
|
data/lib/debug/console.rb
CHANGED
@@ -24,4 +24,14 @@ module DEBUGGER__
|
|
24
24
|
IRB::Context.prepend(IrbPatch)
|
25
25
|
end
|
26
26
|
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
|
27
37
|
end
|
data/lib/debug/prelude.rb
CHANGED
@@ -5,7 +5,7 @@ return if defined?(::DEBUGGER__::Session)
|
|
5
5
|
|
6
6
|
# Put the following line in your login script (e.g. ~/.bash_profile) with modified path:
|
7
7
|
#
|
8
|
-
# export RUBYOPT="-r /path/to/debug/prelude $
|
8
|
+
# export RUBYOPT="-r /path/to/debug/prelude ${RUBYOPT}"
|
9
9
|
#
|
10
10
|
module Kernel
|
11
11
|
def debugger(*a, up_level: 0, **kw)
|
data/lib/debug/server.rb
CHANGED
@@ -399,6 +399,13 @@ module DEBUGGER__
|
|
399
399
|
raise "Specify digits for port number"
|
400
400
|
end
|
401
401
|
end
|
402
|
+
@port_range = if @port.zero?
|
403
|
+
0
|
404
|
+
else
|
405
|
+
port_range_str = (CONFIG[:port_range] || "0").to_s
|
406
|
+
raise "Specify a positive integer <=16 for port range" unless port_range_str.match?(/\A\d+\z/) && port_range_str.to_i <= 16
|
407
|
+
port_range_str.to_i
|
408
|
+
end
|
402
409
|
@uuid = nil # for CDP
|
403
410
|
|
404
411
|
super()
|
@@ -452,7 +459,9 @@ module DEBUGGER__
|
|
452
459
|
end
|
453
460
|
end
|
454
461
|
rescue Errno::EADDRINUSE
|
455
|
-
|
462
|
+
number_of_retries = @port_range.zero? ? 10 : @port_range
|
463
|
+
if retry_cnt < number_of_retries
|
464
|
+
@port += 1 unless @port_range.zero?
|
456
465
|
retry_cnt += 1
|
457
466
|
sleep 0.1
|
458
467
|
retry
|
data/lib/debug/server_cdp.rb
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
require 'json'
|
4
4
|
require 'digest/sha1'
|
5
|
-
require 'base64'
|
6
5
|
require 'securerandom'
|
7
6
|
require 'stringio'
|
8
7
|
require 'open3'
|
@@ -131,7 +130,7 @@ module DEBUGGER__
|
|
131
130
|
stdout.close
|
132
131
|
data = stderr.readpartial 4096
|
133
132
|
stderr.close
|
134
|
-
if data.match
|
133
|
+
if data.match(/DevTools listening on ws:\/\/127.0.0.1:(\d+)(.*)/)
|
135
134
|
port = $1
|
136
135
|
path = $2
|
137
136
|
end
|
@@ -158,7 +157,7 @@ module DEBUGGER__
|
|
158
157
|
raise NotFoundChromeEndpointError
|
159
158
|
end
|
160
159
|
stderr.close
|
161
|
-
if data.match
|
160
|
+
if data.match(/DevTools listening on ws:\/\/127.0.0.1:(\d+)(.*)/)
|
162
161
|
port = $1
|
163
162
|
path = $2
|
164
163
|
end
|
@@ -190,7 +189,7 @@ module DEBUGGER__
|
|
190
189
|
while i < ITERATIONS
|
191
190
|
i += 1
|
192
191
|
if File.exist?(tf) && data = File.read(tf)
|
193
|
-
if data.match
|
192
|
+
if data.match(/DevTools listening on ws:\/\/127.0.0.1:(\d+)(.*)/)
|
194
193
|
port = $1
|
195
194
|
path = $2
|
196
195
|
return [port, path]
|
@@ -297,8 +296,8 @@ module DEBUGGER__
|
|
297
296
|
res = @sock.readpartial 4092
|
298
297
|
show_protocol :<, res
|
299
298
|
|
300
|
-
if res.match
|
301
|
-
correct_key =
|
299
|
+
if res.match(/^Sec-WebSocket-Accept: (.*)\r\n/)
|
300
|
+
correct_key = Digest::SHA1.base64digest "#{key}==258EAFA5-E914-47DA-95CA-C5AB0DC85B11"
|
302
301
|
raise "The Sec-WebSocket-Accept value: #{$1} is not valid" unless $1 == correct_key
|
303
302
|
else
|
304
303
|
raise "Unknown response: #{res}"
|
@@ -378,8 +377,8 @@ module DEBUGGER__
|
|
378
377
|
req = @sock.readpartial 4096
|
379
378
|
show_protocol '>', req
|
380
379
|
|
381
|
-
if req.match
|
382
|
-
accept =
|
380
|
+
if req.match(/^Sec-WebSocket-Key: (.*)\r\n/)
|
381
|
+
accept = Digest::SHA1.base64digest "#{$1}258EAFA5-E914-47DA-95CA-C5AB0DC85B11"
|
383
382
|
res = "HTTP/1.1 101 Switching Protocols\r\nUpgrade: websocket\r\nConnection: Upgrade\r\nSec-WebSocket-Accept: #{accept}\r\n\r\n"
|
384
383
|
@sock.print res
|
385
384
|
show_protocol :<, res
|
@@ -658,7 +657,7 @@ module DEBUGGER__
|
|
658
657
|
|
659
658
|
def activate_bp bps
|
660
659
|
bps.each_key{|k|
|
661
|
-
if k.match
|
660
|
+
if k.match(/^\d+:(\d+):(.*)/)
|
662
661
|
line = $1
|
663
662
|
path = $2
|
664
663
|
SESSION.add_line_breakpoint(path, line.to_i + 1)
|
@@ -689,7 +688,7 @@ module DEBUGGER__
|
|
689
688
|
yield $stderr
|
690
689
|
end
|
691
690
|
|
692
|
-
def puts result=
|
691
|
+
def puts result = ""
|
693
692
|
# STDERR.puts "puts: #{result}"
|
694
693
|
# send_event 'output', category: 'stderr', output: "PUTS!!: " + result.to_s
|
695
694
|
end
|
data/lib/debug/server_dap.rb
CHANGED
data/lib/debug/session.rb
CHANGED
@@ -202,11 +202,6 @@ module DEBUGGER__
|
|
202
202
|
end
|
203
203
|
@tp_thread_end.enable
|
204
204
|
|
205
|
-
if CONFIG[:irb_console] && !CONFIG[:open]
|
206
|
-
require_relative "irb_integration"
|
207
|
-
thc.activate_irb_integration
|
208
|
-
end
|
209
|
-
|
210
205
|
# session start
|
211
206
|
q << true
|
212
207
|
session_server_main
|
@@ -214,6 +209,12 @@ module DEBUGGER__
|
|
214
209
|
first_q << :ok
|
215
210
|
|
216
211
|
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
|
217
218
|
end
|
218
219
|
|
219
220
|
def deactivate
|
@@ -938,14 +939,15 @@ module DEBUGGER__
|
|
938
939
|
end
|
939
940
|
|
940
941
|
# * `irb`
|
941
|
-
# *
|
942
|
+
# * Activate and switch to `irb:rdbg` console
|
942
943
|
register_command 'irb' do |arg|
|
943
944
|
if @ui.remote?
|
944
945
|
@ui.puts "\nIRB is not supported on the remote console."
|
945
|
-
:retry
|
946
946
|
else
|
947
|
-
|
947
|
+
config_set :irb_console, true
|
948
948
|
end
|
949
|
+
|
950
|
+
:retry
|
949
951
|
end
|
950
952
|
|
951
953
|
### Trace
|
@@ -1876,6 +1878,12 @@ module DEBUGGER__
|
|
1876
1878
|
end
|
1877
1879
|
end
|
1878
1880
|
|
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
|
+
|
1879
1887
|
def enter_postmortem_session exc
|
1880
1888
|
return unless exc.instance_variable_defined? :@__debugger_postmortem_frames
|
1881
1889
|
|
data/lib/debug/thread_client.rb
CHANGED
@@ -44,7 +44,7 @@ module DEBUGGER__
|
|
44
44
|
end
|
45
45
|
|
46
46
|
module GlobalVariablesHelper
|
47
|
-
SKIP_GLOBAL_LIST = %i[$= $KCODE $-K $SAFE].freeze
|
47
|
+
SKIP_GLOBAL_LIST = %i[$= $KCODE $-K $SAFE $FILENAME].freeze
|
48
48
|
def safe_global_variables
|
49
49
|
global_variables.reject{|name| SKIP_GLOBAL_LIST.include? name }
|
50
50
|
end
|
@@ -989,7 +989,7 @@ module DEBUGGER__
|
|
989
989
|
true
|
990
990
|
else
|
991
991
|
true if depth >= DEBUGGER__.frame_depth - 3 &&
|
992
|
-
caller_locations(2, 1).first.
|
992
|
+
caller_locations(2, 1).first.base_label == target_location_label
|
993
993
|
# TODO: imcomplete condition
|
994
994
|
end
|
995
995
|
end
|
@@ -1005,7 +1005,7 @@ module DEBUGGER__
|
|
1005
1005
|
true if pat === tp.callee_id.to_s
|
1006
1006
|
else # :return, :b_return
|
1007
1007
|
true if depth >= DEBUGGER__.frame_depth - 3 &&
|
1008
|
-
caller_locations(2, 1).first.
|
1008
|
+
caller_locations(2, 1).first.base_label == target_location_label
|
1009
1009
|
# TODO: imcomplete condition
|
1010
1010
|
end
|
1011
1011
|
end
|
@@ -1056,9 +1056,6 @@ module DEBUGGER__
|
|
1056
1056
|
end
|
1057
1057
|
when :call
|
1058
1058
|
result = frame_eval(eval_src)
|
1059
|
-
when :irb
|
1060
|
-
require_relative "irb_integration"
|
1061
|
-
activate_irb_integration
|
1062
1059
|
when :display, :try_display
|
1063
1060
|
failed_results = []
|
1064
1061
|
eval_src.each_with_index{|src, i|
|
data/lib/debug/version.rb
CHANGED
data/misc/README.md.erb
CHANGED
@@ -13,10 +13,10 @@ New debug.rb has several advantages:
|
|
13
13
|
* TCP/IP
|
14
14
|
* Integration with rich debugger frontends
|
15
15
|
|
16
|
-
Frontend
|
17
|
-
|
18
|
-
Connection
|
19
|
-
Requirement | No
|
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 |
|
20
20
|
|
21
21
|
* Extensible: application can introduce debugging support in several ways:
|
22
22
|
* By `rdbg` command
|
@@ -244,16 +244,16 @@ It will help if you want to know what the program is doing.
|
|
244
244
|
|
245
245
|
If you want to run a command written in Ruby like `rake`, `rails`, `bundle`, `rspec`, and so on, you can use `rdbg -c` option.
|
246
246
|
|
247
|
-
* Without `-c` option, `rdbg <name>` means that `<name>` is Ruby script and
|
248
|
-
* With `-c` option, `rdbg -c <name>` means that `<name>` is a command in `PATH` and simply invokes it with the debugger.
|
247
|
+
* Without the `-c` option, `rdbg <name>` means that `<name>` is a Ruby script and invokes it like `ruby <name>` with the debugger.
|
248
|
+
* With the `-c` option, `rdbg -c <name>` means that `<name>` is a command in `PATH` and simply invokes it with the debugger.
|
249
249
|
|
250
250
|
Examples:
|
251
251
|
* `rdbg -c -- rails server`
|
252
252
|
* `rdbg -c -- bundle exec ruby foo.rb`
|
253
253
|
* `rdbg -c -- bundle exec rake test`
|
254
|
-
* `rdbg -c -- ruby target.rb` is same as `rdbg target.rb`
|
254
|
+
* `rdbg -c -- ruby target.rb` is the same as `rdbg target.rb`
|
255
255
|
|
256
|
-
NOTE: `--` is needed to separate the command line options for `rdbg` and invoking command. For example, `rdbg -c rake -T` is recognized like `rdbg -c -T -- rake`. It should be `rdbg -c -- rake -T`.
|
256
|
+
NOTE: `--` is needed to separate the command line options for `rdbg` and the invoking command. For example, `rdbg -c rake -T` is recognized like `rdbg -c -T -- rake`. It should be `rdbg -c -- rake -T`.
|
257
257
|
|
258
258
|
NOTE: If you want to use bundler (`bundle` command), you need to write `gem debug` line in your `Gemfile`.
|
259
259
|
|
@@ -289,10 +289,10 @@ You can run your application as a remote debuggee, and the remote debugger conso
|
|
289
289
|
|
290
290
|
There are multiple ways to run your program as a debuggee:
|
291
291
|
|
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
|
295
|
-
No
|
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)` |
|
296
296
|
|
297
297
|
#### `rdbg --open` (or `rdbg -O` for short)
|
298
298
|
|
@@ -330,7 +330,9 @@ When `rdbg --attach` connects to the debuggee, you can use any debug commands (s
|
|
330
330
|
|
331
331
|
NOTE: If you use the `quit` command, only the remote console exits and the debuggee program continues to run (and you can connect it again). If you want to exit the debuggee program, use `kill` command.
|
332
332
|
|
333
|
-
If you want to use TCP/IP for the remote debugging, you need to specify the port and host with `--port` like `rdbg --open --port 12345` and it binds to `localhost:12345`.
|
333
|
+
If you want to use TCP/IP for the remote debugging, you need to specify the port and host with `--port` like `rdbg --open --port 12345` and it binds to `localhost:12345`. You can add an optional `--port_range` option to try multiple ports in a reliable way. For example, `rdbg --open --port 12345 --port_range 10` will try to bind to 12345, 12346, 12347, ... until it finds an available port.
|
334
|
+
|
335
|
+
```shell
|
334
336
|
|
335
337
|
To connect to the debuggee, you need to specify the port.
|
336
338
|
|
@@ -509,6 +511,30 @@ The `<...>` notation means the argument.
|
|
509
511
|
|
510
512
|
<%= DEBUGGER__.help %>
|
511
513
|
|
514
|
+
### Using IRB as the Debug Console
|
515
|
+
|
516
|
+
Starting from version `v1.9`, you can now use IRB as the debug console. This integration brings additional features such as:
|
517
|
+
|
518
|
+
* Autocompletion
|
519
|
+
* Support for multi-line input
|
520
|
+
* Access to commands not available in `debug`, like `show_source` or `show_doc`
|
521
|
+
* [Configurable command aliases](https://docs.ruby-lang.org/en/master/IRB.html#module-IRB-label-Command+Aliases)
|
522
|
+
|
523
|
+
To switch to the IRB console, simply use the `irb` command in the debug console.
|
524
|
+
|
525
|
+
Once activated, you'll notice the prompt changes to:
|
526
|
+
|
527
|
+
```txt
|
528
|
+
irb:rdbg(main):001>
|
529
|
+
```
|
530
|
+
|
531
|
+
If you want to make IRB the default console for all sessions, configure the `irb_console` setting by either:
|
532
|
+
|
533
|
+
* Setting the `RUBY_DEBUG_IRB_CONSOLE=true` environment variable
|
534
|
+
* Or adding `config set irb_console 1` to your `~/.rdbgrc`
|
535
|
+
|
536
|
+
To disable the IRB console in the current session, execute `config set irb_console 0` in the console.
|
537
|
+
|
512
538
|
## Debugger API
|
513
539
|
|
514
540
|
### Start debugging
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: debug
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.10.0
|
5
5
|
platform: ruby
|
6
|
+
original_platform: ''
|
6
7
|
authors:
|
7
8
|
- Koichi Sasada
|
8
|
-
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-12-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: irb
|
@@ -90,7 +90,7 @@ licenses:
|
|
90
90
|
metadata:
|
91
91
|
homepage_uri: https://github.com/ruby/debug
|
92
92
|
source_code_uri: https://github.com/ruby/debug
|
93
|
-
|
93
|
+
changelog_uri: https://github.com/ruby/debug/releases/tag/v1.10.0
|
94
94
|
rdoc_options: []
|
95
95
|
require_paths:
|
96
96
|
- lib
|
@@ -105,8 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
105
105
|
- !ruby/object:Gem::Version
|
106
106
|
version: '0'
|
107
107
|
requirements: []
|
108
|
-
rubygems_version: 3.
|
109
|
-
signing_key:
|
108
|
+
rubygems_version: 3.6.0.dev
|
110
109
|
specification_version: 4
|
111
110
|
summary: Debugging functionality for Ruby
|
112
111
|
test_files: []
|