debug 1.0.0.beta8 → 1.1.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/CONTRIBUTING.md +108 -106
- data/README.md +107 -40
- data/Rakefile +1 -1
- data/TODO.md +4 -8
- data/debug.gemspec +1 -0
- data/exe/rdbg +4 -7
- 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 +362 -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 +46 -12
- data/lib/debug/session.rb +637 -310
- 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 +41 -33
- metadata +20 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5e9851059a728e477461cc318c9b94932fa0aeb19215f936ab6c25cf62f67cd0
|
|
4
|
+
data.tar.gz: b050eee3dbf0afecfda2c1221fe38ab678808405c10f89d5832a1950e2728aa8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a15549ee06b890a32d0960dd24a99c4c925d66b5f6512a7e5ff3052f10ca3a255038d44eaa2d10046cbe2b68bca121c813db3a8e5fea68def5dcd2e1797864d7
|
|
7
|
+
data.tar.gz: '058b5ef8c6e40a8ccfa12b62b09c8808c1b524c398e37a25ffd790b8a8e0364026911478019d06100b7a6d8fde878dd7695f2f2630f3f35f37f12695b84b2ddf'
|
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
|
@@ -8,7 +8,7 @@ This debug.rb is replacement of traditional lib/debug.rb standard library which
|
|
|
8
8
|
New debug.rb has several advantages:
|
|
9
9
|
|
|
10
10
|
* Fast: No performance penalty on non-stepping mode and non-breakpoints.
|
|
11
|
-
* Remote debugging: Support remote debugging natively.
|
|
11
|
+
* [Remote debugging](#remote-debugging): Support remote debugging natively.
|
|
12
12
|
* UNIX domain socket
|
|
13
13
|
* TCP/IP
|
|
14
14
|
* VSCode/DAP integration ([VSCode rdbg Ruby Debugger - Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=KoichiSasada.vscode-rdbg))
|
|
@@ -20,11 +20,12 @@ 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
|
|
|
26
27
|
```
|
|
27
|
-
$ gem install debug
|
|
28
|
+
$ gem install debug
|
|
28
29
|
```
|
|
29
30
|
|
|
30
31
|
or specify `-Ipath/to/debug/lib` in `RUBYOPT` or each ruby command-line option, especially for debug this gem development.
|
|
@@ -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"
|
|
36
37
|
```
|
|
37
38
|
|
|
38
39
|
# HOW TO USE
|
|
@@ -43,25 +44,27 @@ 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
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
47
|
+
* [Evaluate Ruby expressions](#evaluate) (e.g. `p lvar` to see the local variable `lvar`).
|
|
48
|
+
* [Query the program status](#information) (e.g. `info` to see information about the current frame).
|
|
49
|
+
* [Control program flow](#control-flow) (e.g. move to the another line with `step`, to the next line with `next`).
|
|
50
|
+
* [Set another breakpoint](#breakpoint) (e.g. `catch Exception` to set a breakpoint that'll be triggered when `Exception` is raised).
|
|
51
|
+
* [Activate tracing in your program](#trace) (e.g. `trace call` to trace method calls).
|
|
52
|
+
* [Change the configuration](#configuration-1) (e.g. `config set no_color true` to disable coloring).
|
|
50
53
|
* Continue the program (`c` or `continue`) and goto 3.
|
|
51
54
|
|
|
52
55
|
## Invoke with the debugger
|
|
53
56
|
|
|
54
57
|
There are several options for (1) and (2). Please choose your favorite way.
|
|
55
58
|
|
|
56
|
-
### Modify source code
|
|
59
|
+
### Modify source code with [`binding.break`](#bindingbreak-method) (similar to `binding.pry` or `binding.irb`)
|
|
57
60
|
|
|
58
|
-
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
|
|
61
|
+
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`](#bindingbreak-method) method (`binding.b` for short) into lines where you want to stop as breakpoints like `binding.pry` and `binding.irb`.
|
|
62
|
+
After that, you run the program as usual and you will enter the debug console at breakpoints you inserted.
|
|
60
63
|
|
|
61
|
-
The following example shows the demonstration of `binding.break
|
|
64
|
+
The following example shows the demonstration of [`binding.break`](#bindingbreak-method).
|
|
62
65
|
|
|
63
66
|
```shell
|
|
64
|
-
$ cat target.rb # Sample
|
|
67
|
+
$ cat target.rb # Sample program
|
|
65
68
|
require 'debug'
|
|
66
69
|
|
|
67
70
|
a = 1
|
|
@@ -120,13 +123,13 @@ d => 4
|
|
|
120
123
|
[1, 2, 3, 4]
|
|
121
124
|
```
|
|
122
125
|
|
|
123
|
-
### Invoke the
|
|
126
|
+
### Invoke the program from the debugger as a traditional debuggers
|
|
124
127
|
|
|
125
128
|
If you don't want to modify the source code, you can set breakpoints with a debug command `break` (`b` for short).
|
|
126
129
|
Using `rdbg` command to launch the program without any modifications, you can run the program with the debugger.
|
|
127
130
|
|
|
128
131
|
```shell
|
|
129
|
-
$ cat target.rb # Sample
|
|
132
|
+
$ cat target.rb # Sample program
|
|
130
133
|
a = 1
|
|
131
134
|
b = 2
|
|
132
135
|
c = 3
|
|
@@ -241,16 +244,16 @@ NOTE: If you want to use bundler (`bundle` command), you need to write `gem debu
|
|
|
241
244
|
|
|
242
245
|
### Using VSCode
|
|
243
246
|
|
|
244
|
-
Like other
|
|
247
|
+
Like other languages, you can use this debugger on the VSCode.
|
|
245
248
|
|
|
246
|
-
1. Install [VSCode rdbg Ruby Debugger - Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=KoichiSasada.vscode-rdbg)
|
|
249
|
+
1. Install [VSCode rdbg Ruby Debugger - Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=KoichiSasada.vscode-rdbg)
|
|
247
250
|
2. Open `.rb` file (e.g. `target.rb`)
|
|
248
251
|
3. Register breakpoints with "Toggle breakpoint" in Run menu (or type F9 key)
|
|
249
252
|
4. Choose "Start debugging" in "Run" menu (or type F5 key)
|
|
250
253
|
5. You will see a dialog "Debug command line" and you can choose your favorite command line your want to run.
|
|
251
|
-
6.
|
|
254
|
+
6. Chosen command line is invoked with `rdbg -c` and VSCode shows the details at breakpoints.
|
|
252
255
|
|
|
253
|
-
|
|
256
|
+
Please refer [Debugging in Visual Studio Code](https://code.visualstudio.com/docs/editor/debugging) for operations on VSCode.
|
|
254
257
|
|
|
255
258
|
You can configure the extension in `.vscode/launch.json`.
|
|
256
259
|
Please see the extension page for more details.
|
|
@@ -265,7 +268,7 @@ You can use this debugger as a remote debugger. For example, it will help the fo
|
|
|
265
268
|
* Your application uses pipe for STDIN or STDOUT.
|
|
266
269
|
* Your application is running as a daemon and you want to query the running status (checking a backtrace and so on).
|
|
267
270
|
|
|
268
|
-
You can run your application as a remote debuggee and the remote debugger console can attach to the
|
|
271
|
+
You can run your application as a remote debuggee and the remote debugger console can attach to the debuggee anytime.
|
|
269
272
|
|
|
270
273
|
### Invoke as a remote debuggee
|
|
271
274
|
|
|
@@ -279,10 +282,10 @@ You can run a script with `rdbg --open target.rb` command and run a `target.rb`
|
|
|
279
282
|
$ exe/rdbg --open target.rb
|
|
280
283
|
DEBUGGER: Session start (pid: 7773)
|
|
281
284
|
DEBUGGER: Debugger can attach via UNIX domain socket (/home/ko1/.ruby-debug-sock/ruby-debug-ko1-7773)
|
|
282
|
-
DEBUGGER: wait for
|
|
285
|
+
DEBUGGER: wait for debugger connection...
|
|
283
286
|
```
|
|
284
287
|
|
|
285
|
-
By
|
|
288
|
+
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
289
|
|
|
287
290
|
You can connect to the debuggee with `rdbg --attach` command (`rdbg -A` for short).
|
|
288
291
|
|
|
@@ -309,7 +312,7 @@ NOTE: If you use `quit` command, only remote console exits and the debuggee prog
|
|
|
309
312
|
|
|
310
313
|
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
314
|
|
|
312
|
-
To connect to the
|
|
315
|
+
To connect to the debuggee, you need to specify the port.
|
|
313
316
|
|
|
314
317
|
```shell
|
|
315
318
|
$ rdbg --attach 12345
|
|
@@ -324,7 +327,7 @@ If you can modify the program, you can open debugging port by adding `require 'd
|
|
|
324
327
|
|
|
325
328
|
If you don't want to stop the program at the beginning, you can also use `require 'debug/open_nonstop'`.
|
|
326
329
|
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
|
|
330
|
+
However, it is also danger because it can become another vulnerability.
|
|
328
331
|
Please use it carefully.
|
|
329
332
|
|
|
330
333
|
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 +339,14 @@ $ RUBY_DEBUG_PORT=12345 ruby target.rb
|
|
|
336
339
|
## Configuration
|
|
337
340
|
|
|
338
341
|
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
|
|
342
|
+
When the debug session is started, initial scripts are loaded so you can put your favorite configurations in the initial scripts.
|
|
340
343
|
|
|
341
344
|
### Configuration list
|
|
342
345
|
|
|
343
346
|
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
347
|
|
|
345
348
|
```
|
|
346
|
-
#
|
|
349
|
+
# configuration example
|
|
347
350
|
config set log_level INFO
|
|
348
351
|
config set no_color true
|
|
349
352
|
```
|
|
@@ -354,12 +357,18 @@ config set no_color true
|
|
|
354
357
|
* `RUBY_DEBUG_LOG_LEVEL` (`log_level`): Log level same as Logger (default: WARN)
|
|
355
358
|
* `RUBY_DEBUG_SHOW_SRC_LINES` (`show_src_lines`): Show n lines source code on breakpoint (default: 10 lines)
|
|
356
359
|
* `RUBY_DEBUG_SHOW_FRAMES` (`show_frames`): Show n frames on breakpoint (default: 2 frames)
|
|
357
|
-
* `
|
|
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: [])
|
|
360
|
+
* `RUBY_DEBUG_USE_SHORT_PATH` (`use_short_path`): Show shorten PATH (like $(Gem)/foo.rb)
|
|
361
361
|
* `RUBY_DEBUG_NO_COLOR` (`no_color`): Do not use colorize (default: false)
|
|
362
362
|
* `RUBY_DEBUG_NO_SIGINT_HOOK` (`no_sigint_hook`): Do not suspend on SIGINT (default: false)
|
|
363
|
+
* `RUBY_DEBUG_NO_RELINE` (`no_reline`): Do not use Reline library (default: false)
|
|
364
|
+
|
|
365
|
+
* CONTROL
|
|
366
|
+
* `RUBY_DEBUG_SKIP_PATH` (`skip_path`): Skip showing/entering frames for given paths (default: [])
|
|
367
|
+
* `RUBY_DEBUG_SKIP_NOSRC` (`skip_nosrc`): Skip on no source code lines (default: false)
|
|
368
|
+
* `RUBY_DEBUG_KEEP_ALLOC_SITE` (`keep_alloc_site`): Keep allocation site and p, pp shows it (default: false)
|
|
369
|
+
* `RUBY_DEBUG_POSTMORTEM` (`postmortem`): Enable postmortem debug (default: false)
|
|
370
|
+
* `RUBY_DEBUG_PARENT_ON_FORK` (`parent_on_fork`): Keep debugging parent process on fork (default: false)
|
|
371
|
+
* `RUBY_DEBUG_SIGDUMP_SIG` (`sigdump_sig`): Sigdump signal (default: disabled)
|
|
363
372
|
|
|
364
373
|
* BOOT
|
|
365
374
|
* `RUBY_DEBUG_NONSTOP` (`nonstop`): Nonstop mode
|
|
@@ -376,7 +385,7 @@ config set no_color true
|
|
|
376
385
|
|
|
377
386
|
### Initial scripts
|
|
378
387
|
|
|
379
|
-
If there is `~/.rdbgrc`, the file is loaded as an initial
|
|
388
|
+
If there is `~/.rdbgrc`, the file is loaded as an initial script (which contains debug commands) when the debug session is started.
|
|
380
389
|
|
|
381
390
|
* `RUBY_DEBUG_INIT_SCRIPT` environment variable can specify the initial script file.
|
|
382
391
|
* You can specify the initial script with `rdbg -x initial_script` (like gdb's `-x` option).
|
|
@@ -390,7 +399,12 @@ If there are `~/.rdbgrc.rb` is available, it is also loaded as a ruby script at
|
|
|
390
399
|
|
|
391
400
|
On the debug console, you can use the following debug commands.
|
|
392
401
|
|
|
393
|
-
|
|
402
|
+
There are additional features:
|
|
403
|
+
|
|
404
|
+
* `<expr>` without debug command is almost same as `pp <expr>`.
|
|
405
|
+
* 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`.
|
|
406
|
+
* 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.
|
|
407
|
+
* `Enter` without any input repeats the last command (useful when repeating `step`s).
|
|
394
408
|
* `Ctrl-D` is equal to `quit` command.
|
|
395
409
|
* [debug command compare sheet - Google Sheets](https://docs.google.com/spreadsheets/d/1TlmmUDsvwK4sSIyoMv-io52BUUz__R5wpu-ComXlsw0/edit?usp=sharing)
|
|
396
410
|
|
|
@@ -402,10 +416,16 @@ The `<...>` notation means the argument.
|
|
|
402
416
|
|
|
403
417
|
* `s[tep]`
|
|
404
418
|
* Step in. Resume the program until next breakable point.
|
|
419
|
+
* `s[tep] <n>`
|
|
420
|
+
* Step in, resume the program at `<n>`th breakable point.
|
|
405
421
|
* `n[ext]`
|
|
406
422
|
* Step over. Resume the program until next line.
|
|
423
|
+
* `n[ext] <n>`
|
|
424
|
+
* Step over, same as `step <n>`.
|
|
407
425
|
* `fin[ish]`
|
|
408
426
|
* Finish this frame. Resume the program until the current frame is finished.
|
|
427
|
+
* `fin[ish] <n>`
|
|
428
|
+
* Finish frames, same as `step <n>`.
|
|
409
429
|
* `c[ontinue]`
|
|
410
430
|
* Resume the program.
|
|
411
431
|
* `q[uit]` or `Ctrl-D`
|
|
@@ -470,11 +490,26 @@ The `<...>` notation means the argument.
|
|
|
470
490
|
* Note that edited file will not be reloaded.
|
|
471
491
|
* `edit <file>`
|
|
472
492
|
* Open <file> on the editor.
|
|
473
|
-
* `i[nfo]
|
|
493
|
+
* `i[nfo]`
|
|
494
|
+
* Show information about current frame (local/instance variables and defined constants).
|
|
495
|
+
* `i[nfo] l[ocal[s]]`
|
|
474
496
|
* Show information about the current frame (local variables)
|
|
475
497
|
* It includes `self` as `%self` and a return value as `%return`.
|
|
498
|
+
* `i[nfo] i[var[s]]` or `i[nfo] instance`
|
|
499
|
+
* Show information about instance variables about `self`.
|
|
500
|
+
* `i[nfo] c[onst[s]]` or `i[nfo] constant[s]`
|
|
501
|
+
* Show information about accessible constants except toplevel constants.
|
|
502
|
+
* `i[nfo] g[lobal[s]]`
|
|
503
|
+
* Show information about global variables
|
|
504
|
+
* `i[nfo] ... </pattern/>`
|
|
505
|
+
* Filter the output with `</pattern/>`.
|
|
476
506
|
* `i[nfo] th[read[s]]`
|
|
477
507
|
* Show all threads (same as `th[read]`).
|
|
508
|
+
* `o[utline]` or `ls`
|
|
509
|
+
* Show you available methods, constants, local variables, and instance variables in the current scope.
|
|
510
|
+
* `o[utline] <expr>` or `ls <expr>`
|
|
511
|
+
* Show you available methods and instance variables of the given object.
|
|
512
|
+
* If the object is a class/module, it also lists its constants.
|
|
478
513
|
* `display`
|
|
479
514
|
* Show display setting.
|
|
480
515
|
* `display <expr>`
|
|
@@ -501,11 +536,41 @@ The `<...>` notation means the argument.
|
|
|
501
536
|
* Evaluate like `p <expr>` on the current frame.
|
|
502
537
|
* `pp <expr>`
|
|
503
538
|
* Evaluate like `pp <expr>` on the current frame.
|
|
504
|
-
* `
|
|
539
|
+
* `eval <expr>`
|
|
505
540
|
* Evaluate `<expr>` on the current frame.
|
|
506
541
|
* `irb`
|
|
507
542
|
* Invoke `irb` on the current frame.
|
|
508
543
|
|
|
544
|
+
### Trace
|
|
545
|
+
|
|
546
|
+
* `trace`
|
|
547
|
+
* Show available tracers list.
|
|
548
|
+
* `trace line`
|
|
549
|
+
* Add a line tracer. It indicates line events.
|
|
550
|
+
* `trace call`
|
|
551
|
+
* Add a call tracer. It indicate call/return events.
|
|
552
|
+
* `trace exception`
|
|
553
|
+
* Add an exception tracer. It indicates raising exceptions.
|
|
554
|
+
* `trace object <expr>`
|
|
555
|
+
* Add an object tracer. It indicates that an object by `<expr>` is passed as a parameter or a receiver on method call.
|
|
556
|
+
* `trace ... </pattern/>`
|
|
557
|
+
* Indicates only matched events to `</pattern/>` (RegExp).
|
|
558
|
+
* `trace ... into: <file>`
|
|
559
|
+
* Save trace information into: `<file>`.
|
|
560
|
+
* `trace off <num>`
|
|
561
|
+
* Disable tracer specified by `<num>` (use `trace` command to check the numbers).
|
|
562
|
+
* `trace off [line|call|pass]`
|
|
563
|
+
* Disable all tracers. If `<type>` is provided, disable specified type tracers.
|
|
564
|
+
* `record`
|
|
565
|
+
* Show recording status.
|
|
566
|
+
* `record [on|off]`
|
|
567
|
+
* Start/Stop recording.
|
|
568
|
+
* `step back`
|
|
569
|
+
* Start replay. Step back with the last execution log.
|
|
570
|
+
* `s[tep]` does stepping forward with the last log.
|
|
571
|
+
* `step reset`
|
|
572
|
+
* Stop replay .
|
|
573
|
+
|
|
509
574
|
### Thread control
|
|
510
575
|
|
|
511
576
|
* `th[read]`
|
|
@@ -525,6 +590,8 @@ The `<...>` notation means the argument.
|
|
|
525
590
|
* Append `<val>` to `<name>` if it is an array.
|
|
526
591
|
* `config unset <name>`
|
|
527
592
|
* Set <name> to default.
|
|
593
|
+
* `source <file>`
|
|
594
|
+
* Evaluate lines in `<file>` as debug commands.
|
|
528
595
|
|
|
529
596
|
### Help
|
|
530
597
|
|
|
@@ -550,7 +617,7 @@ You can start debugging without `rdbg` command by requiring the following librar
|
|
|
550
617
|
You need to require one of them at the very beginning of the application.
|
|
551
618
|
Using `ruby -r` (for example `ruby -r debug/start target.rb`) is another way to invoke with debugger.
|
|
552
619
|
|
|
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 `
|
|
620
|
+
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
621
|
|
|
555
622
|
```shell
|
|
556
623
|
$ ruby -r debug -e0
|
|
@@ -566,7 +633,7 @@ Emacs support available.
|
|
|
566
633
|
|
|
567
634
|
#### Start by method
|
|
568
635
|
|
|
569
|
-
After loading `debug/session`, you can start debug session with the following methods. They are
|
|
636
|
+
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
637
|
|
|
571
638
|
* `DEBUGGER__.start(**kw)`: start debug session with local console.
|
|
572
639
|
* `DEBUGGER__.open(**kw)`: open debug port with configuration (without configurations open with UNIX domain socket)
|
|
@@ -591,15 +658,15 @@ If `do: 'command'` is specified, the debugger suspends the program and run the `
|
|
|
591
658
|
It is useful if you only want to call a debug command and don't want to stop there.
|
|
592
659
|
|
|
593
660
|
```
|
|
594
|
-
def
|
|
661
|
+
def initialize
|
|
595
662
|
@a = 1
|
|
596
663
|
binding.b do: 'watch @a'
|
|
597
664
|
end
|
|
598
665
|
```
|
|
599
666
|
|
|
600
|
-
On this case, register a watch
|
|
667
|
+
On this case, register a watch breakpoint for `@a` and continue to run.
|
|
601
668
|
|
|
602
|
-
If `pre: 'command'` is specified, the
|
|
669
|
+
If `pre: 'command'` is specified, the debugger suspends the program and run the `command` as a debug command, and keep suspend.
|
|
603
670
|
It is useful if you have operations before suspend.
|
|
604
671
|
|
|
605
672
|
```
|
|
@@ -609,7 +676,7 @@ def foo
|
|
|
609
676
|
end
|
|
610
677
|
```
|
|
611
678
|
|
|
612
|
-
On this case, you can see the result of `bar()`
|
|
679
|
+
On this case, you can see the result of `bar()` every time you stop there.
|
|
613
680
|
|
|
614
681
|
## rdbg command help
|
|
615
682
|
|
|
@@ -630,7 +697,7 @@ Debug console mode:
|
|
|
630
697
|
-O, --open Start remote debugging with opening the network port.
|
|
631
698
|
If TCP/IP options are not given,
|
|
632
699
|
a UNIX domain socket will be used.
|
|
633
|
-
--sock-path=SOCK_PATH UNIX
|
|
700
|
+
--sock-path=SOCK_PATH UNIX Domain socket path
|
|
634
701
|
--port=PORT Listening TCP/IP port
|
|
635
702
|
--host=HOST Listening TCP/IP host
|
|
636
703
|
--cookie=COOKIE Set a cookie for connection
|