debug 1.9.2 → 1.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c242bce58b031f61da73507f6b42a26f1ed8322679d1f0b3460d8fbc8c4b7a23
4
- data.tar.gz: 543feb5e53a2c99ba04583edae4a13378667c97b13662f5a4d456dd6bacb17b5
3
+ metadata.gz: fc4d6aa4412830633b73eebc239b7b27b17f100965bf4d8b916ce3f6311dfcbb
4
+ data.tar.gz: 11180fe8d9c9d3c9b170b6e817a39c6020dbfa831631a8bad9dc6d69d6a6235e
5
5
  SHA512:
6
- metadata.gz: b5f6c58f38114e3179c3d5c062294ac276b53533fc4a6543114a883198318b672a8506990064f1b40d9f9597d3e1a933cb7c2363ea4cdd4ba0e0571279a80c73
7
- data.tar.gz: 142a78dcdc449df6e0148857f992500aa88375707af067f36f1e3391fe2adb7ac8ff0f66623806c5488e94292167a369ca901084475e97b8dc38e32257ccbba0
6
+ metadata.gz: 0f7c076a9affef363d2a04b31484be5dd904bd750ec1a567adabbdaee0cf9a91bc162e564f504ae67711b5940aa34541300c56b81b60a6078b15296ebff2a72a
7
+ data.tar.gz: b912627acde3296f2e0701cf9a087d5f626181e04c994994a7ac9943ea38736734d4c2197f795573ca814fcface4c61b330f665aaa4c614f74bf1bfb85c7cb4f
data/README.md CHANGED
@@ -16,38 +16,38 @@ New debug.rb has several advantages:
16
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
17
  | ----------- | -------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | --------------------------------------------- |
