debug 1.0.0.beta8 → 1.0.0.rc1
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/CONTRIBUTING.md +108 -106
- data/README.md +90 -30
- data/debug.gemspec +1 -0
- data/exe/rdbg +3 -6
- data/ext/debug/debug.c +11 -1
- data/lib/debug/breakpoint.rb +55 -22
- data/lib/debug/client.rb +7 -12
- data/lib/debug/color.rb +19 -4
- data/lib/debug/config.rb +354 -177
- data/lib/debug/console.rb +76 -68
- data/lib/debug/frame_info.rb +40 -7
- data/lib/debug/local.rb +91 -0
- data/lib/debug/server.rb +74 -26
- data/lib/debug/server_dap.rb +32 -7
- data/lib/debug/session.rb +568 -274
- data/lib/debug/thread_client.rb +620 -162
- data/lib/debug/tracer.rb +242 -0
- data/lib/debug/version.rb +1 -1
- data/misc/README.md.erb +26 -25
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4753f123beef802e8cea541c779672938b200d5077011cd53a6a99c282d225cb
|
4
|
+
data.tar.gz: '078b495c6c5170cf6704c3100e1769477efadcbca47b5bae54c18c76424b8466'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e3e35a50f48444a978499798ef4d0ff997060f8562118baadec7af7c55ce4932f0a7ebd937dca974338c4086e44fbe34ce85b12386d3b67f65c774ab642a0b1
|
7
|
+
data.tar.gz: 3ba0fa3adf1122d4c86ac491c99a782d3f31d519255f4110e9721f3749bd87ac0aed2f9d1528a14b4ca814a3eb60ed0ef2f30cb51b24f6ec219e8b9ead6c5b73
|
data/CONTRIBUTING.md
CHANGED
@@ -49,75 +49,75 @@ $ bin/gentest target.rb
|
|
49
49
|
#### 3. Debugger will be executed. You can type any debug commands.
|
50
50
|
```shell
|
51
51
|
$ bin/gentest target.rb
|
52
|
+
DEBUGGER: Session start (pid: 11139)
|
52
53
|
[1, 9] in ~/workspace/debug/target.rb
|
53
|
-
=>
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
54
|
+
=> 1| module Foo
|
55
|
+
2| class Bar
|
56
|
+
3| def self.a
|
57
|
+
4| "hello"
|
58
|
+
5| end
|
59
|
+
6| end
|
60
|
+
7| Bar.a
|
61
|
+
8| bar = Bar.new
|
62
|
+
9| end
|
62
63
|
=>#0 <main> at ~/workspace/debug/target.rb:1
|
63
64
|
INTERNAL_INFO: {"location":"~/workspace/debug/target.rb:1","line":1}
|
64
|
-
|
65
65
|
(rdbg)s
|
66
66
|
s
|
67
67
|
[1, 9] in ~/workspace/debug/target.rb
|
68
|
-
|
69
|
-
=>
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
68
|
+
1| module Foo
|
69
|
+
=> 2| class Bar
|
70
|
+
3| def self.a
|
71
|
+
4| "hello"
|
72
|
+
5| end
|
73
|
+
6| end
|
74
|
+
7| Bar.a
|
75
|
+
8| bar = Bar.new
|
76
|
+
9| end
|
77
77
|
=>#0 <module:Foo> at ~/workspace/debug/target.rb:2
|
78
78
|
#1 <main> at ~/workspace/debug/target.rb:1
|
79
79
|
INTERNAL_INFO: {"location":"~/workspace/debug/target.rb:2","line":2}
|
80
|
-
|
81
80
|
(rdbg)n
|
82
81
|
n
|
83
82
|
[1, 9] in ~/workspace/debug/target.rb
|
84
|
-
|
85
|
-
|
86
|
-
=>
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
83
|
+
1| module Foo
|
84
|
+
2| class Bar
|
85
|
+
=> 3| def self.a
|
86
|
+
4| "hello"
|
87
|
+
5| end
|
88
|
+
6| end
|
89
|
+
7| Bar.a
|
90
|
+
8| bar = Bar.new
|
91
|
+
9| end
|
93
92
|
=>#0 <class:Bar> at ~/workspace/debug/target.rb:3
|
94
93
|
#1 <module:Foo> at ~/workspace/debug/target.rb:2
|
95
|
-
#
|
94
|
+
# and 1 frames (use `bt' command for all frames)
|
96
95
|
INTERNAL_INFO: {"location":"~/workspace/debug/target.rb:3","line":3}
|
97
|
-
|
98
96
|
(rdbg)b 7
|
99
97
|
b 7
|
98
|
+
#0 BP - Line /Users/naotto/workspace/debug/target.rb:7 (line)
|
100
99
|
INTERNAL_INFO: {"location":"~/workspace/debug/target.rb:3","line":3}
|
101
|
-
|
102
100
|
(rdbg)c
|
103
101
|
c
|
104
102
|
[2, 9] in ~/workspace/debug/target.rb
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
=>
|
111
|
-
|
112
|
-
|
103
|
+
2| class Bar
|
104
|
+
3| def self.a
|
105
|
+
4| "hello"
|
106
|
+
5| end
|
107
|
+
6| end
|
108
|
+
=> 7| Bar.a
|
109
|
+
8| bar = Bar.new
|
110
|
+
9| end
|
113
111
|
=>#0 <module:Foo> at ~/workspace/debug/target.rb:7
|
114
112
|
#1 <main> at ~/workspace/debug/target.rb:1
|
115
113
|
|
116
114
|
Stop by #0 BP - Line /Users/naotto/workspace/debug/target.rb:7 (line)
|
117
115
|
INTERNAL_INFO: {"location":"~/workspace/debug/target.rb:7","line":7}
|
118
|
-
|
119
116
|
(rdbg)q!
|
120
117
|
q!
|
118
|
+
created: /Users/naotto/workspace/debug/test/tool/../debug/foo_test.rb
|
119
|
+
class: FooTest
|
120
|
+
method: test_1629720194
|
121
121
|
```
|
122
122
|
#### 4. The test file will be created as `test/debug/foo_test.rb`.
|
123
123
|
If the file already exists, **only method** will be added to it.
|
@@ -131,70 +131,70 @@ module DEBUGGER__
|
|
131
131
|
def program
|
132
132
|
<<~RUBY
|
133
133
|
1| module Foo
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
134
|
+
2| class Bar
|
135
|
+
3| def self.a
|
136
|
+
4| "hello"
|
137
|
+
5| end
|
138
|
+
6| end
|
139
|
+
7| Bar.a
|
140
|
+
8| bar = Bar.new
|
141
|
+
9| end
|
142
142
|
RUBY
|
143
143
|
end
|
144
144
|
|
145
|
-
def
|
145
|
+
def test_1629720194
|
146
146
|
debug_code(program) do
|
147
147
|
type 's'
|
148
148
|
assert_line_num 2
|
149
149
|
assert_line_text([
|
150
|
-
|
151
|
-
/
|
152
|
-
/=>
|
153
|
-
/
|
154
|
-
/
|
155
|
-
/
|
156
|
-
/
|
157
|
-
/
|
158
|
-
/
|
159
|
-
/
|
160
|
-
|
161
|
-
/
|
150
|
+
/\[1, 9\] in .*/,
|
151
|
+
/ 1\| module Foo/,
|
152
|
+
/=> 2\| class Bar/,
|
153
|
+
/ 3\| def self\.a/,
|
154
|
+
/ 4\| "hello"/,
|
155
|
+
/ 5\| end/,
|
156
|
+
/ 6\| end/,
|
157
|
+
/ 7\| Bar\.a/,
|
158
|
+
/ 8\| bar = Bar\.new/,
|
159
|
+
/ 9\| end/,
|
160
|
+
/=>\#0\t<module:Foo> at .*/,
|
161
|
+
/ \#1\t<main> at .*/
|
162
162
|
])
|
163
163
|
type 'n'
|
164
164
|
assert_line_num 3
|
165
165
|
assert_line_text([
|
166
|
-
|
167
|
-
/
|
168
|
-
/
|
169
|
-
/=>
|
170
|
-
/
|
171
|
-
/
|
172
|
-
/
|
173
|
-
/
|
174
|
-
/
|
175
|
-
/
|
176
|
-
|
177
|
-
/
|
178
|
-
/
|
166
|
+
/\[1, 9\] in .*/,
|
167
|
+
/ 1\| module Foo/,
|
168
|
+
/ 2\| class Bar/,
|
169
|
+
/=> 3\| def self\.a/,
|
170
|
+
/ 4\| "hello"/,
|
171
|
+
/ 5\| end/,
|
172
|
+
/ 6\| end/,
|
173
|
+
/ 7\| Bar\.a/,
|
174
|
+
/ 8\| bar = Bar\.new/,
|
175
|
+
/ 9\| end/,
|
176
|
+
/=>\#0\t<class:Bar> at .*/,
|
177
|
+
/ \#1\t<module:Foo> at .*/,
|
178
|
+
/ \# and 1 frames \(use `bt' command for all frames\)/
|
179
179
|
])
|
180
180
|
type 'b 7'
|
181
|
-
assert_line_text(
|
181
|
+
assert_line_text(/\#0 BP \- Line .*/)
|
182
182
|
type 'c'
|
183
183
|
assert_line_num 7
|
184
184
|
assert_line_text([
|
185
|
-
|
186
|
-
/
|
187
|
-
/
|
188
|
-
/
|
189
|
-
/
|
190
|
-
/
|
191
|
-
/=>
|
192
|
-
/
|
193
|
-
/
|
194
|
-
|
195
|
-
/
|
185
|
+
/\[2, 9\] in .*/,
|
186
|
+
/ 2\| class Bar/,
|
187
|
+
/ 3\| def self\.a/,
|
188
|
+
/ 4\| "hello"/,
|
189
|
+
/ 5\| end/,
|
190
|
+
/ 6\| end/,
|
191
|
+
/=> 7\| Bar\.a/,
|
192
|
+
/ 8\| bar = Bar\.new/,
|
193
|
+
/ 9\| end/,
|
194
|
+
/=>\#0\t<module:Foo> at .*/,
|
195
|
+
/ \#1\t<main> at .*/,
|
196
196
|
//,
|
197
|
-
/Stop by
|
197
|
+
/Stop by \#0 BP \- Line .*/
|
198
198
|
])
|
199
199
|
type 'q!'
|
200
200
|
end
|
@@ -287,6 +287,7 @@ $ exe/rdbg -e 'b 20;; c ;; bt ;; info ;; q!' -e c target.rb
|
|
287
287
|
|
288
288
|
```
|
289
289
|
❯ exe/rdbg -e 'b 20;; c ;; bt ;; info ;; q!' -e c target.rb
|
290
|
+
DEBUGGER: Session start (pid: 9815)
|
290
291
|
[1, 10] in target.rb
|
291
292
|
=> 1| class Foo
|
292
293
|
2| def first_call
|
@@ -299,10 +300,10 @@ $ exe/rdbg -e 'b 20;; c ;; bt ;; info ;; q!' -e c target.rb
|
|
299
300
|
9| end
|
300
301
|
10| end
|
301
302
|
=>#0 <main> at target.rb:1
|
302
|
-
(rdbg:
|
303
|
-
#
|
304
|
-
(rdbg:
|
305
|
-
[15,
|
303
|
+
(rdbg:commands) b 20
|
304
|
+
#0 BP - Line /PATH_TO_PROJECT/target.rb:20 (return)
|
305
|
+
(rdbg:commands) c
|
306
|
+
[15, 24] in target.rb
|
306
307
|
15| yield(10)
|
307
308
|
16| end
|
308
309
|
17|
|
@@ -312,25 +313,26 @@ $ exe/rdbg -e 'b 20;; c ;; bt ;; info ;; q!' -e c target.rb
|
|
312
313
|
21| end
|
313
314
|
22|
|
314
315
|
23| Foo.new.first_call
|
316
|
+
24|
|
315
317
|
=>#0 Foo#forth_call(num1=20, num2=10) at target.rb:20 #=> 30
|
316
|
-
#1 block{|ten=10|} in second_call at target.rb:8
|
318
|
+
#1 block {|ten=10|} in second_call at target.rb:8
|
317
319
|
# and 4 frames (use `bt' command for all frames)
|
318
320
|
|
319
|
-
Stop by #
|
320
|
-
(rdbg:
|
321
|
+
Stop by #0 BP - Line /PATH_TO_PROJECT/target.rb:20 (return)
|
322
|
+
(rdbg:commands) bt
|
321
323
|
=>#0 Foo#forth_call(num1=20, num2=10) at target.rb:20 #=> 30
|
322
|
-
#1 block{|ten=10|} in second_call at target.rb:8
|
323
|
-
#2 Foo#third_call_with_block(block=#<Proc:
|
324
|
+
#1 block {|ten=10|} in second_call at target.rb:8
|
325
|
+
#2 Foo#third_call_with_block(block=#<Proc:0x00007f9283101568 target.rb:7>) at target.rb:15
|
324
326
|
#3 Foo#second_call(num=20) at target.rb:7
|
325
|
-
#4 first_call at target.rb:3
|
327
|
+
#4 Foo#first_call at target.rb:3
|
326
328
|
#5 <main> at target.rb:23
|
327
|
-
(rdbg:
|
329
|
+
(rdbg:commands) info
|
328
330
|
=>#0 Foo#forth_call(num1=20, num2=10) at target.rb:20 #=> 30
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
(rdbg:
|
331
|
+
%self => #<Foo:0x00007f92831016d0 @ivar1=10, @ivar2=20>
|
332
|
+
%return => 30
|
333
|
+
num1 => 20
|
334
|
+
num2 => 10
|
335
|
+
@ivar1 => 10
|
336
|
+
@ivar2 => 20
|
337
|
+
(rdbg:commands) q!
|
336
338
|
```
|
data/README.md
CHANGED
@@ -20,6 +20,7 @@ New debug.rb has several advantages:
|
|
20
20
|
* Support threads (almost done) and ractors (TODO).
|
21
21
|
* Support suspending and entering to the console debugging with `Ctrl-C` at most of timing.
|
22
22
|
* Show parameters on backtrace command.
|
23
|
+
* Support recording & reply debugging.
|
23
24
|
|
24
25
|
# Installation
|
25
26
|
|
@@ -32,7 +33,7 @@ or specify `-Ipath/to/debug/lib` in `RUBYOPT` or each ruby command-line option,
|
|
32
33
|
If you use Bundler, write the following line to your Gemfile.
|
33
34
|
|
34
35
|
```
|
35
|
-
gem "debug", ">= 1.0.0.
|
36
|
+
gem "debug", ">= 1.0.0.rc"
|
36
37
|
```
|
37
38
|
|
38
39
|
# HOW TO USE
|
@@ -43,9 +44,9 @@ To use a debugger, roughly you will do the following steps:
|
|
43
44
|
2. Run a program with the debugger.
|
44
45
|
3. At the breakpoint, enter the debugger console.
|
45
46
|
4. Use debug commands.
|
46
|
-
* Query the
|
47
|
+
* Query the program status (e.g. `p lvar` to see the local variable `lvar`).
|
47
48
|
* Control program flow (e.g. move to the another line with `step`, to the next line with `next`).
|
48
|
-
* Set another
|
49
|
+
* Set another breakpoint (e.g. `catch Exception` to set a breakpoint when `Exception` is raised).
|
49
50
|
* Change the configuration (e.g. `config set no_color true` to disable coloring).
|
50
51
|
* Continue the program (`c` or `continue`) and goto 3.
|
51
52
|
|
@@ -56,12 +57,12 @@ There are several options for (1) and (2). Please choose your favorite way.
|
|
56
57
|
### Modify source code as `binding.pry` and `binding.irb`
|
57
58
|
|
58
59
|
If you can modify the source code, you can use the debugger by adding `require 'debug'` line at the top of your program and putting `binding.break` method (`binding.b` for short) into lines where you want to stop as breakpoints like `binding.pry` and `binding.irb`.
|
59
|
-
After that, you run the program as
|
60
|
+
After that, you run the program as usual and you will enter the debug console at breakpoints you inserted.
|
60
61
|
|
61
62
|
The following example shows the demonstration of `binding.break`.
|
62
63
|
|
63
64
|
```shell
|
64
|
-
$ cat target.rb # Sample
|
65
|
+
$ cat target.rb # Sample program
|
65
66
|
require 'debug'
|
66
67
|
|
67
68
|
a = 1
|
@@ -120,13 +121,13 @@ d => 4
|
|
120
121
|
[1, 2, 3, 4]
|
121
122
|
```
|
122
123
|
|
123
|
-
### Invoke the
|
124
|
+
### Invoke the program from the debugger as a traditional debuggers
|
124
125
|
|
125
126
|
If you don't want to modify the source code, you can set breakpoints with a debug command `break` (`b` for short).
|
126
127
|
Using `rdbg` command to launch the program without any modifications, you can run the program with the debugger.
|
127
128
|
|
128
129
|
```shell
|
129
|
-
$ cat target.rb # Sample
|
130
|
+
$ cat target.rb # Sample program
|
130
131
|
a = 1
|
131
132
|
b = 2
|
132
133
|
c = 3
|
@@ -241,16 +242,16 @@ NOTE: If you want to use bundler (`bundle` command), you need to write `gem debu
|
|
241
242
|
|
242
243
|
### Using VSCode
|
243
244
|
|
244
|
-
Like other
|
245
|
+
Like other languages, you can use this debugger on the VSCode.
|
245
246
|
|
246
|
-
1. Install [VSCode rdbg Ruby Debugger - Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=KoichiSasada.vscode-rdbg)
|
247
|
+
1. Install [VSCode rdbg Ruby Debugger - Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=KoichiSasada.vscode-rdbg)
|
247
248
|
2. Open `.rb` file (e.g. `target.rb`)
|
248
249
|
3. Register breakpoints with "Toggle breakpoint" in Run menu (or type F9 key)
|
249
250
|
4. Choose "Start debugging" in "Run" menu (or type F5 key)
|
250
251
|
5. You will see a dialog "Debug command line" and you can choose your favorite command line your want to run.
|
251
|
-
6.
|
252
|
+
6. Chosen command line is invoked with `rdbg -c` and VSCode shows the details at breakpoints.
|
252
253
|
|
253
|
-
|
254
|
+
Please refer [Debugging in Visual Studio Code](https://code.visualstudio.com/docs/editor/debugging) for operations on VSCode.
|
254
255
|
|
255
256
|
You can configure the extension in `.vscode/launch.json`.
|
256
257
|
Please see the extension page for more details.
|
@@ -265,7 +266,7 @@ You can use this debugger as a remote debugger. For example, it will help the fo
|
|
265
266
|
* Your application uses pipe for STDIN or STDOUT.
|
266
267
|
* Your application is running as a daemon and you want to query the running status (checking a backtrace and so on).
|
267
268
|
|
268
|
-
You can run your application as a remote debuggee and the remote debugger console can attach to the
|
269
|
+
You can run your application as a remote debuggee and the remote debugger console can attach to the debuggee anytime.
|
269
270
|
|
270
271
|
### Invoke as a remote debuggee
|
271
272
|
|
@@ -279,10 +280,10 @@ You can run a script with `rdbg --open target.rb` command and run a `target.rb`
|
|
279
280
|
$ exe/rdbg --open target.rb
|
280
281
|
DEBUGGER: Session start (pid: 7773)
|
281
282
|
DEBUGGER: Debugger can attach via UNIX domain socket (/home/ko1/.ruby-debug-sock/ruby-debug-ko1-7773)
|
282
|
-
DEBUGGER: wait for
|
283
|
+
DEBUGGER: wait for debugger connection...
|
283
284
|
```
|
284
285
|
|
285
|
-
By
|
286
|
+
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).
|
286
287
|
|
287
288
|
You can connect to the debuggee with `rdbg --attach` command (`rdbg -A` for short).
|
288
289
|
|
@@ -309,7 +310,7 @@ NOTE: If you use `quit` command, only remote console exits and the debuggee prog
|
|
309
310
|
|
310
311
|
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`.
|
311
312
|
|
312
|
-
To connect to the
|
313
|
+
To connect to the debuggee, you need to specify the port.
|
313
314
|
|
314
315
|
```shell
|
315
316
|
$ rdbg --attach 12345
|
@@ -324,7 +325,7 @@ If you can modify the program, you can open debugging port by adding `require 'd
|
|
324
325
|
|
325
326
|
If you don't want to stop the program at the beginning, you can also use `require 'debug/open_nonstop'`.
|
326
327
|
Using `debug/open_nonstop` is useful if you want to open a backdoor to the application.
|
327
|
-
However, it is also danger because it can become
|
328
|
+
However, it is also danger because it can become another vulnerability.
|
328
329
|
Please use it carefully.
|
329
330
|
|
330
331
|
By default, UNIX domain socket is used for the debugging port. To use TCP/IP, you can set the `RUBY_DEBUG_PORT` environment variable.
|
@@ -336,14 +337,14 @@ $ RUBY_DEBUG_PORT=12345 ruby target.rb
|
|
336
337
|
## Configuration
|
337
338
|
|
338
339
|
You can configure the debugger's behavior with debug commands and environment variables.
|
339
|
-
When the debug session is started, initial scripts are loaded so you can put your favorite configurations in the
|
340
|
+
When the debug session is started, initial scripts are loaded so you can put your favorite configurations in the initial scripts.
|
340
341
|
|
341
342
|
### Configuration list
|
342
343
|
|
343
344
|
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.
|
344
345
|
|
345
346
|
```
|
346
|
-
#
|
347
|
+
# configuration example
|
347
348
|
config set log_level INFO
|
348
349
|
config set no_color true
|
349
350
|
```
|
@@ -354,12 +355,18 @@ config set no_color true
|
|
354
355
|
* `RUBY_DEBUG_LOG_LEVEL` (`log_level`): Log level same as Logger (default: WARN)
|
355
356
|
* `RUBY_DEBUG_SHOW_SRC_LINES` (`show_src_lines`): Show n lines source code on breakpoint (default: 10 lines)
|
356
357
|
* `RUBY_DEBUG_SHOW_FRAMES` (`show_frames`): Show n frames on breakpoint (default: 2 frames)
|
357
|
-
* `RUBY_DEBUG_SHOW_INFO_LINES` (`show_info_lines`): Show n lines on info command (default: 10 lines, 0 for unlimited)
|
358
358
|
* `RUBY_DEBUG_USE_SHORT_PATH` (`use_short_path`): Show shoten PATH (like $(Gem)/foo.rb)
|
359
|
-
* `RUBY_DEBUG_SKIP_NOSRC` (`skip_nosrc`): Skip on no source code lines (default: false)
|
360
|
-
* `RUBY_DEBUG_SKIP_PATH` (`skip_path`): Skip showing frames for given paths (default: [])
|
361
359
|
* `RUBY_DEBUG_NO_COLOR` (`no_color`): Do not use colorize (default: false)
|
362
360
|
* `RUBY_DEBUG_NO_SIGINT_HOOK` (`no_sigint_hook`): Do not suspend on SIGINT (default: false)
|
361
|
+
* `RUBY_DEBUG_NO_RELINE` (`no_reline`): Do not use Reline library (default: false)
|
362
|
+
|
363
|
+
* CONTROL
|
364
|
+
* `RUBY_DEBUG_SKIP_PATH` (`skip_path`): Skip showing/entering frames for given paths (default: [])
|
365
|
+
* `RUBY_DEBUG_SKIP_NOSRC` (`skip_nosrc`): Skip on no source code lines (default: false)
|
366
|
+
* `RUBY_DEBUG_KEEP_ALLOC_SITE` (`keep_alloc_site`): Keep allocation site and p, pp shows it (default: false)
|
367
|
+
* `RUBY_DEBUG_POSTMORTEM` (`postmortem`): Enable postmortem debug (default: false)
|
368
|
+
* `RUBY_DEBUG_PARENT_ON_FORK` (`parent_on_fork`): Keep debugging parent process on fork (default: false)
|
369
|
+
* `RUBY_DEBUG_SIGDUMP_SIG` (`sigdump_sig`): Sigdump signal (default: disabled)
|
363
370
|
|
364
371
|
* BOOT
|
365
372
|
* `RUBY_DEBUG_NONSTOP` (`nonstop`): Nonstop mode
|
@@ -376,7 +383,7 @@ config set no_color true
|
|
376
383
|
|
377
384
|
### Initial scripts
|
378
385
|
|
379
|
-
If there is `~/.rdbgrc`, the file is loaded as an initial
|
386
|
+
If there is `~/.rdbgrc`, the file is loaded as an initial script (which contains debug commands) when the debug session is started.
|
380
387
|
|
381
388
|
* `RUBY_DEBUG_INIT_SCRIPT` environment variable can specify the initial script file.
|
382
389
|
* You can specify the initial script with `rdbg -x initial_script` (like gdb's `-x` option).
|
@@ -402,10 +409,16 @@ The `<...>` notation means the argument.
|
|
402
409
|
|
403
410
|
* `s[tep]`
|
404
411
|
* Step in. Resume the program until next breakable point.
|
412
|
+
* `s[tep] <n>`
|
413
|
+
* Step in, resume the program at `<n>`th breakable point.
|
405
414
|
* `n[ext]`
|
406
415
|
* Step over. Resume the program until next line.
|
416
|
+
* `n[ext] <n>`
|
417
|
+
* Step over, same as `step <n>`.
|
407
418
|
* `fin[ish]`
|
408
419
|
* Finish this frame. Resume the program until the current frame is finished.
|
420
|
+
* `fin[ish] <n>`
|
421
|
+
* Finish frames, same as `step <n>`.
|
409
422
|
* `c[ontinue]`
|
410
423
|
* Resume the program.
|
411
424
|
* `q[uit]` or `Ctrl-D`
|
@@ -470,11 +483,26 @@ The `<...>` notation means the argument.
|
|
470
483
|
* Note that edited file will not be reloaded.
|
471
484
|
* `edit <file>`
|
472
485
|
* Open <file> on the editor.
|
473
|
-
* `i[nfo]
|
486
|
+
* `i[nfo]`
|
487
|
+
* Show information about current frame (local/instance variables and defined constants).
|
488
|
+
* `i[nfo] l[ocal[s]]`
|
474
489
|
* Show information about the current frame (local variables)
|
475
490
|
* It includes `self` as `%self` and a return value as `%return`.
|
491
|
+
* `i[nfo] i[var[s]]` or `i[nfo] instance`
|
492
|
+
* Show information about insttance variables about `self`.
|
493
|
+
* `i[nfo] c[onst[s]]` or `i[nfo] constant[s]`
|
494
|
+
* Show information about accessible constants except toplevel constants.
|
495
|
+
* `i[nfo] g[lobal[s]]`
|
496
|
+
* Show information about global variables
|
497
|
+
* `i[nfo] ... </pattern/>`
|
498
|
+
* Filter the output with `</pattern/>`.
|
476
499
|
* `i[nfo] th[read[s]]`
|
477
500
|
* Show all threads (same as `th[read]`).
|
501
|
+
* `o[utline]` or `ls`
|
502
|
+
* Show you available methods, constants, local variables, and instance variables in the current scope.
|
503
|
+
* `o[utline] <expr>` or `ls <expr>`
|
504
|
+
* Show you available methods and instance variables of the given object.
|
505
|
+
* If the object is a class/module, it also lists its constants.
|
478
506
|
* `display`
|
479
507
|
* Show display setting.
|
480
508
|
* `display <expr>`
|
@@ -506,6 +534,36 @@ The `<...>` notation means the argument.
|
|
506
534
|
* `irb`
|
507
535
|
* Invoke `irb` on the current frame.
|
508
536
|
|
537
|
+
### Trace
|
538
|
+
|
539
|
+
* `trace`
|
540
|
+
* Show available tracers list.
|
541
|
+
* `trace line`
|
542
|
+
* Add a line tracer. It indicates line events.
|
543
|
+
* `trace call`
|
544
|
+
* Add a call tracer. It indicate call/return events.
|
545
|
+
* `trace exception`
|
546
|
+
* Add an exception tracer. It indicates raising exceptions.
|
547
|
+
* `trace object <expr>`
|
548
|
+
* Add an object tracer. It indicates that an object by `<expr>` is passed as a parameter or a receiver on method call.
|
549
|
+
* `trace ... </pattern/>`
|
550
|
+
* Indicates only matched events to `</pattern/>` (RegExp).
|
551
|
+
* `trace ... into: <file>`
|
552
|
+
* Save trace information into: `<file>`.
|
553
|
+
* `trace off <num>`
|
554
|
+
* Disable tracer specified by `<num>` (use `trace` command to check the numbers).
|
555
|
+
* `trace off [line|call|pass]`
|
556
|
+
* Disable all tracers. If `<type>` is provided, disable specified type tracers.
|
557
|
+
* `record`
|
558
|
+
* Show recording status.
|
559
|
+
* `record [on|off]`
|
560
|
+
* Start/Stop recording.
|
561
|
+
* `step back`
|
562
|
+
* Start replay. Step back with the last execution log.
|
563
|
+
* `s[tep]` does stepping forward with the last log.
|
564
|
+
* `step reset`
|
565
|
+
* Stop replay .
|
566
|
+
|
509
567
|
### Thread control
|
510
568
|
|
511
569
|
* `th[read]`
|
@@ -525,6 +583,8 @@ The `<...>` notation means the argument.
|
|
525
583
|
* Append `<val>` to `<name>` if it is an array.
|
526
584
|
* `config unset <name>`
|
527
585
|
* Set <name> to default.
|
586
|
+
* `source <file>`
|
587
|
+
* Evaluate lines in `<file>` as debug commands.
|
528
588
|
|
529
589
|
### Help
|
530
590
|
|
@@ -550,7 +610,7 @@ You can start debugging without `rdbg` command by requiring the following librar
|
|
550
610
|
You need to require one of them at the very beginning of the application.
|
551
611
|
Using `ruby -r` (for example `ruby -r debug/start target.rb`) is another way to invoke with debugger.
|
552
612
|
|
553
|
-
NOTE: Until Ruby 3.0, there is old `lib/debug.rb` standard library. So that if this gem is not installed, or if `Gemfile` missed to list this gem and `
|
613
|
+
NOTE: Until Ruby 3.0, there is old `lib/debug.rb` standard library. So that if this gem is not installed, or if `Gemfile` missed to list this gem and `bundle exec` is used, you will see the following output:
|
554
614
|
|
555
615
|
```shell
|
556
616
|
$ ruby -r debug -e0
|
@@ -566,7 +626,7 @@ Emacs support available.
|
|
566
626
|
|
567
627
|
#### Start by method
|
568
628
|
|
569
|
-
After loading `debug/session`, you can start debug session with the following methods. They are
|
629
|
+
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.
|
570
630
|
|
571
631
|
* `DEBUGGER__.start(**kw)`: start debug session with local console.
|
572
632
|
* `DEBUGGER__.open(**kw)`: open debug port with configuration (without configurations open with UNIX domain socket)
|
@@ -591,15 +651,15 @@ If `do: 'command'` is specified, the debugger suspends the program and run the `
|
|
591
651
|
It is useful if you only want to call a debug command and don't want to stop there.
|
592
652
|
|
593
653
|
```
|
594
|
-
def
|
654
|
+
def initialize
|
595
655
|
@a = 1
|
596
656
|
binding.b do: 'watch @a'
|
597
657
|
end
|
598
658
|
```
|
599
659
|
|
600
|
-
On this case, register a watch
|
660
|
+
On this case, register a watch breakpoint for `@a` and continue to run.
|
601
661
|
|
602
|
-
If `pre: 'command'` is specified, the
|
662
|
+
If `pre: 'command'` is specified, the debugger suspends the program and run the `command` as a debug command, and keep suspend.
|
603
663
|
It is useful if you have operations before suspend.
|
604
664
|
|
605
665
|
```
|
@@ -609,7 +669,7 @@ def foo
|
|
609
669
|
end
|
610
670
|
```
|
611
671
|
|
612
|
-
On this case, you can see the result of `bar()`
|
672
|
+
On this case, you can see the result of `bar()` every time you stop there.
|
613
673
|
|
614
674
|
## rdbg command help
|
615
675
|
|
@@ -630,7 +690,7 @@ Debug console mode:
|
|
630
690
|
-O, --open Start remote debugging with opening the network port.
|
631
691
|
If TCP/IP options are not given,
|
632
692
|
a UNIX domain socket will be used.
|
633
|
-
--sock-path=SOCK_PATH UNIX
|
693
|
+
--sock-path=SOCK_PATH UNIX Domain socket path
|
634
694
|
--port=PORT Listening TCP/IP port
|
635
695
|
--host=HOST Listening TCP/IP host
|
636
696
|
--cookie=COOKIE Set a cookie for connection
|