debug 1.7.1 → 1.9.1

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: a84e87e9582c98cf24ca8aa9f1f30032c10736bf4dbc1c44da016db564a7a574
4
- data.tar.gz: da093ef6ebfd8fc5e4a10fcc39c59826e45829ec09da0d9dc164b9cd71085286
3
+ metadata.gz: cbc923d5ce88d6092dbc8125ee988ec386fffdc3409b8bca4113ab925bc61311
4
+ data.tar.gz: 2e0a5013263c3c220dfee989af1a87c224f36bf03504fef120785717df5b9ef7
5
5
  SHA512:
6
- metadata.gz: d663b6db0dba8921aaaa535f834e768367e07fef03613e6a277a27724fb75ecf830c7557465521998d42cbb41744e6335495958f626285468d6e38ae6ec52515
7
- data.tar.gz: cb24e62c5875c069812ff1b056dda3b912a20069d09123b72dbd0da69e61aed66968bc4dc5f80e9b599df743fb7755a2399f1461f344fc43ed9ea6bbf20f251c
6
+ metadata.gz: eb62ffd4d8111449f618b8a91a4ab9b89237916eeb71e0fd57dd1d78d4ddadff4a3897cbdf989cd989b9c0a52103f8bfd02f1e6cd9d2453b70bd72025f1b63aa
7
+ data.tar.gz: 81607797fa369d2eeed0fe35335d078ea04be3ab653dea8b653b0c25453c2000407a532c17246d41be175f1df34d7bebc069deb83fef976b39a79df2a399b79c
data/CONTRIBUTING.md CHANGED
@@ -149,10 +149,10 @@ If the file already exists, **only method** will be added to it.
149
149
  ```ruby
150
150
  # frozen_string_literal: true
151
151
 
152
- require_relative '../support/test_case'
152
+ require_relative '../support/console_test_case'
153
153
 
154
154
  module DEBUGGER__
155
- class FooTest < TestCase
155
+ class FooTest < ConsoleTestCase
156
156
  def program
157
157
  <<~RUBY
158
158
  1| module Foo
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
@@ -26,7 +26,7 @@ New debug.rb has several advantages:
26
26
  * Support threads (almost done) and ractors (TODO).
27
27
  * Support suspending and entering to the console debugging with `Ctrl-C` at most of timing.
28
28
  * Show parameters on backtrace command.
29
- * Support recording & reply debugging.
29
+ * Support recording & replay debugging.
30
30
 
31
31
  # Installation
32
32
 
@@ -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
@@ -476,6 +476,8 @@ config set no_color true
476
476
  * `RUBY_DEBUG_NO_SIGINT_HOOK` (`no_sigint_hook`): Do not suspend on SIGINT (default: false)
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
+ * `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)
479
481
 
480
482
  * CONTROL
481
483
  * `RUBY_DEBUG_SKIP_PATH` (`skip_path`): Skip showing/entering frames for given paths
@@ -503,6 +505,7 @@ config set no_color true
503
505
  * `RUBY_DEBUG_LOCAL_FS_MAP` (`local_fs_map`): Specify local fs map
504
506
  * `RUBY_DEBUG_SKIP_BP` (`skip_bp`): Skip breakpoints if no clients are attached (default: false)
505
507
  * `RUBY_DEBUG_COOKIE` (`cookie`): Cookie for negotiation
508
+ * `RUBY_DEBUG_SESSION_NAME` (`session_name`): Session name for differentiating multiple sessions
506
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))
507
510
 
508
511
  * OBSOLETE
@@ -512,7 +515,7 @@ There are other environment variables:
512
515
 
513
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/)).
514
517
  * `RUBY_DEBUG_ENABLE`: If the value is `0`, do not enable debug.gem feature.
515
- * `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.
516
519
  * `RUBY_DEBUG_EDITOR` or `EDITOR`: An editor used by `edit` debug command.
517
520
  * `RUBY_DEBUG_BB`: Define `Kernel#bb` method which is alias of `Kernel#debugger`.
518
521
 
