debug 1.8.0 → 1.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 39fceaae982c712433b6bf0bc855328c5d923524658a399926e7a032f5d7cdbf
4
- data.tar.gz: 4f80f39348e0cd46882bd54e04398342c3d124133aa15edcc57a18f1a20fe449
3
+ metadata.gz: 3d25f806f1fa474cea627e17003007f9e28a776244f25c24addae854005fd8d1
4
+ data.tar.gz: 63a48b8aeee29d020a4d8fb6ec85ad337c42c0b83f32ca53ea83d767a6daadc5
5
5
  SHA512:
6
- metadata.gz: 67a369a45e2debb29dbb42fcbc32d36e1c40467249d657f45caa8a04a5fb3521a10c91860a3f3407caaa8f97cf81ad35f8a3e5ac83a124b99811d82363afe2cf
7
- data.tar.gz: b29458d948196114b7cb5c7c182decca2685495b96707d904674714a2256a46bd0244efdde5d1ada8a460d881dff7ad4acafaa2c433c6e0eddbcf928425f6748
6
+ metadata.gz: 91f621ae09fb945590cb7ddd43b97401f27304326b49204ea0a17981fbd236e52e5e19bfa4cb158bd49943d04681e39ff51072f317a4d29368ccdaa50552cd86
7
+ data.tar.gz: 9ab3a0a3509ad947ad62c70e10eedacd3fb299a5e2c1654f06ffd01f59de23d91cd99b80101fc13acd1e0b1192265821a2c5fbddf0dfbefccc69dfaf5748b63d
data/README.md CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  # debug.rb
4
4
 
5
- This library provides debugging functionality to Ruby (MRI) 2.6 and later.
5
+ This library provides debugging functionality to Ruby (MRI) 2.7 and later.
6
6
 
7
- This debug.rb is replacement of traditional lib/debug.rb standard library which is implemented by `set_trace_func`.
7
+ This debug.rb is the replacement of traditional lib/debug.rb standard library, which is implemented by `set_trace_func`.
8
8
  New debug.rb has several advantages:
9
9
 
10
10
  * Fast: No performance penalty on non-stepping mode and non-breakpoints.
@@ -18,7 +18,7 @@ New debug.rb has several advantages:
18
18
  Connection | UDS, TCP/IP | UDS, TCP/IP | TCP/IP |