18
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 |
19
+ | Requirement | None | [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
23
23
  * By loading libraries with `-r` command line option
24
24
  * By calling Ruby's method explicitly
25
25
  * Misc
26
- * Support threads (almost done) and ractors (TODO).
27
- * Support suspending and entering to the console debugging with `Ctrl-C` at most of timing.
26
+ * Support threads (almost done) and Ractors (TODO).
27
+ * Support suspending and entering the debug console with `Ctrl-C` at most of timing.
28
28
  * Show parameters on backtrace command.
29
- * Support recording & replay debugging.
29
+ * Support recording and replay debugging.
30
30
 
31
31
  # Installation
32
32
 
33
- ```
33
+ ```console
34
34
  $ gem install debug
35
35
  ```
36
36
 
37
- or specify `-Ipath/to/debug/lib` in `RUBYOPT` or each ruby command-line option, especially for debug this gem development.
37
+ Alternatively, specify `-Ipath/to/debug/lib` in `RUBYOPT`, or as a Ruby command-line option
38
+ This is especially useful for debugging this gem during development.
38
39
 
39
- If you use Bundler, write the following line to your Gemfile.
40
+ If using Bundler, add the following to your Gemfile:
40
41
 
41
- ```
42
+ ```ruby
42
43
  gem "debug", ">= 1.0.0"
43
44
  ```
44
45
 
45
- (The version constraint is important; `debug < 1.0.0` is an older,
46
- abandoned gem that is completely different from this product.)
46
+ (The version constraint is important; `debug < 1.0.0` is an older, abandoned gem that is completely different from this product.)
47
47
 
48
48
  # HOW TO USE
49
49
 
50
- To use a debugger, roughly you will do the following steps:
50
+ To use the debugger, you will do roughly the following steps:
51
51
 
52
52
  1. Set breakpoints.
53
53
  2. Run a program with the debugger.
@@ -63,22 +63,23 @@ To use a debugger, roughly you will do the following steps:
63
63
 
64
64
  ## Invoke with the debugger
65
65
 
66
- There are several options for (1) and (2). Please choose your favorite way.
66
+ There are several ways to invoke the debugger, depending on your needs, preferences, and the environment.
67
67
 
68
68
  ### Modify source code with [`binding.break`](#bindingbreak-method) (similar to `binding.pry` or `binding.irb`)
69
69
 
70
- If you can modify the source code, you can use the debugger by adding `require 'debug'` at the top of your program and putting [`binding.break`](#bindingbreak-method) method into lines where you want to stop as breakpoints like `binding.pry` and `binding.irb`.
70
+ If you can modify the source code, you can use the debugger by adding `require 'debug'` at the top of your program and putting [`binding.break`](#bindingbreak-method) method into lines where you want to stop as breakpoints.
71
+ This is similar to how `binding.pry` and `binding.irb` work.
71
72
 
72
- You can also use its 2 aliases in the same way:
73
+ `binding.break` has two aliases which do the same thing:
73
74
 
74
75
  - `binding.b`
75
76
  - `debugger`
76
77
 
77
78
  After that, run the program as usual and you will enter the debug console at breakpoints you inserted.
78
79
 
79
- The following example shows the demonstration of [`binding.break`](#bindingbreak-method).
80
+ The following is an example of the [`binding.break`](#bindingbreak-method) method.
80
81
 
81
- ```shell
82
+ ```console
82
83
  $ cat target.rb # Sample program
83
84
  require 'debug'
84
85
 
@@ -140,10 +141,11 @@ d => 4
140
141
 
141
142
  ### Invoke the program from the debugger as a traditional debuggers
142
143
 
143
- If you don't want to modify the source code, you can set breakpoints with a debug command `break` (`b` for short).
144
- Using `rdbg` command (or `bundle exec rdbg`) to launch the program without any modifications, you can run the program with the debugger.
144
+ If you don't want to modify the source code, you can use the `rdbg` command (or `bundle exec rdbg`) to run the program with the debugger.
145
+ This is similar to how you'd launch a program with `ruby program.rb`.
146
+ Then you can set breakpoints with the debug command `break` (`b` for short).
145
147
 
146
- ```shell
148
+ ```console
147
149
  $ cat target.rb # Sample program
148
150
  a = 1
149
151
  b = 2
@@ -166,9 +168,11 @@ DEBUGGER: Session start (pid: 7656)
166
168
  (rdbg)
167
169
  ```
168
170
 
169
- `rdbg` command suspends the program at the beginning of the given script (`target.rb` in this case) and you can use debug commands. `(rdbg)` is prompt. Let's set breakpoints on line 3 and line 5 with `break` command (`b` for short).
171
+ The `rdbg` command suspends the program at the beginning of the given script (`target.rb` in this case) and you can use debug commands to control execution from there.
172
+ `(rdbg)` is the console prompt.
173
+ Let's set breakpoints on line 3 and line 5 with `break` command (`b` for short).
170
174
 
171
- ```shell
175
+ ```console
172
176
  (rdbg) break 3 # set breakpoint at line 3
173
177
  #0 BP - Line /mnt/c/ko1/src/rb/ruby-debug/target.rb:3 (line)
174
178
 
@@ -180,9 +184,10 @@ DEBUGGER: Session start (pid: 7656)
180
184
  #1 BP - Line /mnt/c/ko1/src/rb/ruby-debug/target.rb:5 (line)
181
185
  ```
182
186
 
183
- You can see that two breakpoints are registered. Let's continue the program by using the `continue` command.
187
+ You can see that two breakpoints are registered.
188
+ Let's continue the program by using the `continue` command.
184
189
 
185
- ```shell
190
+ ```console
186
191
  (rdbg) continue
187
192
  [1, 7] in target.rb
188
193
  1| a = 1
@@ -199,11 +204,11 @@ Stop by #0 BP - Line /mnt/c/ko1/src/rb/ruby-debug/target.rb:3 (line)
199
204
  (rdbg)
200
205
  ```
201
206
 
202
- You can see that we can stop at line 3.
203
- Let's see the local variables with the `info` command, and continue.
204
- You can also confirm that the program will suspend at line 5 and you can use the `info` command again.
207
+ You can see that we stopped at line 3.
208
+ Let's see the local variables with the `info` command, and continue execution with the `continue`.
209
+ The program will then suspend at line 5 and you can use the `info` command again.
205
210
 
206
- ```shell
211
+ ```console
207
212
  (rdbg) info
208
213
  =>#0 <main> at target.rb:3
209
214
  %self => main
@@ -237,25 +242,28 @@ d => 4
237
242
  [1, 2, 3, 4]
238
243
  ```
239
244
 
240
- By the way, using `rdbg` command you can suspend your application with `C-c` (SIGINT) and enter the debug console.
245
+ NOTE: When using `rdbg` you can suspend your application with `C-c` (SIGINT) and enter the debug console.
241
246
  It will help if you want to know what the program is doing.
242
247
 
243
248
  ### Use `rdbg` with commands written in Ruby
244
249
 
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.
250
+ If you want to run an executable written in Ruby like `rake`, `rails`, `bundle`, `rspec`, and so on, you can use `rdbg -c` option.
246
251
 
247
- * Without `-c` option, `rdbg <name>` means that `<name>` is Ruby script and invoke it like `ruby <name>` with the debugger.
248
- * With `-c` option, `rdbg -c <name>` means that `<name>` is a command in `PATH` and simply invokes it with the debugger.
252
+ * Without the `-c` option, `rdbg <name>` means that `<name>` is a Ruby script and it is invoked like `ruby <name>` with the debugger.
253
+ * With the `-c` option, `rdbg -c <name>` means that `<name>` is an executable in `PATH` and simply invokes it with the debugger.
249
254
 
250
255
  Examples:
256
+
251
257
  * `rdbg -c -- rails server`
252
258
  * `rdbg -c -- bundle exec ruby foo.rb`
253
259
  * `rdbg -c -- bundle exec rake test`
254
- * `rdbg -c -- ruby target.rb` is same as `rdbg target.rb`
260
+ * `rdbg -c -- ruby target.rb` is the same as `rdbg target.rb`
255
261
 
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`.
262
+ NOTE: `--` is needed to separate the command line options for `rdbg` from the executable being invoked, and its options.
263
+ For example, `rdbg -c rake -T` would be parsed as `rdbg -c -T -- rake`, which is incorrect.
264
+ It should be `rdbg -c -- rake -T`.
257
265
 
258
- NOTE: If you want to use bundler (`bundle` command), you need to write `gem debug` line in your `Gemfile`.
266
+ NOTE: If you want to use Bundler (`bundle` executable), you need to add `gem 'debug'` to your `Gemfile`.
259
267
 
260
268
  ### Using VSCode
261
269
 
@@ -275,12 +283,13 @@ Please see the extension page for more details.
275
283
 
276
284
  ## Remote debugging
277
285
 
278
- You can use this debugger as a remote debugger. For example, it will help in the following situations:
286
+ You can use this debugger as a remote debugger.
287
+ For example, it will help in the following situations:
279
288
 
280
289
  * Your application does not run on TTY, and it is hard to use `binding.pry` or `binding.irb`.
281
290
  * Your application is running on a Docker container, and there is no TTY.
282
291
  * Your application is running as a daemon.
283
- * Your application uses pipe for STDIN or STDOUT.
292
+ * Your application uses pipe for `STDIN` or `STDOUT`.
284
293
  * Your application is running as a daemon and you want to query the running status (checking a backtrace and so on).
285
294
 
286
295
  You can run your application as a remote debuggee, and the remote debugger console can attach to the debuggee anytime.
@@ -296,10 +305,11 @@ There are multiple ways to run your program as a debuggee:
296
305
 
297
306
  #### `rdbg --open` (or `rdbg -O` for short)
298
307
 
299
- You can run a script with `rdbg --open target.rb` command and run a `target.rb` as a debuggee program. It also opens the network port and suspends at the beginning of `target.rb`.
308
+ Launch a script with `rdbg --open target.rb` to run `target.rb` as a debuggee program.
309
+ It also opens the network port and suspends at the beginning of `target.rb`.
300
310
 
301
- ```shell
302
- $ exe/rdbg --open target.rb
311
+ ```console
312
+ $ rdbg --open target.rb
303
313
  DEBUGGER: Session start (pid: 7773)
304
314
  DEBUGGER: Debugger can attach via UNIX domain socket (/home/ko1/.ruby-debug-sock/ruby-debug-ko1-7773)
305
315
  DEBUGGER: wait for debugger connection...
@@ -309,7 +319,7 @@ By default, `rdbg --open` uses UNIX domain socket and generates the path name au
309
319
 
310
320
  You can connect to the debuggee with `rdbg --attach` command (`rdbg -A` for short).
311
321
 
312
- ```shell
322
+ ```console
313
323
  $ rdbg -A
314
324
  [1, 7] in target.rb
315
325
  => 1| a = 1
@@ -324,35 +334,41 @@ $ rdbg -A
324
334
  (rdbg:remote)
325
335
  ```
326
336
 
327
- If there are no other opening ports on the default directory, `rdbg --attach` command chooses the only one opening UNIX domain socket and connects to it. If there are more files, you need to specify the file.
337
+ If there are no other files in the default directory, `rdbg --attach` will automatically connect to the UNIX domain socket listed.
338
+ If there are multiple files, you need to specify which to use.
328
339
 
329
- When `rdbg --attach` connects to the debuggee, you can use any debug commands (set breakpoints, continue the program, and so on) like the local debug console. When a debuggee program exits, the remote console will also terminate.
340
+ When `rdbg --attach` connects to the debuggee, you can use any debug commands (set breakpoints, continue the program, and so on) like the local debug console.
341
+ When a debuggee program exits, the remote console will also terminate.
330
342
 
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.
343
+ 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).
344
+ If you want to exit the debuggee program, use `kill` command.
332
345
 
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`.
346
+ If you want to use TCP/IP for remote debugging, you need to specify the port and host with `--port` like `rdbg --open --port 12345` and it binds to `localhost:12345`.
347
+ You can add an optional `--port_range` to try multiple ports in a reliable way.
348
+ For example, `rdbg --open --port 12345 --port_range 10` will try to bind to 12345, 12346, 12347,… until it finds an available port.
334
349
 
335
350
  To connect to the debuggee, you need to specify the port.
336
351
 
337
- ```shell
352
+ ```console
338
353
  $ rdbg --attach 12345
339
354
  ```
340
355
 
341
356
  If you want to choose the host to bind, you can use `--host` option.
342
- Note that all messages communicated between the debugger and the debuggee are *NOT* encrypted so please use remote debugging carefully.
357
+ Messages communicated between the debugger and the debuggee are *NOT* encrypted so please use remote debugging carefully.
343
358
 
344
359
  #### `require 'debug/open'` in a program
345
360
 
346
- If you can modify the program, you can open the debugging port by adding `require 'debug/open'` line in the program.
361
+ If you can modify the program, you can open the debugging port by adding `require 'debug/open'` in the program.
347
362
 
348
363
  If you don't want to stop the program at the beginning, you can also use `require 'debug/open_nonstop'`.
349
364
  Using `debug/open_nonstop` is useful if you want to open a backdoor to the application.
350
365
  However, it is also dangerous because it can become another vulnerability.
351
366
  Please use it carefully.
352
367
 
353
- By default, UNIX domain socket is used for the debugging port. To use TCP/IP, you can set the `RUBY_DEBUG_PORT` environment variable.
368
+ By default, UNIX domain socket is used for the debugging port.
369
+ To use TCP/IP, you can set the `RUBY_DEBUG_PORT` environment variable.
354
370
 
355
- ```shell
371
+ ```console
356
372
  $ RUBY_DEBUG_PORT=12345 ruby target.rb
357
373
  ```
358
374
 
@@ -364,9 +380,7 @@ You can attach with external debugger frontend with VSCode and Chrome.
364
380
  $ rdbg --open=[frontend] target.rb
365
381
  ```
366
382
 
367
- will open a debug port and `[frontend]` can attach to the port.
368
-
369
- Also `open` command allows opening the debug port.
383
+ This will open a debug port and the `[frontend]` can attach to the port.
370
384
 
371
385
  #### VSCode integration
372
386
 
@@ -374,9 +388,9 @@ Also `open` command allows opening the debug port.
374
388
 
375
389
  If you don't run a debuggee Ruby process on VSCode, you can attach it to VSCode later with the following steps.
376
390
 
377
- `rdbg --open=vscode` opens the debug port and tries to invoke the VSCode (`code` command).
391
+ `rdbg --open=vscode` opens the debug port and tries to invoke the VSCode (`code` executable).
378
392
 
379
- ```
393
+ ```console
380
394
  $ rdbg --open=vscode target.rb
381
395
  DEBUGGER: Debugger can attach via UNIX domain socket (/tmp/ruby-debug-sock-1000/ruby-debug-ko1-27706)
382
396
  DEBUGGER: wait for debugger connection...
@@ -384,11 +398,11 @@ Launching: code /tmp/ruby-debug-vscode-20211014-27706-gd7e85/ /tmp/ruby-debug-vs
384
398
  DEBUGGER: Connected.
385
399
  ```
386
400
 
387
- And it tries to invoke the new VSCode window and VSCode starts attaching to the debuggee Ruby program automatically.
401
+ It tries to invoke the new VSCode window and VSCode will attach to the debuggee Ruby program automatically.
388
402
 
389
- You can also use `open vscode` command in REPL.
403
+ You can also use `open vscode` in a REPL.
390
404
 
391
- ```
405
+ ```console
392
406
  $ rdbg target.rb
393
407
  [1, 8] in target.rb
394
408
  1|
@@ -407,9 +421,9 @@ Launching: code /tmp/ruby-debug-vscode-20211014-28337-kg9dm/ /tmp/ruby-debug-vsc
407
421
  DEBUGGER: Connected.
408
422
  ```
409
423
 
410
- If the machine which runs the Ruby process doesn't have a `code` command, the following message will be shown:
424
+ If the machine which runs the Ruby process doesn't have a `code` executable on `$PATH`, the following message will be shown:
411
425
 
412
- ```
426
+ ```console
413
427
  (rdbg) open vscode
414
428
  DEBUGGER: wait for debugger connection...
415
429
  DEBUGGER: Debugger can attach via UNIX domain socket (/tmp/ruby-debug-sock-1000/ruby-debug-ko1-455)
@@ -425,15 +439,13 @@ If your application is running on a SSH remote host, please try:
425
439
 
426
440
  ```
427
441
 
428
- and try to use the proposed commands.
429
-
430
442
  Note that you can attach with `rdbg --attach` and continue REPL debugging.
431
443
 
432
444
  #### Chrome DevTool integration
433
445
 
434
- With `rdbg --open=chrome` command will show the following message.
446
+ Using `rdbg --open=chrome` will show the following message:
435
447
 
436
- ```
448
+ ```console
437
449
  $ rdbg target.rb --open=chrome
438
450
  DEBUGGER: Debugger can attach via TCP/IP (127.0.0.1:43633)
439
451
  DEBUGGER: With Chrome browser, type the following URL in the address-bar:
@@ -443,20 +455,25 @@ DEBUGGER: With Chrome browser, type the following URL in the address-bar:
443
455
  DEBUGGER: wait for debugger connection...
444
456
  ```
445
457
 
446
- Type `devtools://devtools/bundled/inspector.html?v8only=true&panel=sources&ws=127.0.0.1:57231/b32a55cd-2eb5-4c5c-87d8-b3dfc59d80ef` in the address bar on Chrome browser, and you can continue the debugging with chrome browser.
458
+ Type the following in the address bar on Chrome browser, and you can continue the debugging with chrome browser:
459
+
460
+ ```txt
461
+ devtools://devtools/bundled/inspector.html?v8only=true&panel=sources&ws=127.0.0.1:57231/b32a55cd-2eb5-4c5c-87d8-b3dfc59d80ef`
462
+ ```
447
463
 
448
- Also `open chrome` command works like `open vscode`.
464
+ Similar to VSCode, you can use `open chrome` to open the debugger in Chrome.
449
465
 
450
- For more information about how to use Chrome debugging, you might want to read [here](https://developer.chrome.com/docs/devtools/).
466
+ For more information about how to use Chrome debugging, [see the devtools docs](https://developer.chrome.com/docs/devtools/).
451
467
 
452
468
  ## Configuration
453
469
 
454
470
  You can configure the debugger's behavior with debug commands and environment variables.
455
- When the debug session is started, initial scripts are loaded so you can put your favorite configurations in the initial scripts.
471
+ When the debug session is started, some [initialization scripts](#initial-scripts) (e.g., `~/.rdbgrc`) are loaded, allowing you to configure the debugger's behavior to your needs and preferences.
456
472
 
457
473
  ### Configuration list
458
474
 
459
- You can configure the debugger's behavior with environment variables and `config` command. Each configuration has an environment variable and a name which can be specified by `config` command.
475
+ You can configure the debugger's behavior with environment variables and `config` command.
476
+ Each configuration has an environment variable and a name which can be specified by `config` command.
460
477
 
461
478
  ```
462
479
  # configuration example
@@ -469,6 +486,7 @@ config set no_color true
469
486
  * UI
470
487
  * `RUBY_DEBUG_LOG_LEVEL` (`log_level`): Log level same as Logger (default: WARN)
471
488
  * `RUBY_DEBUG_SHOW_SRC_LINES` (`show_src_lines`): Show n lines source code on breakpoint (default: 10)
489
+ * `RUBY_DEBUG_SHOW_SRC_LINES_FRAME` (`show_src_lines_frame`): Show n lines source code on frame operations (default: 1)
472
490
  * `RUBY_DEBUG_SHOW_EVALEDSRC` (`show_evaledsrc`): Show actually evaluated source (default: false)
473
491
  * `RUBY_DEBUG_SHOW_FRAMES` (`show_frames`): Show n frames on breakpoint (default: 2)
474
492
  * `RUBY_DEBUG_USE_SHORT_PATH` (`use_short_path`): Show shorten PATH (like $(Gem)/foo.rb) (default: false)
@@ -477,6 +495,7 @@ config set no_color true
477
495
  * `RUBY_DEBUG_NO_RELINE` (`no_reline`): Do not use Reline library (default: false)
478
496
  * `RUBY_DEBUG_NO_HINT` (`no_hint`): Do not show the hint on the REPL (default: false)
479
497
  * `RUBY_DEBUG_NO_LINENO` (`no_lineno`): Do not show line numbers (default: false)
498
+ * `RUBY_DEBUG_NO_REPEAT` (`no_repeat`): Do not repeat last line when empty line (default: false)
480
499
  * `RUBY_DEBUG_IRB_CONSOLE` (`irb_console`): Use IRB as the console (default: false)
481
500
 
482
501
  * CONTROL
@@ -493,12 +512,13 @@ config set no_color true
493
512
  * `RUBY_DEBUG_INIT_SCRIPT` (`init_script`): debug command script path loaded at first stop
494
513
  * `RUBY_DEBUG_COMMANDS` (`commands`): debug commands invoked at first stop. Commands should be separated by `;;`
495
514
  * `RUBY_DEBUG_NO_RC` (`no_rc`): ignore loading ~/.rdbgrc(.rb) (default: false)
496
- * `RUBY_DEBUG_HISTORY_FILE` (`history_file`): history file (default: ~/.rdbg_history)
515
+ * `RUBY_DEBUG_HISTORY_FILE` (`history_file`): history file (default: ${XDG_STATE_HOME-~/.local/state}/rdbg/history)
497
516
  * `RUBY_DEBUG_SAVE_HISTORY` (`save_history`): maximum save history lines (default: 10000)
498
517
 
499
518
  * REMOTE
500
519
  * `RUBY_DEBUG_OPEN` (`open`): Open remote port (same as `rdbg --open` option)
501
520
  * `RUBY_DEBUG_PORT` (`port`): TCP/IP remote debugging: port
521
+ * `RUBY_DEBUG_PORT_RANGE` (`port_range`): TCP/IP remote debugging: length of port range
502
522
  * `RUBY_DEBUG_HOST` (`host`): TCP/IP remote debugging: host (default: 127.0.0.1)
503
523
  * `RUBY_DEBUG_SOCK_PATH` (`sock_path`): UNIX Domain Socket remote debugging: socket path
504
524
  * `RUBY_DEBUG_SOCK_DIR` (`sock_dir`): UNIX Domain Socket remote debugging: socket directory
@@ -521,7 +541,7 @@ There are other environment variables:
521
541
 
522
542
  ### Initial scripts
523
543
 
524
- If there is `~/.rdbgrc`, the file is loaded as an initial script (which contains debug commands) when the debug session is started.
544
+ If there is a `~/.rdbgrc` file it is loaded as an initialization script (which contains debug commands) when the debug session is started.
525
545
 
526
546
  * `RUBY_DEBUG_INIT_SCRIPT` environment variable can specify the initial script file.
527
547
  * You can specify the initial script with `rdbg -x initial_script` (like gdb's `-x` option).
@@ -529,7 +549,7 @@ If there is `~/.rdbgrc`, the file is loaded as an initial script (which contains
529
549
  Initial scripts are useful to write your favorite configurations.
530
550
  For example, you can set breakpoints with `break file:123` in `~/.rdbgrc`.
531
551
 
532
- If there are `~/.rdbgrc.rb` is available, it is also loaded as a ruby script at same timing.
552
+ If there is a `~/.rdbgrc.rb` file it is also loaded as a Ruby script when the debug session is started.
533
553
 
534
554
  ## Debug command on the debug console
535
555
 
@@ -538,16 +558,19 @@ On the debug console, you can use the following debug commands.
538
558
  There are additional features:
539
559
 
540
560
  * `<expr>` without debug command is almost the same as `pp <expr>`.
541
- * If the input line `<expr>` does *NOT* start with any debug command, the line `<expr>` will be evaluated as a Ruby expression, and the result will be printed with `pp` method. So that the input `foo.bar` is the same as `pp foo.bar`.
542
- * If `<expr>` is recognized as a debug command, of course, it is not evaluated as a Ruby expression but is executed as debug command. For example, you can not evaluate such single-letter local variables `i`, `b`, `n`, `c` because they are single-letter debug commands. Use `p i` instead.
543
- * So the author (Koichi Sasada) recommends using `p`, `pp` or `eval` command to evaluate the Ruby expression every time.
561
+ * If the input line `<expr>` does *NOT* start with any debug command, the line `<expr>` will be evaluated as a Ruby expression, and the result will be printed with `pp` method.
562
+ So that the input `foo.bar` is the same as `pp foo.bar`.
563
+ * If `<expr>` is recognized as a debug command, of course, it is not evaluated as a Ruby expression but is executed as debug command.
564
+ For example, you can not evaluate such single-letter local variables `i`, `b`, `n`, `c` because they are single-letter debug commands. Use `p i` instead.
565
+ * For consistency, the author (Koichi Sasada) recommends using the `p`, `pp`, or `eval` command to evaluate the Ruby expression every time.
544
566
  * `Enter` without any input repeats the last command (useful when repeating `step`s) for some commands.
545
567
  * `Ctrl-D` is equal to `quit` command.
546
568
  * [debug command compare sheet - Google Sheets](https://docs.google.com/spreadsheets/d/1TlmmUDsvwK4sSIyoMv-io52BUUz__R5wpu-ComXlsw0/edit?usp=sharing)
547
569
 
548
- You can use the following debug commands. Each command should be written in 1 line.
549
- The `[...]` notation means this part can be eliminated. For example, `s[tep]` means `s` or `step` is a valid command. `ste` is not valid.
550
- The `<...>` notation means the argument.
570
+ You can use the following debug commands.
571
+ Each command should be written in 1 line.
572
+ The `[…]` notation means this part can be eliminated. For example, `s[tep]` means `s` or `step` is a valid command. `ste` is not valid.
573
+ The `<…>` notation means the argument.
551
574
 
552
575
  ### Control flow
553
576
 
@@ -797,7 +820,7 @@ To switch to the IRB console, simply use the `irb` command in the debug console.
797
820
 
798
821
  Once activated, you'll notice the prompt changes to:
799
822
 
800
- ```txt
823
+ ```console
801
824
  irb:rdbg(main):001>
802
825
  ```
803
826
 
@@ -824,9 +847,12 @@ You can start debugging without `rdbg` command by requiring the following librar
824
847
  You need to require one of them at the very beginning of the application.
825
848
  Using `ruby -r` (for example `ruby -r debug/start target.rb`) is another way to invoke with debugger.
826
849
 
827
- NOTE: Until Ruby 3.0, there is old `lib/debug.rb` standard library. So that if this gem is not installed, or if `Gemfile` missed to list this gem and `bundle exec` is used, you will see the following output:
850
+ NOTE: Until Ruby 3.0, there is old `lib/debug.rb` in the standard library.
851
+ `lib/debug.rb` was not maintained well in recent years, and the purpose of this library is to rewrite old `lib/debug.rb` with recent techniques.
852
+
853
+ So, if this gem is not installed, or if the `Gemfile` doesn't include this gem and `bundle exec` is used, you will see the following output:
828
854
 
829
- ```shell
855
+ ```console
830
856
  $ ruby -r debug -e0
831
857
  .../2.7.3/lib/ruby/2.7.0/x86_64-linux/continuation.so: warning: callcc is obsolete; use Fiber instead
832
858
  Debug.rb
@@ -836,16 +862,15 @@ Emacs support available.
836
862
  (rdb:1)
837
863
  ```
838
864
 
839
- `lib/debug.rb` was not maintained well in recent years, and the purpose of this library is to rewrite old `lib/debug.rb` with recent techniques.
840
-
841
865
  #### Start by method
842
866
 
843
- After loading `debug/session`, you can start a debug session with the following methods. They are convenient if you want to specify debug configurations in your program.
867
+ After loading `debug/session`, you can start a debug session with the following methods.
868
+ They are convenient if you want to specify debug configurations in your program.
844
869
 
845
870
  * `DEBUGGER__.start(**kw)`: start debug session with local console.
846
- * `DEBUGGER__.open(**kw)`: open debug port with configuration (without configurations open with UNIX domain socket)
847
- * `DEBUGGER__.open_unix(**kw)`: open debug port with UNIX domain socket
848
- * `DEBUGGER__.open_tcp(**kw)`: open debug port with TCP/IP
871
+ * `DEBUGGER__.open(**kw)`: open debug port with configuration (without configurations open with UNIX domain socket).
872
+ * `DEBUGGER__.open_unix(**kw)`: open debug port with UNIX domain socket.
873
+ * `DEBUGGER__.open_tcp(**kw)`: open debug port with TCP/IP.
849
874
 
850
875
  For example:
851
876
 
@@ -859,24 +884,28 @@ DEBUGGER__.start(no_color: true, # disable colorize
859
884
 
860
885
  ### `binding.break` method
861
886
 
862
- `binding.break` (or `binding.b`) set breakpoints at the written line. It also has several keywords.
887
+ `binding.break` (or `binding.b`) sets a breakpoint at that line.
888
+ It also has several keywords.
863
889
 
864
890
  If `do: 'command'` is specified, the debugger suspends the program, runs the `command` as a debug command, and continues the program.
865
891
  It is useful if you only want to call a debug command and don't want to stop there.
892
+ For example:
866
893
 
867
- ```
894
+ ```ruby
868
895
  def initialize
869
896
  @a = 1
870
897
  binding.b do: 'info \n watch @a'
871
898
  end
872
899
  ```
873
900
 
874
- In this case, execute the `info` command then register a watch breakpoint for `@a` and continue to run. You can also use `;;` instead of `\n` to separate your commands.
901
+ In this case, execute the `info` command, then register a watch breakpoint for `@a` and continue to run.
902
+ You can also use `;;` instead of `\n` to separate your commands.
875
903
 
876
904
  If `pre: 'command'` is specified, the debugger suspends the program and runs the `command` as a debug command, and keeps suspended.
877
905
  It is useful if you have operations before suspend.
906
+ For example:
878
907
 
879
- ```
908
+ ```ruby
880
909
  def foo
881
910
  binding.b pre: 'p bar()'
882
911
  ...
@@ -887,7 +916,7 @@ In this case, you can see the result of `bar()` every time you stop there.
887
916
 
888
917
  ## rdbg command help
889
918
 
890
- ```
919
+ ```console
891
920
  exe/rdbg [options] -- [debuggee options]
892
921
 
893
922
  Debug console mode:
@@ -907,6 +936,7 @@ Debug console mode:
907
936
  Now rdbg, vscode and chrome is supported.
908
937
  --sock-path=SOCK_PATH UNIX Domain socket path
909
938
  --port=PORT Listening TCP/IP port
939
+ --port-range=PORT_RANGE Number of ports to try to connect to
910
940
  --host=HOST Listening TCP/IP host
911
941
  --cookie=COOKIE Set a cookie for connection
912
942
  --session-name=NAME Session name
@@ -955,7 +985,7 @@ NOTE
955
985
 
956
986
  # Contributing
957
987
 
958
- Bug reports and pull requests are welcome on GitHub at https://github.com/ruby/debug.
988
+ Bug reports and pull requests are welcome on GitHub at [https://github.com/ruby/debug]().
959
989
  This debugger is not mature so your feedback will help us.
960
990
 
961
991
  Please also check the [contributing guideline](/CONTRIBUTING.md).
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.