debug 1.7.2 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +47 -41
- data/debug.gemspec +3 -3
- data/ext/debug/debug.c +6 -0
- data/ext/debug/extconf.rb +1 -0
- data/ext/debug/iseq_collector.c +2 -0
- data/lib/debug/client.rb +3 -2
- data/lib/debug/config.rb +13 -6
- data/lib/debug/console.rb +8 -29
- data/lib/debug/dap_custom/traceInspector.rb +336 -0
- data/lib/debug/frame_info.rb +9 -0
- data/lib/debug/irb_integration.rb +27 -0
- data/lib/debug/server.rb +5 -3
- data/lib/debug/server_cdp.rb +11 -13
- data/lib/debug/server_dap.rb +191 -160
- data/lib/debug/session.rb +63 -29
- data/lib/debug/source_repository.rb +1 -1
- data/lib/debug/thread_client.rb +42 -24
- data/lib/debug/version.rb +1 -1
- data/misc/README.md.erb +41 -41
- metadata +12 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d25f806f1fa474cea627e17003007f9e28a776244f25c24addae854005fd8d1
|
4
|
+
data.tar.gz: 63a48b8aeee29d020a4d8fb6ec85ad337c42c0b83f32ca53ea83d767a6daadc5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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
|
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
|
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
|
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
|
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
|
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
|
269
|
-
6. Chosen command line is invoked with `rdbg -c
|
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
|
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
|
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
|
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
|
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
|
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
|
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/...'
|
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
|
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
|
540
|
-
* So the author (Koichi Sasada) recommends
|
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
|
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
|
@@ -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
|
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
|
-
|
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
|
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
|
-
|
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/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.
|
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", "
|
31
|
-
spec.add_dependency "reline", ">= 0.3.
|
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
data/ext/debug/iseq_collector.c
CHANGED
@@ -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
|
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
|
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
|
@@ -339,6 +342,9 @@ module DEBUGGER__
|
|
339
342
|
o.on('--cookie=COOKIE', 'Set a cookie for connection') do |c|
|
340
343
|
config[:cookie] = c
|
341
344
|
end
|
345
|
+
o.on('--session-name=NAME', 'Session name') do |name|
|
346
|
+
config[:session_name] = name
|
347
|
+
end
|
342
348
|
|
343
349
|
rdbg = 'rdbg'
|
344
350
|
|
@@ -410,7 +416,6 @@ module DEBUGGER__
|
|
410
416
|
if argv.empty?
|
411
417
|
case
|
412
418
|
when have_shown_version && config[:mode] == :start
|
413
|
-
pp config
|
414
419
|
exit
|
415
420
|
end
|
416
421
|
end
|
@@ -457,7 +462,7 @@ module DEBUGGER__
|
|
457
462
|
require 'tmpdir'
|
458
463
|
|
459
464
|
if tmpdir = Dir.tmpdir
|
460
|
-
path = File.join(tmpdir, "
|
465
|
+
path = File.join(tmpdir, "rdbg-#{Process.uid}")
|
461
466
|
|
462
467
|
unless File.exist?(path)
|
463
468
|
d = Dir.mktmpdir
|
@@ -470,7 +475,7 @@ module DEBUGGER__
|
|
470
475
|
|
471
476
|
def self.unix_domain_socket_homedir
|
472
477
|
if home = ENV['HOME']
|
473
|
-
path = File.join(home, '.
|
478
|
+
path = File.join(home, '.rdbg-sock')
|
474
479
|
|
475
480
|
unless File.exist?(path)
|
476
481
|
Dir.mkdir(path, 0700)
|
@@ -494,12 +499,14 @@ module DEBUGGER__
|
|
494
499
|
end
|
495
500
|
|
496
501
|
def self.create_unix_domain_socket_name_prefix(base_dir = unix_domain_socket_dir)
|
497
|
-
|
498
|
-
File.join(base_dir, "ruby-debug-#{user}")
|
502
|
+
File.join(base_dir, "rdbg")
|
499
503
|
end
|
500
504
|
|
501
505
|
def self.create_unix_domain_socket_name(base_dir = unix_domain_socket_dir)
|
502
|
-
|
506
|
+
suffix = "-#{Process.pid}"
|
507
|
+
name = CONFIG[:session_name]
|
508
|
+
suffix << "-#{name}" if name
|
509
|
+
create_unix_domain_socket_name_prefix(base_dir) + suffix
|
503
510
|
end
|
504
511
|
|
505
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
|
-
|
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
|
38
|
+
[prompt]
|
60
39
|
when :ruby
|
61
|
-
[prompt.sub('rdbg'){colorize('ruby', [:RED])}]
|
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
|
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.
|
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
|
-
|