19
19
  Requirement | No | [vscode-rdbg](https://marketplace.visualstudio.com/items?itemName=KoichiSasada.vscode-rdbg) | Chrome |
20
20
 
21
- * Extensible: application can introduce debugging support with several ways:
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
@@ -55,7 +55,7 @@ To use a debugger, roughly you will do the following steps:
55
55
  4. Use debug commands.
56
56
  * [Evaluate Ruby expressions](#evaluate) (e.g. `p lvar` to see the local variable `lvar`).
57
57
  * [Query the program status](#information) (e.g. `info` to see information about the current frame).
58
- * [Control program flow](#control-flow) (e.g. move to the another line with `step`, to the next line with `next`).
58
+ * [Control program flow](#control-flow) (e.g. move to another line with `step`, to the next line with `next`).
59
59
  * [Set another breakpoint](#breakpoint) (e.g. `catch Exception` to set a breakpoint that'll be triggered when `Exception` is raised).
60
60
  * [Activate tracing in your program](#trace) (e.g. `trace call` to trace method calls).
61
61
  * [Change the configuration](#configuration-1) (e.g. `config set no_color true` to disable coloring).
@@ -180,7 +180,7 @@ DEBUGGER: Session start (pid: 7656)
180
180
  #1 BP - Line /mnt/c/ko1/src/rb/ruby-debug/target.rb:5 (line)
181
181
  ```
182
182
 
183
- You can see that two breakpoints are registered. Let's continue the program by `continue` command.
183
+ You can see that two breakpoints are registered. Let's continue the program by using the `continue` command.
184
184
 
185
185
  ```shell
186
186
  (rdbg) continue
@@ -200,8 +200,8 @@ Stop by #0 BP - Line /mnt/c/ko1/src/rb/ruby-debug/target.rb:3 (line)
200
200
  ```
201
201
 
202
202
  You can see that we can stop at line 3.
203
- Let's see the local variables with `info` command, and continue.
204
- You can also confirm that the program will suspend at line 5 and you can use `info` command again.
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.
205
205
 
206
206
  ```shell
207
207
  (rdbg) info
@@ -238,14 +238,14 @@ d => 4
238
238
  ```
239
239
 
240
240
  By the way, using `rdbg` command you can suspend your application with `C-c` (SIGINT) and enter the debug console.
241
- It will help that if you want to know what the program is doing.
241
+ It will help if you want to know what the program is doing.
242
242
 
243
243
  ### Use `rdbg` with commands written in Ruby
244
244
 
245
- If you want to run a command written in Ruby like like `rake`, `rails`, `bundle`, `rspec` and so on, you can use `rdbg -c` option.
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
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 command in `PATH` and simply invoke it 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.
249
249
 
250
250
  Examples:
251
251
  * `rdbg -c -- rails server`
@@ -263,27 +263,27 @@ Like other languages, you can use this debugger on the VSCode.
263
263
 
264
264
  1. Install [VSCode rdbg Ruby Debugger - Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=KoichiSasada.vscode-rdbg)
265
265
  2. Open `.rb` file (e.g. `target.rb`)
266
- 3. Register breakpoints with "Toggle breakpoint" in Run menu (or type F9 key)
266
+ 3. Register breakpoints with "Toggle breakpoint" in the Run menu (or type F9 key)
267
267
  4. Choose "Start debugging" in "Run" menu (or type F5 key)
268
- 5. You will see a dialog "Debug command line" and you can choose your favorite command line your want to run.
269
- 6. Chosen command line is invoked with `rdbg -c` and VSCode shows the details at breakpoints.
268
+ 5. You will see a dialog "Debug command line" and you can choose your favorite command line you want to run.
269
+ 6. Chosen command line is invoked with `rdbg -c`, and VSCode shows the details at breakpoints.
270
270
 
271
- Please refer [Debugging in Visual Studio Code](https://code.visualstudio.com/docs/editor/debugging) for operations on VSCode.
271
+ Please refer to [Debugging in Visual Studio Code](https://code.visualstudio.com/docs/editor/debugging) for operations on VSCode.
272
272
 
273
273
  You can configure the extension in `.vscode/launch.json`.
274
274
  Please see the extension page for more details.
275
275
 
276
276
  ## Remote debugging
277
277
 
278
- You can use this debugger as a remote debugger. For example, it will help the following situations:
278
+ You can use this debugger as a remote debugger. For example, it will help in the following situations:
279
279
 
280
- * Your application does not run on TTY and it is hard to use `binding.pry` or `binding.irb`.
281
- * Your application is running on Docker container and there is no TTY.
280
+ * Your application does not run on TTY, and it is hard to use `binding.pry` or `binding.irb`.
281
+ * Your application is running on a Docker container, and there is no TTY.
282
282
  * Your application is running as a daemon.
283
283
  * Your application uses pipe for STDIN or STDOUT.
284
284
  * Your application is running as a daemon and you want to query the running status (checking a backtrace and so on).
285
285
 
286
- You can run your application as a remote debuggee and the remote debugger console can attach to the debuggee anytime.
286
+ You can run your application as a remote debuggee, and the remote debugger console can attach to the debuggee anytime.
287
287
 
288
288
  ### Invoke as a remote debuggee
289
289
 
@@ -305,7 +305,7 @@ DEBUGGER: Debugger can attach via UNIX domain socket (/home/ko1/.ruby-debug-sock
305
305
  DEBUGGER: wait for debugger connection...
306
306
  ```
307
307
 
308
- By default, `rdbg --open` uses UNIX domain socket and generates path name automatically (`/home/ko1/.ruby-debug-sock/ruby-debug-ko1-7773` in this case).
308
+ By default, `rdbg --open` uses UNIX domain socket and generates the path name automatically (`/home/ko1/.ruby-debug-sock/ruby-debug-ko1-7773` in this case).
309
309
 
310
310
  You can connect to the debuggee with `rdbg --attach` command (`rdbg -A` for short).
311
311
 
@@ -324,11 +324,11 @@ $ rdbg -A
324
324
  (rdbg:remote)
325
325
  ```
326
326
 
327
- If there is no other opening ports on the default directory, `rdbg --attach` command chooses the only one opening UNIX domain socket and connect to it. If there are more files, you need to specify the file.
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.
328
328
 
329
- When `rdbg --attach` connects to the debuggee, you can use any debug commands (set breakpoints, continue the program and so on) like local debug console. When an debuggee program exits, the remote console will also terminate.
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.
330
330
 
331
- NOTE: If you use `quit` command, only 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.
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
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`.
334
334
 
@@ -343,11 +343,11 @@ Note that all messages communicated between the debugger and the debuggee are *N
343
343
 
344
344
  #### `require 'debug/open'` in a program
345
345
 
346
- If you can modify the program, you can open debugging port by adding `require 'debug/open'` line in the program.
346
+ If you can modify the program, you can open the debugging port by adding `require 'debug/open'` line in the program.
347
347
 
348
348
  If you don't want to stop the program at the beginning, you can also use `require 'debug/open_nonstop'`.
349
349
  Using `debug/open_nonstop` is useful if you want to open a backdoor to the application.
350
- However, it is also danger because it can become another vulnerability.
350
+ However, it is also dangerous because it can become another vulnerability.
351
351
  Please use it carefully.
352
352
 
353
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.
@@ -372,7 +372,7 @@ Also `open` command allows opening the debug port.
372
372
 
373
373
  ([vscode-rdbg v0.0.9](https://marketplace.visualstudio.com/items?itemName=KoichiSasada.vscode-rdbg) or later is required)
374
374
 
375
- If you don't run a debuggee Ruby process on VSCode, you can attach with VSCode later with the following steps.
375
+ If you don't run a debuggee Ruby process on VSCode, you can attach it to VSCode later with the following steps.
376
376
 
377
377
  `rdbg --open=vscode` opens the debug port and tries to invoke the VSCode (`code` command).
378
378
 
@@ -425,7 +425,7 @@ If your application is running on a SSH remote host, please try:
425
425
 
426
426
  ```
427
427
 
428
- and try to use proposed commands.
428
+ and try to use the proposed commands.
429
429
 
430
430
  Note that you can attach with `rdbg --attach` and continue REPL debugging.
431
431
 
@@ -443,7 +443,7 @@ DEBUGGER: With Chrome browser, type the following URL in the address-bar:
443
443
  DEBUGGER: wait for debugger connection...
444
444
  ```
445
445
 
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.
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.
447
447
 
448
448
  Also `open chrome` command works like `open vscode`.
449
449
 
@@ -456,7 +456,7 @@ When the debug session is started, initial scripts are loaded so you can put you
456
456
 
457
457
  ### Configuration list
458
458
 
459
- You can configure debugger's behavior with environment variables and `config` command. Each configuration has environment variable and the name which can be specified by `config` command.
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.
460
460
 
461
461
  ```
462
462
  # configuration example
@@ -477,6 +477,7 @@ config set no_color true
477
477
  * `RUBY_DEBUG_NO_RELINE` (`no_reline`): Do not use Reline library (default: false)
478
478
  * `RUBY_DEBUG_NO_HINT` (`no_hint`): Do not show the hint on the REPL (default: false)
479
479
  * `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)
480
481
 
481
482
  * CONTROL
482
483
  * `RUBY_DEBUG_SKIP_PATH` (`skip_path`): Skip showing/entering frames for given paths
@@ -504,6 +505,7 @@ config set no_color true
504
505
  * `RUBY_DEBUG_LOCAL_FS_MAP` (`local_fs_map`): Specify local fs map
505
506
  * `RUBY_DEBUG_SKIP_BP` (`skip_bp`): Skip breakpoints if no clients are attached (default: false)
506
507
  * `RUBY_DEBUG_COOKIE` (`cookie`): Cookie for negotiation
508
+ * `RUBY_DEBUG_SESSION_NAME` (`session_name`): Session name for differentiating multiple sessions
507
509
  * `RUBY_DEBUG_CHROME_PATH` (`chrome_path`): Platform dependent path of Chrome (For more information, See [here](https://github.com/ruby/debug/pull/334/files#diff-5fc3d0a901379a95bc111b86cf0090b03f857edfd0b99a0c1537e26735698453R55-R64))
508
510
 
509
511
  * OBSOLETE
@@ -513,7 +515,7 @@ There are other environment variables:
513
515
 
514
516
  * `NO_COLOR`: If the value is set, set `RUBY_DEBUG_NO_COLOR` ([NO_COLOR: disabling ANSI color output in various Unix commands](https://no-color.org/)).
515
517
  * `RUBY_DEBUG_ENABLE`: If the value is `0`, do not enable debug.gem feature.
516
- * `RUBY_DEBUG_ADDED_RUBYOPT`: Remove this value from `RUBYOPT` at first. This feature helps loading debug.gem with `RUBYOPT='-r debug/...'` and you don't want to derive it to child processes. In this case you can set `RUBY_DEBUG_ADDED_RUBYOPT='-r debug/...'` (same value) and this string will be deleted from `RUBYOPT` at first.
518
+ * `RUBY_DEBUG_ADDED_RUBYOPT`: Remove this value from `RUBYOPT` at first. This feature helps loading debug.gem with `RUBYOPT='-r debug/...'`, and you don't want to derive it to child processes. In this case, you can set `RUBY_DEBUG_ADDED_RUBYOPT='-r debug/...'` (same value), and this string will be deleted from `RUBYOPT` at first.
517
519
  * `RUBY_DEBUG_EDITOR` or `EDITOR`: An editor used by `edit` debug command.
518
520
  * `RUBY_DEBUG_BB`: Define `Kernel#bb` method which is alias of `Kernel#debugger`.
519
521
 
@@ -525,7 +527,7 @@ If there is `~/.rdbgrc`, the file is loaded as an initial script (which contains
525
527
  * You can specify the initial script with `rdbg -x initial_script` (like gdb's `-x` option).
526
528
 
527
529
  Initial scripts are useful to write your favorite configurations.
528
- For example, you can set break points with `break file:123` in `~/.rdbgrc`.
530
+ For example, you can set breakpoints with `break file:123` in `~/.rdbgrc`.
529
531
 
530
532
  If there are `~/.rdbgrc.rb` is available, it is also loaded as a ruby script at same timing.
531
533
 
@@ -535,16 +537,16 @@ On the debug console, you can use the following debug commands.
535
537
 
536
538
  There are additional features:
537
539
 
538
- * `<expr>` without debug command is almost same as `pp <expr>`.
539
- * 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 same as `pp foo.bar`.
540
- * 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.
541
- * So the author (Koichi Sasada) recommends to use `p`, `pp` or `eval` command to evaluate the Ruby expression everytime.
540
+ * `<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.
542
544
  * `Enter` without any input repeats the last command (useful when repeating `step`s) for some commands.
543
545
  * `Ctrl-D` is equal to `quit` command.
544
546
  * [debug command compare sheet - Google Sheets](https://docs.google.com/spreadsheets/d/1TlmmUDsvwK4sSIyoMv-io52BUUz__R5wpu-ComXlsw0/edit?usp=sharing)
545
547
 
546
548
  You can use the following debug commands. Each command should be written in 1 line.
547
- The `[...]` notation means this part can be eliminate. For example, `s[tep]` means `s` or `step` are valid command. `ste` is not valid.
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.
548
550
  The `<...>` notation means the argument.
549
551
 
550
552
  ### Control flow
@@ -814,7 +816,7 @@ Emacs support available.
814
816
 
815
817
  #### Start by method
816
818
 
817
- After loading `debug/session`, you can start debug session with the following methods. They are convenient if you want to specify debug configurations in your program.
819
+ 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.
818
820
 
819
821
  * `DEBUGGER__.start(**kw)`: start debug session with local console.
820
822
  * `DEBUGGER__.open(**kw)`: open debug port with configuration (without configurations open with UNIX domain socket)
@@ -833,9 +835,9 @@ DEBUGGER__.start(no_color: true, # disable colorize
833
835
 
834
836
  ### `binding.break` method
835
837
 
836
- `binding.break` (or `binding.b`) set breakpoints at written line. It also has several keywords.
838
+ `binding.break` (or `binding.b`) set breakpoints at the written line. It also has several keywords.
837
839
 
838
- If `do: 'command'` is specified, the debugger suspends the program and run the `command` as a debug command and continue the program.
840
+ If `do: 'command'` is specified, the debugger suspends the program, runs the `command` as a debug command, and continues the program.
839
841
  It is useful if you only want to call a debug command and don't want to stop there.
840
842
 
841
843
  ```
@@ -845,9 +847,9 @@ def initialize
845
847
  end
846
848
  ```
847
849
 
848
- On 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.
850
+ 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.
849
851
 
850
- If `pre: 'command'` is specified, the debugger suspends the program and run the `command` as a debug command, and keep suspend.
852
+ If `pre: 'command'` is specified, the debugger suspends the program and runs the `command` as a debug command, and keeps suspended.
851
853
  It is useful if you have operations before suspend.
852
854
 
853
855
  ```
@@ -857,7 +859,7 @@ def foo
857
859
  end
858
860
  ```
859
861
 
860
- On this case, you can see the result of `bar()` every time you stop there.
862
+ In this case, you can see the result of `bar()` every time you stop there.
861
863
 
862
864
  ## rdbg command help
863
865
 
@@ -883,6 +885,7 @@ Debug console mode:
883
885
  --port=PORT Listening TCP/IP port
884
886
  --host=HOST Listening TCP/IP host
885
887
  --cookie=COOKIE Set a cookie for connection
888
+ --session-name=NAME Session name
886
889
 
887
890
  Debug console mode runs Ruby program with the debug console.
888
891
 
data/debug.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.description = %q{Debugging functionality for Ruby. This is completely rewritten debug.rb which was contained by the ancient Ruby versions.}
11
11
  spec.homepage = "https://github.com/ruby/debug"
12
12
  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")
14
14
 
15
15
  spec.metadata["homepage_uri"] = spec.homepage
16
16
  spec.metadata["source_code_uri"] = spec.homepage
@@ -27,6 +27,6 @@ Gem::Specification.new do |spec|
27
27
  spec.require_paths = ["lib"]
28
28
  spec.extensions = ['ext/debug/extconf.rb']
29
29
 
30
- spec.add_dependency "irb", ">= 1.5.0" # for binding.irb(show_code: false)
31
- spec.add_dependency "reline", ">= 0.3.1"
30
+ spec.add_dependency "irb", "~> 1.10" # for irb:debug integration
31
+ spec.add_dependency "reline", ">= 0.3.8"
32
32
  end
data/ext/debug/debug.c CHANGED
@@ -180,13 +180,17 @@ iseq_last_line(VALUE iseqw)
180
180
  }
181
181
  #endif
182
182
 
183
+ #ifdef HAVE_RB_ISEQ
183
184
  void Init_iseq_collector(void);
185
+ #endif
184
186
 
185
187
  void
186
188
  Init_debug(void)
187
189
  {
190
+ #ifdef HAVE_RB_ISEQ
188
191
  VALUE rb_mRubyVM = rb_const_get(rb_cObject, rb_intern("RubyVM"));
189
192
  VALUE rb_cISeq = rb_const_get(rb_mRubyVM, rb_intern("InstructionSequence"));
193
+ #endif
190
194
  rb_mDebugger = rb_const_get(rb_cObject, rb_intern("DEBUGGER__"));
191
195
  rb_cFrameInfo = rb_const_get(rb_mDebugger, rb_intern("FrameInfo"));
192
196
 
@@ -210,5 +214,7 @@ Init_debug(void)
210
214
  rb_define_method(rb_cISeq, "last_line", iseq_last_line, 0);
211
215
  #endif
212
216
 
217
+ #ifdef HAVE_RB_ISEQ
213
218
  Init_iseq_collector();
219
+ #endif
214
220
  }
data/ext/debug/extconf.rb CHANGED
@@ -4,6 +4,7 @@ File.write("debug_version.h", "#define RUBY_DEBUG_VERSION \"#{DEBUGGER__::VERSIO
4
4
  $distcleanfiles << "debug_version.h"
5
5
 
6
6
  if defined? RubyVM
7
+ $defs << '-DHAVE_RB_ISEQ'
7
8
  $defs << '-DHAVE_RB_ISEQ_PARAMETERS'
8
9
  $defs << '-DHAVE_RB_ISEQ_CODE_LOCATION'
9
10
 
@@ -1,5 +1,6 @@
1
1
  #include <ruby/ruby.h>
2
2
 
3
+ #ifdef HAVE_RB_ISEQ
3
4
  VALUE rb_iseqw_new(VALUE v);
4
5
  void rb_objspace_each_objects(
5
6
  int (*callback)(void *start, void *end, size_t stride, void *data),
@@ -89,3 +90,4 @@ Init_iseq_collector(void)
89
90
  rb_define_singleton_method(rb_mObjSpace, "each_iseq", each_iseq, 0);
90
91
  rb_define_singleton_method(rb_mObjSpace, "count_iseq", count_iseq, 0);
91
92
  }
93
+ #endif
data/lib/debug/client.rb CHANGED
@@ -165,15 +165,16 @@ module DEBUGGER__
165
165
  end
166
166
  else
167
167
  Client.cleanup_unix_domain_sockets
168
- files = Client.list_connections verbose: true
168
+ files = Client.list_connections
169
169
 
170
170
  case files.size
171
171
  when 0
172
172
  $stderr.puts "No debug session is available."
173
173
  exit
174
174
  when 1
175
- @s = Socket.unix(files.first.first)
175
+ @s = Socket.unix(files.first)
176
176
  else
177
+ files = Client.list_connections verbose: true
177
178
  $stderr.puts "Please select a debug session:"
178
179
  files.each{|(f, desc)|
179
180
  $stderr.puts " #{File.basename(f)} (#{desc})"
data/lib/debug/config.rb CHANGED
@@ -22,6 +22,7 @@ module DEBUGGER__
22
22
  no_reline: ['RUBY_DEBUG_NO_RELINE', "UI: Do not use Reline library", :bool, "false"],
23
23
  no_hint: ['RUBY_DEBUG_NO_HINT', "UI: Do not show the hint on the REPL", :bool, "false"],
24
24
  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"],
25
26
 
26
27
  # control setting
27
28
  skip_path: ['RUBY_DEBUG_SKIP_PATH', "CONTROL: Skip showing/entering frames for given paths", :path],
@@ -49,6 +50,7 @@ module DEBUGGER__
49
50
  local_fs_map: ['RUBY_DEBUG_LOCAL_FS_MAP', "REMOTE: Specify local fs map", :path_map],
50
51
  skip_bp: ['RUBY_DEBUG_SKIP_BP', "REMOTE: Skip breakpoints if no clients are attached", :bool, 'false'],
51
52
  cookie: ['RUBY_DEBUG_COOKIE', "REMOTE: Cookie for negotiation"],
53
+ session_name: ['RUBY_DEBUG_SESSION_NAME', "REMOTE: Session name for differentiating multiple sessions"],
52
54
  chrome_path: ['RUBY_DEBUG_CHROME_PATH', "REMOTE: Platform dependent path of Chrome (For more information, See [here](https://github.com/ruby/debug/pull/334/files#diff-5fc3d0a901379a95bc111b86cf0090b03f857edfd0b99a0c1537e26735698453R55-R64))"],
53
55
 
54
56
  # obsolete
@@ -340,6 +342,9 @@ module DEBUGGER__
340
342
  o.on('--cookie=COOKIE', 'Set a cookie for connection') do |c|
341
343
  config[:cookie] = c
342
344
  end
345
+ o.on('--session-name=NAME', 'Session name') do |name|
346
+ config[:session_name] = name
347
+ end
343
348
 
344
349
  rdbg = 'rdbg'
345
350
 
@@ -411,7 +416,6 @@ module DEBUGGER__
411
416
  if argv.empty?
412
417
  case
413
418
  when have_shown_version && config[:mode] == :start
414
- pp config
415
419
  exit
416
420
  end
417
421
  end
@@ -458,7 +462,7 @@ module DEBUGGER__
458
462
  require 'tmpdir'
459
463
 
460
464
  if tmpdir = Dir.tmpdir
461
- path = File.join(tmpdir, "ruby-debug-sock-#{Process.uid}")
465
+ path = File.join(tmpdir, "rdbg-#{Process.uid}")
462
466
 
463
467
  unless File.exist?(path)
464
468
  d = Dir.mktmpdir
@@ -471,7 +475,7 @@ module DEBUGGER__
471
475
 
472
476
  def self.unix_domain_socket_homedir
473
477
  if home = ENV['HOME']
474
- path = File.join(home, '.ruby-debug-sock')
478
+ path = File.join(home, '.rdbg-sock')
475
479
 
476
480
  unless File.exist?(path)
477
481
  Dir.mkdir(path, 0700)
@@ -495,12 +499,14 @@ module DEBUGGER__
495
499
  end
496
500
 
497
501
  def self.create_unix_domain_socket_name_prefix(base_dir = unix_domain_socket_dir)
498
- user = ENV['USER'] || 'UnknownUser'
499
- File.join(base_dir, "ruby-debug-#{user}")
502
+ File.join(base_dir, "rdbg")
500
503
  end
501
504
 
502
505
  def self.create_unix_domain_socket_name(base_dir = unix_domain_socket_dir)
503
- create_unix_domain_socket_name_prefix(base_dir) + "-#{Process.pid}"
506
+ suffix = "-#{Process.pid}"
507
+ name = CONFIG[:session_name]
508
+ suffix << "-#{name}" if name
509
+ create_unix_domain_socket_name_prefix(base_dir) + suffix
504
510
  end
505
511
 
506
512
  ## Help
data/lib/debug/console.rb CHANGED
@@ -5,30 +5,9 @@ module DEBUGGER__
5
5
  raise LoadError if CONFIG[:no_reline]
6
6
  require 'reline'
7
7
 
8
- # reline 0.2.7 or later is required.
9
- raise LoadError if Reline::VERSION < '0.2.7'
10
-
11
8
  require_relative 'color'
12
- include Color
13
-
14
- begin
15
- prev = trap(:SIGWINCH, nil)
16
- trap(:SIGWINCH, prev)
17
- SIGWINCH_SUPPORTED = true
18
- rescue ArgumentError
19
- SIGWINCH_SUPPORTED = false
20
- end
21
9
 
22
- # 0.2.7 has SIGWINCH issue on non-main thread
23
- class ::Reline::LineEditor
24
- m = Module.new do
25
- def reset(prompt = '', encoding:)
26
- super
27
- Signal.trap(:SIGWINCH, nil)
28
- end
29
- end
30
- prepend m
31
- end if SIGWINCH_SUPPORTED
10
+ include Color
32
11
 
33
12
  def parse_input buff, commands
34
13
  c, rest = get_command buff
@@ -56,10 +35,10 @@ module DEBUGGER__
56
35
  Reline.prompt_proc = -> args, *kw do
57
36
  case state = parse_input(args.first, commands)
58
37
  when nil, :command
59
- [prompt, prompt]
38
+ [prompt]
60
39
  when :ruby
61
- [prompt.sub('rdbg'){colorize('ruby', [:RED])}] * 2
62
- end
40
+ [prompt.sub('rdbg'){colorize('ruby', [:RED])}]
41
+ end * args.size
63
42
  end
64
43
 
65
44
  Reline.completion_proc = -> given do
@@ -96,7 +75,7 @@ module DEBUGGER__
96
75
  when nil
97
76
  buff
98
77
  when :ruby
99
- colorize_code(buff.chomp)
78
+ colorize_code(buff)
100
79
  end
101
80
  end unless CONFIG[:no_hint]
102
81
 
@@ -224,11 +203,11 @@ module DEBUGGER__
224
203
  end
225
204
 
226
205
  def load_history
227
- read_history_file.count{|line|
206
+ read_history_file.each{|line|
228
207
  line.strip!
229
208
  history << line unless line.empty?
230
- }
209
+ } if history.empty?
210
+ history.count
231
211
  end
232
212
  end # class Console
233
213
  end
234
-
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'irb'
4
+
5
+ module DEBUGGER__
6
+ module IrbPatch
7
+ def evaluate(line, line_no)
8
+ SESSION.send(:restart_all_threads)
9
+ super
10
+ # This is to communicate with the test framework so it can feed the next input
11
+ puts "INTERNAL_INFO: {}" if ENV['RUBY_DEBUG_TEST_UI'] == 'terminal'
12
+ ensure
13
+ SESSION.send(:stop_all_threads)
14
+ end
15
+ end
16
+
17
+ class ThreadClient
18
+ def activate_irb_integration
19
+ IRB.setup(location, argv: [])
20
+ workspace = IRB::WorkSpace.new(current_frame&.binding || TOPLEVEL_BINDING)
21
+ irb = IRB::Irb.new(workspace)
22
+ IRB.conf[:MAIN_CONTEXT] = irb.context
23
+ IRB::Debug.setup(irb)
24
+ IRB::Context.prepend(IrbPatch)
25
+ end
26
+ end
27
+ end
data/lib/debug/server.rb CHANGED
@@ -133,7 +133,7 @@ module DEBUGGER__
133
133
  require 'etc'
134
134
 
135
135
  check_cookie $1
136
- @sock.puts "PID: #{Process.pid}, $0: #{$0}"
136
+ @sock.puts "PID: #{Process.pid}, $0: #{$0}, session_name: #{CONFIG[:session_name]}"
137
137
  @sock.puts "debug #{VERSION} on #{RUBY_DESCRIPTION}"
138
138
  @sock.puts "uname: #{Etc.uname.inspect}"
139
139
  @sock.close
@@ -149,7 +149,9 @@ module DEBUGGER__
149
149
  end
150
150
  parse_option(params)
151
151
 
152
- puts "DEBUGGER (client): Connected. PID:#{Process.pid}, $0:#{$0}"
152
+ session_name = CONFIG[:session_name]
153
+ session_name_str = ", session_name:#{session_name}" if session_name
154
+ puts "DEBUGGER (client): Connected. PID:#{Process.pid}, $0:#{$0}#{session_name_str}"
153
155
  puts "DEBUGGER (client): Type `Ctrl-C` to enter the debug console." unless @need_pause_at_first
154
156
  puts
155
157
 
@@ -410,7 +412,7 @@ module DEBUGGER__
410
412
  DEBUGGER__.warn <<~EOS
411
413
  With Chrome browser, type the following URL in the address-bar:
412
414
 
413
- devtools://devtools/bundled/inspector.html?v8only=true&panel=sources&ws=#{@local_addr.inspect_sockaddr}/#{@uuid}
415
+ devtools://devtools/bundled/inspector.html?v8only=true&panel=sources&noJavaScriptCompletion=true&ws=#{@local_addr.inspect_sockaddr}/#{@uuid}
414
416
 
415
417
  EOS
416
418
  end
@@ -59,7 +59,7 @@ module DEBUGGER__
59
59
  ws_client.send sessionId: s_id, id: 5,
60
60
  method: 'Page.navigate',
61
61
  params: {
62
- url: "devtools://devtools/bundled/inspector.html?v8only=true&panel=sources&ws=#{addr}/#{uuid}",
62
+ url: "devtools://devtools/bundled/inspector.html?v8only=true&panel=sources&noJavaScriptCompletion=true&ws=#{addr}/#{uuid}",
63
63
  frameId: f_id
64
64
  }
65
65
  when 101
@@ -474,7 +474,7 @@ module DEBUGGER__
474
474
  when 'Debugger.getScriptSource'
475
475
  @q_msg << req
476
476
  when 'Debugger.enable'
477
- send_response req
477
+ send_response req, debuggerId: rand.to_s
478
478
  @q_msg << req
479
479
  when 'Runtime.enable'
480
480
  send_response req
@@ -788,7 +788,9 @@ module DEBUGGER__
788
788
 
789
789
  def dap_eval b, expr, _context, prompt: '(repl_eval)'
790
790
  begin
791
- b.eval(expr.to_s, prompt)
791
+ tp_allow_reentry do
792
+ b.eval(expr.to_s, prompt)
793
+ end
792
794
  rescue Exception => e
793
795
  e
794
796
  end
data/lib/debug/session.rb CHANGED
@@ -82,7 +82,7 @@ class RubyVM::InstructionSequence
82
82
  def first_line
83
83
  self.to_a[4][:code_location][0]
84
84
  end unless method_defined?(:first_line)
85
- end
85
+ end if defined?(RubyVM::InstructionSequence)
86
86
 
87
87
  module DEBUGGER__
88
88
  PresetCommands = Struct.new(:commands, :source, :auto_continue)
@@ -133,7 +133,7 @@ module DEBUGGER__
133
133
  @commands = {}
134
134
  @unsafe_context = false
135
135
 
136
- @has_keep_script_lines = RubyVM.respond_to? :keep_script_lines
136
+ @has_keep_script_lines = defined?(RubyVM.keep_script_lines)
137
137
 
138
138
  @tp_load_script = TracePoint.new(:script_compiled){|tp|
139
139
  eval_script = tp.eval_script unless @has_keep_script_lines
@@ -202,6 +202,11 @@ 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
+
205
210
  # session start
206
211
  q << true
207
212
  session_server_main
@@ -256,6 +261,15 @@ module DEBUGGER__
256
261
  @tc << req
257
262
  end
258
263
 
264
+ def request_tc_with_restarted_threads(req)
265
+ restart_all_threads
266
+ request_tc(req)
267
+ end
268
+
269
+ def request_eval type, src
270
+ request_tc_with_restarted_threads [:eval, type, src]
271
+ end
272
+
259
273
  def process_event evt
260
274
  # variable `@internal_info` is only used for test
261
275
  tc, output, ev, @internal_info, *ev_args = evt
@@ -314,7 +328,7 @@ module DEBUGGER__
314
328
  if @displays.empty?
315
329
  wait_command_loop
316
330
  else
317
- request_tc [:eval, :display, @displays]
331
+ request_eval :display, @displays
318
332
  end
319
333
  when :result
320
334
  raise "[BUG] not in subsession" if @subsession_stack.empty?
@@ -329,6 +343,7 @@ module DEBUGGER__
329
343
  end
330
344
  end
331
345
 
346
+ stop_all_threads
332
347
  when :method_breakpoint, :watch_breakpoint
333
348
  bp = ev_args[1]
334
349
  if bp
@@ -342,6 +357,7 @@ module DEBUGGER__
342
357
  obj_inspect = ev_args[2]
343
358
  opt = ev_args[3]
344
359
  add_tracer ObjectTracer.new(@ui, obj_id, obj_inspect, **opt)
360
+ stop_all_threads
345
361
  else
346
362
  stop_all_threads
347
363
  end
@@ -685,15 +701,15 @@ module DEBUGGER__
685
701
  register_command 'bt', 'backtrace', unsafe: false do |arg|
686
702
  case arg
687
703
  when /\A(\d+)\z/
688
- request_tc [:show, :backtrace, arg.to_i, nil]
704
+ request_tc_with_restarted_threads [:show, :backtrace, arg.to_i, nil]
689
705
  when /\A\/(.*)\/\z/
690
706
  pattern = $1
691
- request_tc [:show, :backtrace, nil, Regexp.compile(pattern)]
707
+ request_tc_with_restarted_threads [:show, :backtrace, nil, Regexp.compile(pattern)]
692
708
  when /\A(\d+)\s+\/(.*)\/\z/
693
709
  max, pattern = $1, $2
694
- request_tc [:show, :backtrace, max.to_i, Regexp.compile(pattern)]
710
+ request_tc_with_restarted_threads [:show, :backtrace, max.to_i, Regexp.compile(pattern)]
695
711
  else
696
- request_tc [:show, :backtrace, nil, nil]
712
+ request_tc_with_restarted_threads [:show, :backtrace, nil, nil]
697
713
  end
698
714
  end
699
715
 
@@ -810,15 +826,15 @@ module DEBUGGER__
810
826
 
811
827
  case sub
812
828
  when nil
813
- request_tc [:show, :default, pat] # something useful
829
+ request_tc_with_restarted_threads [:show, :default, pat] # something useful
814
830
  when :locals
815
- request_tc [:show, :locals, pat]
831
+ request_tc_with_restarted_threads [:show, :locals, pat]
816
832
  when :ivars
817
- request_tc [:show, :ivars, pat, opt]
833
+ request_tc_with_restarted_threads [:show, :ivars, pat, opt]
818
834
  when :consts
819
- request_tc [:show, :consts, pat, opt]
835
+ request_tc_with_restarted_threads [:show, :consts, pat, opt]
820
836
  when :globals
821
- request_tc [:show, :globals, pat]
837
+ request_tc_with_restarted_threads [:show, :globals, pat]
822
838
  when :threads
823
839
  thread_list
824
840
  :retry
@@ -838,7 +854,7 @@ module DEBUGGER__
838
854
  # * Show you available methods and instance variables of the given object.
839
855
  # * If the object is a class/module, it also lists its constants.
840
856
  register_command 'outline', 'o', 'ls', unsafe: false do |arg|
841
- request_tc [:show, :outline, arg]
857
+ request_tc_with_restarted_threads [:show, :outline, arg]
842
858
  end
843
859
 
844
860
  # * `display`
@@ -848,9 +864,9 @@ module DEBUGGER__
848
864
  register_command 'display', postmortem: false do |arg|
849
865
  if arg && !arg.empty?
850
866
  @displays << arg
851
- request_tc [:eval, :try_display, @displays]
867
+ request_eval :try_display, @displays
852
868
  else
853
- request_tc [:eval, :display, @displays]
869
+ request_eval :display, @displays
854
870
  end
855
871
  end
856
872
 
@@ -864,7 +880,7 @@ module DEBUGGER__
864
880
  if @displays[n = $1.to_i]
865
881
  @displays.delete_at n
866
882
  end
867
- request_tc [:eval, :display, @displays]
883
+ request_eval :display, @displays
868
884
  when nil
869
885
  if ask "clear all?", 'N'
870
886
  @displays.clear
@@ -925,10 +941,11 @@ module DEBUGGER__
925
941
  # * Invoke `irb` on the current frame.
926
942
  register_command 'irb' do |arg|
927
943
  if @ui.remote?
928
- @ui.puts "not supported on the remote console."
944
+ @ui.puts "\nIRB is not supported on the remote console."
929
945
  :retry
946
+ else
947
+ request_eval :irb, nil
930
948
  end
931
- request_eval :irb, nil
932
949
  end
933
950
 
934
951
  ### Trace
@@ -983,7 +1000,7 @@ module DEBUGGER__
983
1000
  :retry
984
1001
 
985
1002
  when /\Aobject\s+(.+)/
986
- request_tc [:trace, :object, $1.strip, {pattern: pattern, into: into}]
1003
+ request_tc_with_restarted_threads [:trace, :object, $1.strip, {pattern: pattern, into: into}]
987
1004
 
988
1005
  when /\Aoff\s+(\d+)\z/
989
1006
  if t = @tracers.values[$1.to_i]
@@ -1164,11 +1181,6 @@ module DEBUGGER__
1164
1181
  return :retry
1165
1182
  end
1166
1183
 
1167
- def request_eval type, src
1168
- restart_all_threads
1169
- request_tc [:eval, type, src]
1170
- end
1171
-
1172
1184
  def step_command type, arg
1173
1185
  if type == :until
1174
1186
  leave_subsession [:step, type, arg]
@@ -1739,15 +1751,19 @@ module DEBUGGER__
1739
1751
  # check breakpoints
1740
1752
  if file_path
1741
1753
  @bps.find_all do |_key, bp|
1742
- LineBreakpoint === bp && bp.path_is?(file_path)
1754
+ LineBreakpoint === bp && bp.path_is?(file_path) && (iseq.first_lineno..iseq.last_line).cover?(bp.line)
1743
1755
  end.each do |_key, bp|
1744
1756
  if !bp.iseq
1745
1757
  bp.try_activate iseq
1746
1758
  elsif reloaded
1747
1759
  @bps.delete bp.key # to allow duplicate
1748
- if nbp = LineBreakpoint.copy(bp, iseq)
1749
- add_bp nbp
1750
- end
1760
+
1761
+ # When we delete a breakpoint from the @bps hash, we also need to deactivate it or else its tracepoint event
1762
+ # will continue to be enabled and we'll suspend on ghost breakpoints
1763
+ bp.delete
1764
+
1765
+ nbp = LineBreakpoint.copy(bp, iseq)
1766
+ add_bp nbp
1751
1767
  end
1752
1768
  end
1753
1769
  else # !file_path => file_path is not existing
@@ -2174,6 +2190,7 @@ module DEBUGGER__
2174
2190
  case loc.absolute_path
2175
2191
  when dir_prefix
2176
2192
  when %r{rubygems/core_ext/kernel_require\.rb}
2193
+ when %r{bundled_gems\.rb}
2177
2194
  else
2178
2195
  return loc if loc.absolute_path
2179
2196
  end
@@ -2534,7 +2551,7 @@ module DEBUGGER__
2534
2551
  sig
2535
2552
  end
2536
2553
 
2537
- case sig&.to_s&.to_sym
2554
+ case sym
2538
2555
  when :INT, :SIGINT
2539
2556
  if defined?(SESSION) && SESSION.active? && SESSION.intercept_trap_sigint?
2540
2557
  return SESSION.save_int_trap(command.empty? ? command_proc : command.first)
@@ -22,7 +22,7 @@ module DEBUGGER__
22
22
  end
23
23
  end
24
24
 
25
- if RubyVM.respond_to? :keep_script_lines
25
+ if defined?(RubyVM.keep_script_lines)
26
26
  # Ruby 3.1 and later
27
27
  RubyVM.keep_script_lines = true
28
28
  require 'objspace'
@@ -5,6 +5,10 @@ require 'pp'
5
5
 
6
6
  require_relative 'color'
7
7
 
8
+ class ::Thread
9
+ attr_accessor :debug_thread_client
10
+ end
11
+
8
12
  module DEBUGGER__
9
13
  M_INSTANCE_VARIABLES = method(:instance_variables).unbind
10
14
  M_INSTANCE_VARIABLE_GET = method(:instance_variable_get).unbind
@@ -48,12 +52,7 @@ module DEBUGGER__
48
52
 
49
53
  class ThreadClient
50
54
  def self.current
51
- if thc = Thread.current[:DEBUGGER__ThreadClient]
52
- thc
53
- else
54
- thc = SESSION.get_thread_client
55
- Thread.current[:DEBUGGER__ThreadClient] = thc
56
- end
55
+ Thread.current.debug_thread_client ||= SESSION.get_thread_client
57
56
  end
58
57
 
59
58
  include Color
@@ -614,7 +613,7 @@ module DEBUGGER__
614
613
  if expr && !expr.empty?
615
614
  begin
616
615
  _self = frame_eval(expr, re_raise: true)
617
- rescue Exception => e
616
+ rescue Exception
618
617
  # ignore
619
618
  else
620
619
  if M_KIND_OF_P.bind_call(_self, Module)
@@ -862,8 +861,18 @@ module DEBUGGER__
862
861
  class SuspendReplay < Exception
863
862
  end
864
863
 
864
+ if ::Fiber.respond_to?(:blocking)
865
+ private def fiber_blocking
866
+ ::Fiber.blocking{yield}
867
+ end
868
+ else
869
+ private def fiber_blocking
870
+ yield
871
+ end
872
+ end
873
+
865
874
  def wait_next_action
866
- wait_next_action_
875
+ fiber_blocking{wait_next_action_}
867
876
  rescue SuspendReplay
868
877
  replay_suspend
869
878
  end
@@ -1048,13 +1057,8 @@ module DEBUGGER__
1048
1057
  when :call
1049
1058
  result = frame_eval(eval_src)
1050
1059
  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
1060
+ require_relative "irb_integration"
1061
+ activate_irb_integration
1058
1062
  when :display, :try_display
1059
1063
  failed_results = []
1060
1064
  eval_src.each_with_index{|src, i|
data/lib/debug/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DEBUGGER__
4
- VERSION = "1.8.0"
4
+ VERSION = "1.9.0"
5
5
  end
data/misc/README.md.erb CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  # debug.rb
4
4
 
5
- This library provides debugging functionality to Ruby (MRI) 2.6 and later.
5
+ This library provides debugging functionality to Ruby (MRI) 2.7 and later.
6
6
 
7
- This debug.rb is replacement of traditional lib/debug.rb standard library which is implemented by `set_trace_func`.
7
+ This debug.rb is the replacement of traditional lib/debug.rb standard library, which is implemented by `set_trace_func`.
8
8
  New debug.rb has several advantages:
9
9
 
10
10
  * Fast: No performance penalty on non-stepping mode and non-breakpoints.
@@ -18,7 +18,7 @@ New debug.rb has several advantages:
18
18
  Connection | UDS, TCP/IP | UDS, TCP/IP | TCP/IP |
19
19
  Requirement | No | [vscode-rdbg](https://marketplace.visualstudio.com/items?itemName=KoichiSasada.vscode-rdbg) | Chrome |
20
20
 
21
- * Extensible: application can introduce debugging support with several ways:
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
@@ -55,7 +55,7 @@ To use a debugger, roughly you will do the following steps:
55
55
  4. Use debug commands.
56
56
  * [Evaluate Ruby expressions](#evaluate) (e.g. `p lvar` to see the local variable `lvar`).
57
57
  * [Query the program status](#information) (e.g. `info` to see information about the current frame).
58
- * [Control program flow](#control-flow) (e.g. move to the another line with `step`, to the next line with `next`).
58
+ * [Control program flow](#control-flow) (e.g. move to another line with `step`, to the next line with `next`).
59
59
  * [Set another breakpoint](#breakpoint) (e.g. `catch Exception` to set a breakpoint that'll be triggered when `Exception` is raised).
60
60
  * [Activate tracing in your program](#trace) (e.g. `trace call` to trace method calls).
61
61
  * [Change the configuration](#configuration-1) (e.g. `config set no_color true` to disable coloring).
@@ -180,7 +180,7 @@ DEBUGGER: Session start (pid: 7656)
180
180
  #1 BP - Line /mnt/c/ko1/src/rb/ruby-debug/target.rb:5 (line)
181
181
  ```
182
182
 
183
- You can see that two breakpoints are registered. Let's continue the program by `continue` command.
183
+ You can see that two breakpoints are registered. Let's continue the program by using the `continue` command.
184
184
 
185
185
  ```shell
186
186
  (rdbg) continue
@@ -200,8 +200,8 @@ Stop by #0 BP - Line /mnt/c/ko1/src/rb/ruby-debug/target.rb:3 (line)
200
200
  ```
201
201
 
202
202
  You can see that we can stop at line 3.
203
- Let's see the local variables with `info` command, and continue.
204
- You can also confirm that the program will suspend at line 5 and you can use `info` command again.
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.
205
205
 
206
206
  ```shell
207
207
  (rdbg) info
@@ -238,14 +238,14 @@ d => 4
238
238
  ```
239
239
 
240
240
  By the way, using `rdbg` command you can suspend your application with `C-c` (SIGINT) and enter the debug console.
241
- It will help that if you want to know what the program is doing.
241
+ It will help if you want to know what the program is doing.
242
242
 
243
243
  ### Use `rdbg` with commands written in Ruby
244
244
 
245
- If you want to run a command written in Ruby like like `rake`, `rails`, `bundle`, `rspec` and so on, you can use `rdbg -c` option.
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
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 command in `PATH` and simply invoke it 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.
249
249
 
250
250
  Examples:
251
251
  * `rdbg -c -- rails server`
@@ -263,27 +263,27 @@ Like other languages, you can use this debugger on the VSCode.
263
263
 
264
264
  1. Install [VSCode rdbg Ruby Debugger - Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=KoichiSasada.vscode-rdbg)
265
265
  2. Open `.rb` file (e.g. `target.rb`)
266
- 3. Register breakpoints with "Toggle breakpoint" in Run menu (or type F9 key)
266
+ 3. Register breakpoints with "Toggle breakpoint" in the Run menu (or type F9 key)
267
267
  4. Choose "Start debugging" in "Run" menu (or type F5 key)
268
- 5. You will see a dialog "Debug command line" and you can choose your favorite command line your want to run.
269
- 6. Chosen command line is invoked with `rdbg -c` and VSCode shows the details at breakpoints.
268
+ 5. You will see a dialog "Debug command line" and you can choose your favorite command line you want to run.
269
+ 6. Chosen command line is invoked with `rdbg -c`, and VSCode shows the details at breakpoints.
270
270
 
271
- Please refer [Debugging in Visual Studio Code](https://code.visualstudio.com/docs/editor/debugging) for operations on VSCode.
271
+ Please refer to [Debugging in Visual Studio Code](https://code.visualstudio.com/docs/editor/debugging) for operations on VSCode.
272
272
 
273
273
  You can configure the extension in `.vscode/launch.json`.
274
274
  Please see the extension page for more details.
275
275
 
276
276
  ## Remote debugging
277
277
 
278
- You can use this debugger as a remote debugger. For example, it will help the following situations:
278
+ You can use this debugger as a remote debugger. For example, it will help in the following situations:
279
279
 
280
- * Your application does not run on TTY and it is hard to use `binding.pry` or `binding.irb`.
281
- * Your application is running on Docker container and there is no TTY.
280
+ * Your application does not run on TTY, and it is hard to use `binding.pry` or `binding.irb`.
281
+ * Your application is running on a Docker container, and there is no TTY.
282
282
  * Your application is running as a daemon.
283
283
  * Your application uses pipe for STDIN or STDOUT.
284
284
  * Your application is running as a daemon and you want to query the running status (checking a backtrace and so on).
285
285
 
286
- You can run your application as a remote debuggee and the remote debugger console can attach to the debuggee anytime.
286
+ You can run your application as a remote debuggee, and the remote debugger console can attach to the debuggee anytime.
287
287
 
288
288
  ### Invoke as a remote debuggee
289
289
 
@@ -305,7 +305,7 @@ DEBUGGER: Debugger can attach via UNIX domain socket (/home/ko1/.ruby-debug-sock
305
305
  DEBUGGER: wait for debugger connection...
306
306
  ```
307
307
 
308
- By default, `rdbg --open` uses UNIX domain socket and generates path name automatically (`/home/ko1/.ruby-debug-sock/ruby-debug-ko1-7773` in this case).
308
+ By default, `rdbg --open` uses UNIX domain socket and generates the path name automatically (`/home/ko1/.ruby-debug-sock/ruby-debug-ko1-7773` in this case).
309
309
 
310
310
  You can connect to the debuggee with `rdbg --attach` command (`rdbg -A` for short).
311
311
 
@@ -324,11 +324,11 @@ $ rdbg -A
324
324
  (rdbg:remote)
325
325
  ```
326
326
 
327
- If there is no other opening ports on the default directory, `rdbg --attach` command chooses the only one opening UNIX domain socket and connect to it. If there are more files, you need to specify the file.
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.
328
328
 
329
- When `rdbg --attach` connects to the debuggee, you can use any debug commands (set breakpoints, continue the program and so on) like local debug console. When an debuggee program exits, the remote console will also terminate.
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.
330
330
 
331
- NOTE: If you use `quit` command, only 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.
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
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`.
334
334
 
@@ -343,11 +343,11 @@ Note that all messages communicated between the debugger and the debuggee are *N
343
343
 
344
344
  #### `require 'debug/open'` in a program
345
345
 
346
- If you can modify the program, you can open debugging port by adding `require 'debug/open'` line in the program.
346
+ If you can modify the program, you can open the debugging port by adding `require 'debug/open'` line in the program.
347
347
 
348
348
  If you don't want to stop the program at the beginning, you can also use `require 'debug/open_nonstop'`.
349
349
  Using `debug/open_nonstop` is useful if you want to open a backdoor to the application.
350
- However, it is also danger because it can become another vulnerability.
350
+ However, it is also dangerous because it can become another vulnerability.
351
351
  Please use it carefully.
352
352
 
353
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.
@@ -372,7 +372,7 @@ Also `open` command allows opening the debug port.
372
372
 
373
373
  ([vscode-rdbg v0.0.9](https://marketplace.visualstudio.com/items?itemName=KoichiSasada.vscode-rdbg) or later is required)
374
374
 
375
- If you don't run a debuggee Ruby process on VSCode, you can attach with VSCode later with the following steps.
375
+ If you don't run a debuggee Ruby process on VSCode, you can attach it to VSCode later with the following steps.
376
376
 
377
377
  `rdbg --open=vscode` opens the debug port and tries to invoke the VSCode (`code` command).
378
378
 
@@ -425,7 +425,7 @@ If your application is running on a SSH remote host, please try:
425
425
 
426
426
  ```
427
427
 
428
- and try to use proposed commands.
428
+ and try to use the proposed commands.
429
429
 
430
430
  Note that you can attach with `rdbg --attach` and continue REPL debugging.
431
431
 
@@ -443,7 +443,7 @@ DEBUGGER: With Chrome browser, type the following URL in the address-bar:
443
443
  DEBUGGER: wait for debugger connection...
444
444
  ```
445
445
 
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.
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.
447
447
 
448
448
  Also `open chrome` command works like `open vscode`.
449
449
 
@@ -456,7 +456,7 @@ When the debug session is started, initial scripts are loaded so you can put you
456
456
 
457
457
  ### Configuration list
458
458
 
459
- You can configure debugger's behavior with environment variables and `config` command. Each configuration has environment variable and the name which can be specified by `config` command.
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.
460
460
 
461
461
  ```
462
462
  # configuration example
@@ -473,7 +473,7 @@ There are other environment variables:
473
473
 
474
474
  * `NO_COLOR`: If the value is set, set `RUBY_DEBUG_NO_COLOR` ([NO_COLOR: disabling ANSI color output in various Unix commands](https://no-color.org/)).
475
475
  * `RUBY_DEBUG_ENABLE`: If the value is `0`, do not enable debug.gem feature.
476
- * `RUBY_DEBUG_ADDED_RUBYOPT`: Remove this value from `RUBYOPT` at first. This feature helps loading debug.gem with `RUBYOPT='-r debug/...'` and you don't want to derive it to child processes. In this case you can set `RUBY_DEBUG_ADDED_RUBYOPT='-r debug/...'` (same value) and this string will be deleted from `RUBYOPT` at first.
476
+ * `RUBY_DEBUG_ADDED_RUBYOPT`: Remove this value from `RUBYOPT` at first. This feature helps loading debug.gem with `RUBYOPT='-r debug/...'`, and you don't want to derive it to child processes. In this case, you can set `RUBY_DEBUG_ADDED_RUBYOPT='-r debug/...'` (same value), and this string will be deleted from `RUBYOPT` at first.
477
477
  * `RUBY_DEBUG_EDITOR` or `EDITOR`: An editor used by `edit` debug command.
478
478
  * `RUBY_DEBUG_BB`: Define `Kernel#bb` method which is alias of `Kernel#debugger`.
479
479
 
@@ -485,7 +485,7 @@ If there is `~/.rdbgrc`, the file is loaded as an initial script (which contains
485
485
  * You can specify the initial script with `rdbg -x initial_script` (like gdb's `-x` option).
486
486
 
487
487
  Initial scripts are useful to write your favorite configurations.
488
- For example, you can set break points with `break file:123` in `~/.rdbgrc`.
488
+ For example, you can set breakpoints with `break file:123` in `~/.rdbgrc`.
489
489
 
490
490
  If there are `~/.rdbgrc.rb` is available, it is also loaded as a ruby script at same timing.
491
491
 
@@ -495,16 +495,16 @@ On the debug console, you can use the following debug commands.
495
495
 
496
496
  There are additional features:
497
497
 
498
- * `<expr>` without debug command is almost same as `pp <expr>`.
499
- * 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 same as `pp foo.bar`.
500
- * 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.
501
- * So the author (Koichi Sasada) recommends to use `p`, `pp` or `eval` command to evaluate the Ruby expression everytime.
498
+ * `<expr>` without debug command is almost the same as `pp <expr>`.
499
+ * 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`.
500
+ * 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.
501
+ * So the author (Koichi Sasada) recommends using `p`, `pp` or `eval` command to evaluate the Ruby expression every time.
502
502
  * `Enter` without any input repeats the last command (useful when repeating `step`s) for some commands.
503
503
  * `Ctrl-D` is equal to `quit` command.
504
504
  * [debug command compare sheet - Google Sheets](https://docs.google.com/spreadsheets/d/1TlmmUDsvwK4sSIyoMv-io52BUUz__R5wpu-ComXlsw0/edit?usp=sharing)
505
505
 
506
506
  You can use the following debug commands. Each command should be written in 1 line.
507
- The `[...]` notation means this part can be eliminate. For example, `s[tep]` means `s` or `step` are valid command. `ste` is not valid.
507
+ The `[...]` notation means this part can be eliminated. For example, `s[tep]` means `s` or `step` is a valid command. `ste` is not valid.
508
508
  The `<...>` notation means the argument.
509
509
 
510
510
  <%= DEBUGGER__.help %>
@@ -541,7 +541,7 @@ Emacs support available.
541
541
 
542
542
  #### Start by method
543
543
 
544
- After loading `debug/session`, you can start debug session with the following methods. They are convenient if you want to specify debug configurations in your program.
544
+ 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.
545
545
 
546
546
  * `DEBUGGER__.start(**kw)`: start debug session with local console.
547
547
  * `DEBUGGER__.open(**kw)`: open debug port with configuration (without configurations open with UNIX domain socket)
@@ -560,9 +560,9 @@ DEBUGGER__.start(no_color: true, # disable colorize
560
560
 
561
561
  ### `binding.break` method
562
562
 
563
- `binding.break` (or `binding.b`) set breakpoints at written line. It also has several keywords.
563
+ `binding.break` (or `binding.b`) set breakpoints at the written line. It also has several keywords.
564
564
 
565
- If `do: 'command'` is specified, the debugger suspends the program and run the `command` as a debug command and continue the program.
565
+ If `do: 'command'` is specified, the debugger suspends the program, runs the `command` as a debug command, and continues the program.
566
566
  It is useful if you only want to call a debug command and don't want to stop there.
567
567
 
568
568
  ```
@@ -572,9 +572,9 @@ def initialize
572
572
  end
573
573
  ```
574
574
 
575
- On 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.
575
+ 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.
576
576
 
577
- If `pre: 'command'` is specified, the debugger suspends the program and run the `command` as a debug command, and keep suspend.
577
+ If `pre: 'command'` is specified, the debugger suspends the program and runs the `command` as a debug command, and keeps suspended.
578
578
  It is useful if you have operations before suspend.
579
579
 
580
580
  ```
@@ -584,7 +584,7 @@ def foo
584
584
  end
585
585
  ```
586
586
 
587
- On this case, you can see the result of `bar()` every time you stop there.
587
+ In this case, you can see the result of `bar()` every time you stop there.
588
588
 
589
589
  ## rdbg command help
590
590
 
metadata CHANGED
@@ -1,43 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: debug
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.0
4
+ version: 1.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Koichi Sasada
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-05-09 00:00:00.000000000 Z
11
+ date: 2023-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: irb
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.5.0
19
+ version: '1.10'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.5.0
26
+ version: '1.10'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: reline
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 0.3.1
33
+ version: 0.3.8
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 0.3.1
40
+ version: 0.3.8
41
41
  description: Debugging functionality for Ruby. This is completely rewritten debug.rb
42
42
  which was contained by the ancient Ruby versions.
43
43
  email:
@@ -68,6 +68,7 @@ files:
68
68
  - lib/debug/console.rb
69
69
  - lib/debug/dap_custom/traceInspector.rb
70
70
  - lib/debug/frame_info.rb
71
+ - lib/debug/irb_integration.rb
71
72
  - lib/debug/local.rb
72
73
  - lib/debug/open.rb
73
74
  - lib/debug/open_nonstop.rb
@@ -97,14 +98,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
97
98
  requirements:
98
99
  - - ">="
99
100
  - !ruby/object:Gem::Version
100
- version: 2.6.0
101
+ version: 2.7.0
101
102
  required_rubygems_version: !ruby/object:Gem::Requirement
102
103
  requirements:
103
104
  - - ">="
104
105
  - !ruby/object:Gem::Version
105
106
  version: '0'
106
107
  requirements: []
107
- rubygems_version: 3.3.7
108
+ rubygems_version: 3.5.0.dev
108
109
  signing_key:
109
110
  specification_version: 4
110
111
  summary: Debugging functionality for Ruby