@@ -524,7 +527,7 @@ If there is `~/.rdbgrc`, the file is loaded as an initial script (which contains
524
527
  * You can specify the initial script with `rdbg -x initial_script` (like gdb's `-x` option).
525
528
 
526
529
  Initial scripts are useful to write your favorite configurations.
527
- 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`.
528
531
 
529
532
  If there are `~/.rdbgrc.rb` is available, it is also loaded as a ruby script at same timing.
530
533
 
@@ -534,16 +537,16 @@ On the debug console, you can use the following debug commands.
534
537
 
535
538
  There are additional features:
536
539
 
537
- * `<expr>` without debug command is almost same as `pp <expr>`.
538
- * 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`.
539
- * 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.
540
- * 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.
541
544
  * `Enter` without any input repeats the last command (useful when repeating `step`s) for some commands.
542
545
  * `Ctrl-D` is equal to `quit` command.
543
546
  * [debug command compare sheet - Google Sheets](https://docs.google.com/spreadsheets/d/1TlmmUDsvwK4sSIyoMv-io52BUUz__R5wpu-ComXlsw0/edit?usp=sharing)
544
547
 
545
548
  You can use the following debug commands. Each command should be written in 1 line.
546
- 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.
547
550
  The `<...>` notation means the argument.
548
551
 
549
552
  ### Control flow
@@ -563,9 +566,9 @@ The `<...>` notation means the argument.
563
566
  * `u[ntil]`
564
567
  * Similar to `next` command, but only stop later lines or the end of the current frame.
565
568
  * Similar to gdb's `advance` command.
566
- * `u[ntil] <[file:]line>
569
+ * `u[ntil] <[file:]line>`
567
570
  * Run til the program reaches given location or the end of the current frame.
568
- * `u[ntil] <name>
571
+ * `u[ntil] <name>`
569
572
  * Run til the program invokes a method `<name>`. `<name>` can be a regexp with `/name/`.
570
573
  * `c` or `cont` or `continue`
571
574
  * Resume the program.
@@ -813,7 +816,7 @@ Emacs support available.
813
816
 
814
817
  #### Start by method
815
818
 
816
- 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.
817
820
 
818
821
  * `DEBUGGER__.start(**kw)`: start debug session with local console.
819
822
  * `DEBUGGER__.open(**kw)`: open debug port with configuration (without configurations open with UNIX domain socket)
@@ -832,9 +835,9 @@ DEBUGGER__.start(no_color: true, # disable colorize
832
835
 
833
836
  ### `binding.break` method
834
837
 
835
- `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.
836
839
 
837
- 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.
838
841
  It is useful if you only want to call a debug command and don't want to stop there.
839
842
 
840
843
  ```
@@ -844,9 +847,9 @@ def initialize
844
847
  end
845
848
  ```
846
849
 
847
- 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.
848
851
 
849
- 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.
850
853
  It is useful if you have operations before suspend.
851
854
 
852
855
  ```
@@ -856,7 +859,7 @@ def foo
856
859
  end
857
860
  ```
858
861
 
859
- 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.
860
863
 
861
864
  ## rdbg command help
862
865
 
@@ -882,6 +885,7 @@ Debug console mode:
882
885
  --port=PORT Listening TCP/IP port
883
886
  --host=HOST Listening TCP/IP host
884
887
  --cookie=COOKIE Set a cookie for connection
888
+ --session-name=NAME Session name
885
889
 
886
890
  Debug console mode runs Ruby program with the debug console.
887
891
 
@@ -908,6 +912,8 @@ Attach mode:
908
912
  'rdbg -A host port' tries to connect to host:port via TCP/IP.
909
913
 
910
914
  Other options:
915
+ -v Show version number
916
+ --version Show version number and exit
911
917
  -h, --help Print help
912
918
  --util=NAME Utility mode (used by tools)
913
919
  --stop-at-load Stop immediately when the debugging feature is loaded.
data/Rakefile CHANGED
@@ -35,9 +35,14 @@ task :check_readme do
35
35
  end
36
36
  end
37
37
 
38
+ desc "Run debug.gem test-framework tests"
39
+ Rake::TestTask.new(:test_test) do |t|
40
+ t.test_files = FileList["test/support/*_test.rb"]
41
+ end
42
+
38
43
  desc "Run all debugger console related tests"
39
44
  Rake::TestTask.new(:test_console) do |t|
40
- t.test_files = FileList["test/console/*_test.rb", "test/support/*_test.rb"]
45
+ t.test_files = FileList["test/console/*_test.rb"]
41
46
  end
42
47
 
43
48
  desc "Run all debugger protocols (CAP & DAP) related tests"
@@ -46,7 +51,7 @@ Rake::TestTask.new(:test_protocol) do |t|
46
51
  end
47
52
 
48
53
  task test: 'test_console' do
49
- warn '`rake test` doesn\'t run protocol tests. Use `rake test-all` to test all.'
54
+ warn '`rake test` doesn\'t run protocol tests. Use `rake test_all` to test all.'
50
55
  end
51
56
 
52
- task test_all: [:test_console, :test_protocol]
57
+ task test_all: [:test_test, :test_console, :test_protocol]
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
@@ -62,15 +62,23 @@ di_body(const rb_debug_inspector_t *dc, void *ptr)
62
62
  long i;
63
63
 
64
64
  for (i=1; i<len; i++) {
65
- VALUE loc, e;
65
+ VALUE e;
66
66
  VALUE iseq = rb_debug_inspector_frame_iseq_get(dc, i);
67
+ VALUE loc = RARRAY_AREF(locs, i);
68
+ VALUE path;
67
69
 
68
70
  if (!NIL_P(iseq)) {
69
- VALUE path = iseq_realpath(iseq);
70
- if (!NIL_P(path) && !NIL_P(skip_path_prefix) && str_start_with(path, skip_path_prefix)) continue;
71
+ path = iseq_realpath(iseq);
72
+ }
73
+ else {
74
+ // C frame
75
+ path = rb_funcall(loc, rb_intern("path"), 0);
76
+ }
77
+
78
+ if (!NIL_P(path) && !NIL_P(skip_path_prefix) && str_start_with(path, skip_path_prefix)) {
79
+ continue;
71
80
  }
72
81
 
73
- loc = RARRAY_AREF(locs, i);
74
82
  e = di_entry(loc,
75
83
  rb_debug_inspector_frame_self_get(dc, i),
76
84
  rb_debug_inspector_frame_binding_get(dc, i),
@@ -180,13 +188,17 @@ iseq_last_line(VALUE iseqw)
180
188
  }
181
189
  #endif
182
190
 
191
+ #ifdef HAVE_RB_ISEQ
183
192
  void Init_iseq_collector(void);
193
+ #endif
184
194
 
185
195
  void
186
196
  Init_debug(void)
187
197
  {
198
+ #ifdef HAVE_RB_ISEQ
188
199
  VALUE rb_mRubyVM = rb_const_get(rb_cObject, rb_intern("RubyVM"));
189
200
  VALUE rb_cISeq = rb_const_get(rb_mRubyVM, rb_intern("InstructionSequence"));
201
+ #endif
190
202
  rb_mDebugger = rb_const_get(rb_cObject, rb_intern("DEBUGGER__"));
191
203
  rb_cFrameInfo = rb_const_get(rb_mDebugger, rb_intern("FrameInfo"));
192
204
 
@@ -210,5 +222,7 @@ Init_debug(void)
210
222
  rb_define_method(rb_cISeq, "last_line", iseq_last_line, 0);
211
223
  #endif
212
224
 
225
+ #ifdef HAVE_RB_ISEQ
213
226
  Init_iseq_collector();
227
+ #endif
214
228
  }
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
@@ -101,10 +101,6 @@ module DEBUGGER__
101
101
  def generate_label(name)
102
102
  colorize(" BP - #{name} ", [:YELLOW, :BOLD, :REVERSE])
103
103
  end
104
-
105
- def pending_until_load?
106
- false
107
- end
108
104
  end
109
105
 
110
106
  if RUBY_VERSION.to_f <= 2.7
@@ -163,10 +159,6 @@ module DEBUGGER__
163
159
  @pending = !@iseq
164
160
  end
165
161
 
166
- def pending_until_load?
167
- @pending
168
- end
169
-
170
162
  def setup
171
163
  return unless @type
172
164
 
@@ -207,6 +199,8 @@ module DEBUGGER__
207
199
  if @pending && !@oneshot
208
200
  DEBUGGER__.info "#{self} is activated."
209
201
  end
202
+
203
+ @pending = false
210
204
  end
211
205
 
212
206
  def activate_exact iseq, events, line
@@ -299,6 +293,10 @@ module DEBUGGER__
299
293
  def inspect
300
294
  "<#{self.class.name} #{self.to_s}>"
301
295
  end
296
+
297
+ def path_is? path
298
+ DEBUGGER__.compare_path(@path, path)
299
+ end
302
300
  end
303
301
 
304
302
  class CatchBreakpoint < Breakpoint
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
@@ -21,6 +21,8 @@ module DEBUGGER__
21
21
  no_sigint_hook: ['RUBY_DEBUG_NO_SIGINT_HOOK', "UI: Do not suspend on SIGINT", :bool, "false"],
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
+ 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"],
24
26
 
25
27
  # control setting
26
28
  skip_path: ['RUBY_DEBUG_SKIP_PATH', "CONTROL: Skip showing/entering frames for given paths", :path],
@@ -48,6 +50,7 @@ module DEBUGGER__
48
50
  local_fs_map: ['RUBY_DEBUG_LOCAL_FS_MAP', "REMOTE: Specify local fs map", :path_map],
49
51
  skip_bp: ['RUBY_DEBUG_SKIP_BP', "REMOTE: Skip breakpoints if no clients are attached", :bool, 'false'],
50
52
  cookie: ['RUBY_DEBUG_COOKIE', "REMOTE: Cookie for negotiation"],
53
+ session_name: ['RUBY_DEBUG_SESSION_NAME', "REMOTE: Session name for differentiating multiple sessions"],
51
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))"],
52
55
 
53
56
  # obsolete
@@ -265,6 +268,8 @@ module DEBUGGER__
265
268
  require 'optparse'
266
269
  require_relative 'version'
267
270
 
271
+ have_shown_version = false
272
+
268
273
  opt = OptionParser.new do |o|
269
274
  o.banner = "#{$0} [options] -- [debuggee options]"
270
275
  o.separator ''
@@ -337,6 +342,9 @@ module DEBUGGER__
337
342
  o.on('--cookie=COOKIE', 'Set a cookie for connection') do |c|
338
343
  config[:cookie] = c
339
344
  end
345
+ o.on('--session-name=NAME', 'Session name') do |name|
346
+ config[:session_name] = name
347
+ end
340
348
 
341
349
  rdbg = 'rdbg'
342
350
 
@@ -372,6 +380,16 @@ module DEBUGGER__
372
380
  o.separator ''
373
381
  o.separator 'Other options:'
374
382
 
383
+ o.on('-v', 'Show version number') do
384
+ puts o.ver
385
+ have_shown_version = true
386
+ end
387
+
388
+ o.on('--version', 'Show version number and exit') do
389
+ puts o.ver
390
+ exit
391
+ end
392
+
375
393
  o.on("-h", "--help", "Print help") do
376
394
  puts o
377
395
  exit
@@ -395,6 +413,13 @@ module DEBUGGER__
395
413
 
396
414
  opt.parse!(argv)
397
415
 
416
+ if argv.empty?
417
+ case
418
+ when have_shown_version && config[:mode] == :start
419
+ exit
420
+ end
421
+ end
422
+
398
423
  config
399
424
  end
400
425
 
@@ -425,8 +450,9 @@ module DEBUGGER__
425
450
  unless (dir_uid = fs.uid) == (uid = Process.uid)
426
451
  raise "#{path} uid is #{dir_uid}, but Process.uid is #{uid}"
427
452
  end
428
- unless (dir_mode = fs.mode) == 040700 # 4: dir, 7:rwx
429
- raise "#{path}'s mode is #{dir_mode.to_s(8)} (should be 040700)"
453
+
454
+ if fs.world_writable? && !fs.sticky?
455
+ raise "#{path} is world writable but not sticky"
430
456
  end
431
457
 
432
458
  path
@@ -436,7 +462,7 @@ module DEBUGGER__
436
462
  require 'tmpdir'
437
463
 
438
464
  if tmpdir = Dir.tmpdir
439
- path = File.join(tmpdir, "ruby-debug-sock-#{Process.uid}")
465
+ path = File.join(tmpdir, "rdbg-#{Process.uid}")
440
466
 
441
467
  unless File.exist?(path)
442
468
  d = Dir.mktmpdir
@@ -449,7 +475,7 @@ module DEBUGGER__
449
475
 
450
476
  def self.unix_domain_socket_homedir
451
477
  if home = ENV['HOME']
452
- path = File.join(home, '.ruby-debug-sock')
478
+ path = File.join(home, '.rdbg-sock')
453
479
 
454
480
  unless File.exist?(path)
455
481
  Dir.mkdir(path, 0700)
@@ -473,12 +499,14 @@ module DEBUGGER__
473
499
  end
474
500
 
475
501
  def self.create_unix_domain_socket_name_prefix(base_dir = unix_domain_socket_dir)
476
- user = ENV['USER'] || 'UnknownUser'
477
- File.join(base_dir, "ruby-debug-#{user}")
502
+ File.join(base_dir, "rdbg")
478
503
  end
479
504
 
480
505
  def self.create_unix_domain_socket_name(base_dir = unix_domain_socket_dir)
481
- 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
482
510
  end
483
511
 
484
512
  ## Help