You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+30-30Lines changed: 30 additions & 30 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@
4
4
5
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).
@@ -238,11 +238,11 @@ 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
248
* With `-c` option, `rdbg -c <name>` means that `<name>` is command in `PATH` and simply invoke it with the debugger.
@@ -265,8 +265,8 @@ Like other languages, you can use this debugger on the VSCode.
265
265
2. Open `.rb` file (e.g. `target.rb`)
266
266
3. Register breakpoints with "Toggle breakpoint" in 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
271
Please refer [Debugging in Visual Studio Code](https://code.visualstudio.com/docs/editor/debugging) for operations on VSCode.
272
272
@@ -275,15 +275,15 @@ 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 debugged, and the remote debugger console can attach to the debuggee anytime.
287
287
288
288
### Invoke as a remote debuggee
289
289
@@ -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 is 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 `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
@@ -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 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 addressbar 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
@@ -515,7 +515,7 @@ There are other environment variables:
515
515
516
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/)).
517
517
*`RUBY_DEBUG_ENABLE`: If the value is `0`, do not enable debug.gem feature.
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.
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.
519
519
*`RUBY_DEBUG_EDITOR` or `EDITOR`: An editor used by `edit` debug command.
520
520
*`RUBY_DEBUG_BB`: Define `Kernel#bb` method which is alias of `Kernel#debugger`.
521
521
@@ -527,7 +527,7 @@ If there is `~/.rdbgrc`, the file is loaded as an initial script (which contains
527
527
* You can specify the initial script with `rdbg -x initial_script` (like gdb's `-x` option).
528
528
529
529
Initial scripts are useful to write your favorite configurations.
530
-
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`.
531
531
532
532
If there are `~/.rdbgrc.rb` is available, it is also loaded as a ruby script at same timing.
533
533
@@ -537,16 +537,16 @@ On the debug console, you can use the following debug commands.
537
537
538
538
There are additional features:
539
539
540
-
*`<expr>` without debug command is almost 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 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 singleletter local variables `i`, `b`, `n`, `c` because they are singleletter debug commands. Use `p i` instead.
543
-
* 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.
544
544
*`Enter` without any input repeats the last command (useful when repeating `step`s) for some commands.
545
545
*`Ctrl-D` is equal to `quit` command.
546
546
*[debug command compare sheet - Google Sheets](https://docs.google.com/spreadsheets/d/1TlmmUDsvwK4sSIyoMv-io52BUUz__R5wpu-ComXlsw0/edit?usp=sharing)
547
547
548
548
You can use the following debug commands. Each command should be written in 1 line.
549
-
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.
`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.
839
839
840
-
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.
841
841
It is useful if you only want to call a debug command and don't want to stop there.
842
842
843
843
```
@@ -847,9 +847,9 @@ def initialize
847
847
end
848
848
```
849
849
850
-
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.
851
851
852
-
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.
853
853
It is useful if you have operations before suspend.
854
854
855
855
```
@@ -859,7 +859,7 @@ def foo
859
859
end
860
860
```
861
861
862
-
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.
0 commit comments