debug 1.0.0.beta2 → 1.0.0.beta7
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/.github/workflows/ruby.yml +34 -0
- data/.gitignore +3 -0
- data/CONTRIBUTING.md +336 -0
- data/Gemfile +2 -2
- data/README.md +190 -73
- data/TODO.md +27 -0
- data/bin/gentest +22 -0
- data/debug.gemspec +2 -0
- data/exe/rdbg +14 -11
- data/ext/debug/debug.c +10 -9
- data/lib/debug.rb +4 -1
- data/lib/debug/breakpoint.rb +110 -45
- data/lib/debug/client.rb +55 -13
- data/lib/debug/color.rb +76 -0
- data/lib/debug/config.rb +157 -33
- data/lib/debug/console.rb +26 -2
- data/lib/debug/frame_info.rb +145 -0
- data/lib/debug/open.rb +3 -0
- data/lib/debug/run.rb +4 -1
- data/lib/debug/server.rb +103 -50
- data/lib/debug/server_dap.rb +607 -0
- data/lib/debug/session.rb +534 -169
- data/lib/debug/source_repository.rb +64 -12
- data/lib/debug/thread_client.rb +211 -126
- data/lib/debug/version.rb +3 -1
- data/misc/README.md.erb +95 -47
- metadata +24 -3
data/lib/debug/version.rb
CHANGED
data/misc/README.md.erb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
[](https://github.com/ruby/debug/actions/workflows/ruby.yml?query=branch%3Amaster)
|
2
|
+
|
1
3
|
# debug.rb
|
2
4
|
|
3
5
|
This library provides debugging functionality to Ruby.
|
@@ -9,7 +11,7 @@ New debug.rb has several advantages:
|
|
9
11
|
* Remote debugging: Support remote debugging natively.
|
10
12
|
* UNIX domain socket
|
11
13
|
* TCP/IP
|
12
|
-
* VSCode/DAP integration (
|
14
|
+
* VSCode/DAP integration ([VSCode rdbg Ruby Debugger - Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=KoichiSasada.vscode-rdbg))
|
13
15
|
* Extensible: application can introduce debugging support with several methods
|
14
16
|
* By `rdbg` command
|
15
17
|
* By loading libraries with `-r` command line option
|
@@ -27,6 +29,16 @@ $ gem install debug --pre
|
|
27
29
|
|
28
30
|
or specify `-Ipath/to/debug/lib` in `RUBYOPT` or each ruby command-line option, especially for debug this gem development.
|
29
31
|
|
32
|
+
If you use Bundler, write the following line to your Gemfile. And use rdbg command with -c option.
|
33
|
+
|
34
|
+
```
|
35
|
+
gem "debug", ">= 1.0.0.beta"
|
36
|
+
```
|
37
|
+
|
38
|
+
```
|
39
|
+
$ rdbg -c bundle exec ruby target.rb
|
40
|
+
```
|
41
|
+
|
30
42
|
# How to use
|
31
43
|
|
32
44
|
## Invoke with debugger
|
@@ -49,33 +61,54 @@ To use debugging feature, you can have 3 ways.
|
|
49
61
|
|
50
62
|
### Local debug console
|
51
63
|
|
64
|
+
#### (1) Use `rdbg` command
|
65
|
+
|
52
66
|
```
|
53
|
-
# (1) Use `rdbg` command
|
54
67
|
$ rdbg target.rb
|
55
68
|
$ rdbg -- -r foo -e expr # -- is required to make clear rdbg options and ruby's options
|
69
|
+
```
|
56
70
|
|
57
|
-
|
71
|
+
#### (2) Use `-r debug/run` command line option
|
58
72
|
|
73
|
+
```
|
59
74
|
$ ruby -r debug/run target.rb
|
75
|
+
```
|
60
76
|
|
61
|
-
|
77
|
+
#### (3) Write `require 'debug...'` in .rb files
|
62
78
|
|
63
|
-
|
79
|
+
```ruby
|
80
|
+
# target.rb
|
64
81
|
require 'debug/run' # start the debug console
|
65
|
-
...
|
66
82
|
|
67
|
-
#
|
83
|
+
# ... rest of program ...
|
84
|
+
```
|
68
85
|
|
69
|
-
$ cat target.rb
|
70
|
-
require 'debug/session' # introduce the functionality
|
71
|
-
DEBUGGER__.console # and start the debug console
|
72
86
|
|
87
|
+
```
|
73
88
|
$ ruby target.rb
|
74
89
|
```
|
75
90
|
|
76
91
|
When you run the program with the debug console, you will see the debug console prompt `(rdbg)`.
|
77
92
|
The debuggee program (`target.rb`) is suspended at the beginning of `target.rb`.
|
78
93
|
|
94
|
+
|
95
|
+
Alternatively, start the debugger at a specific location in your program using `binding.break` (`binding.b` for short).
|
96
|
+
|
97
|
+
```ruby
|
98
|
+
# target.rb
|
99
|
+
require 'debug' # start the debugger
|
100
|
+
|
101
|
+
# ... program ...
|
102
|
+
|
103
|
+
binding.break # setup a breakpoint at this line
|
104
|
+
|
105
|
+
# ... rest of program ...
|
106
|
+
```
|
107
|
+
|
108
|
+
```
|
109
|
+
$ ruby target.rb
|
110
|
+
```
|
111
|
+
|
79
112
|
You can type any debugger's command described bellow. "c" or "continue" resume the debuggee program.
|
80
113
|
You can suspend the debuggee program and show the debug console with `Ctrl-C`.
|
81
114
|
|
@@ -143,33 +176,36 @@ $ rdbg ~/src/rb/target.rb
|
|
143
176
|
|
144
177
|
### Remote debug (1) UNIX domain socket
|
145
178
|
|
179
|
+
#### (1) Use `rdbg` command
|
180
|
+
|
146
181
|
```
|
147
|
-
# (1) Use `rdbg` command
|
148
182
|
$ rdbg --open target.rb # or rdbg -O target.rb for shorthand
|
149
183
|
Debugger can attach via UNIX domain socket (/home/ko1/.ruby-debug-sock/ruby-debug-ko1-5042)
|
150
|
-
|
184
|
+
```
|
151
185
|
|
152
|
-
|
186
|
+
#### (2) Use `-r debug/open` command line option
|
153
187
|
|
188
|
+
```
|
154
189
|
$ ruby -r debug/open target.rb
|
155
190
|
Debugger can attach via UNIX domain socket (/home/ko1/.ruby-debug-sock/ruby-debug-ko1-5042)
|
156
|
-
|
191
|
+
```
|
192
|
+
|
193
|
+
#### (3) Write `require 'debug/open'` in .rb files
|
157
194
|
|
158
|
-
|
159
|
-
|
195
|
+
```ruby
|
196
|
+
# target.rb
|
160
197
|
require 'debug/open' # open the debugger entry point by UNIX domain socket.
|
161
|
-
...
|
162
198
|
|
163
199
|
# or
|
164
200
|
|
165
|
-
$ cat target.rb
|
166
201
|
require 'debug/server' # introduce remote debugging feature
|
167
202
|
DEBUGGER__.open # open the debugger entry point by UNIX domain socket.
|
168
203
|
# or DEBUGGER__.open_unix to specify UNIX domain socket.
|
204
|
+
```
|
169
205
|
|
206
|
+
```
|
170
207
|
$ ruby target.rb
|
171
208
|
Debugger can attach via UNIX domain socket (/home/ko1/.ruby-debug-sock/ruby-debug-ko1-5042)
|
172
|
-
...
|
173
209
|
```
|
174
210
|
|
175
211
|
It runs target.rb and accept debugger connection within UNIX domain socket.
|
@@ -233,40 +269,49 @@ The socket file is located at
|
|
233
269
|
|
234
270
|
You can open the TCP/IP port instead of using UNIX domain socket.
|
235
271
|
|
272
|
+
#### (1) Use `rdbg` command
|
273
|
+
|
236
274
|
```
|
237
|
-
# (1) Use `rdbg` command
|
238
275
|
$ rdbg -O --port=12345 target.rb
|
239
276
|
# or
|
240
277
|
$ rdbg --open --port=12345 target.rb
|
241
278
|
Debugger can attach via TCP/IP (localhost:12345)
|
242
|
-
|
279
|
+
```
|
280
|
+
|
281
|
+
#### (2) Use `-r debug/open` command line option
|
243
282
|
|
244
|
-
# (2) Use `-r debug/open` command line option
|
245
283
|
|
284
|
+
```
|
246
285
|
$ RUBY_DEBUG_PORT=12345 ruby -r debug/open target.rb
|
247
286
|
Debugger can attach via TCP/IP (localhost:12345)
|
248
|
-
|
287
|
+
```
|
288
|
+
|
289
|
+
#### (3) Write `require 'debug/open'` in .rb files
|
249
290
|
|
250
|
-
|
251
|
-
|
291
|
+
```ruby
|
292
|
+
# target.rb
|
252
293
|
require 'debug/open' # open the debugger entry point.
|
253
|
-
|
294
|
+
```
|
254
295
|
|
255
|
-
|
296
|
+
and run with environment variable RUBY_DEBUG_PORT
|
297
|
+
|
298
|
+
```
|
256
299
|
$ RUBY_DEBUG_PORT=12345 ruby target.rb
|
257
300
|
Debugger can attach via TCP/IP (localhost:12345)
|
258
|
-
|
301
|
+
```
|
259
302
|
|
260
|
-
|
303
|
+
or
|
261
304
|
|
262
|
-
|
305
|
+
```ruby
|
306
|
+
# target.rb
|
263
307
|
require 'debug/server' # introduce remote debugging feature
|
264
308
|
DEBUGGER__.open(port: 12345)
|
265
309
|
# or DEBUGGER__.open_tcp(port: 12345)
|
310
|
+
```
|
266
311
|
|
312
|
+
```
|
267
313
|
$ ruby target.rb
|
268
314
|
Debugger can attach via TCP/IP (localhost:12345)
|
269
|
-
...
|
270
315
|
```
|
271
316
|
|
272
317
|
You can also specify the host with the `RUBY_DEBUG_HOST` environment variable. And also `DEBUGGER__.open` method accepts a `host:` keyword parameter. If the host is not given, `localhost` will be used.
|
@@ -280,26 +325,23 @@ $ rdbg --attach hostname 12345
|
|
280
325
|
|
281
326
|
### Initial scripts
|
282
327
|
|
283
|
-
If there are
|
284
|
-
|
285
|
-
Initial scripts are evaluated at the first suspend timing (generally, it is the beginning of the target script). For example, you can set break points with `break file:123`.
|
328
|
+
If there are `~/.rdbgrc`, the file is loaded as initial scripts which contains debugger commands at the beginning of debug session. `RUBY_DEBUG_INIT_SCRIPT` environment variable can specify the initial script file. You can write configurations in a file. For example, you can set break points with `break file:123` in `~/.rdbgrc`.
|
286
329
|
|
287
|
-
If there are
|
330
|
+
If there are `~/.rdbgrc.rb` is available, it is loaded as a ruby script at same timing.
|
288
331
|
|
289
|
-
###
|
332
|
+
### Configurations
|
290
333
|
|
291
|
-
You can
|
334
|
+
You can configure debugger's setting with environment variables and `config` command.
|
335
|
+
You can write any configuration into `~/.rdbgrc` like:
|
292
336
|
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
*
|
300
|
-
*
|
301
|
-
* `RUBY_DEBUG_HOST`: TCP/IP remote debugging: host (localhost if not given) to open.
|
302
|
-
* `RUBY_DEBUG_SOCK_DIR`: UNIX Domain Socket remote debugging: socket directory to open.
|
337
|
+
```
|
338
|
+
config set log_level INFO
|
339
|
+
config set no_color true
|
340
|
+
```
|
341
|
+
<% cat = nil; DEBUGGER__::CONFIG_SET.each do |key, (env, desc)| %>
|
342
|
+
<% /\A(\w+): (.+)/ =~ desc; if cat != $1; cat = 1 %>
|
343
|
+
* <%= $1 %>
|
344
|
+
<% cat = $1; end %> * `<%= env %>` (`<%= key %>`): <%= $2 %><% end %>
|
303
345
|
|
304
346
|
## Debug command on the debug console
|
305
347
|
|
@@ -322,3 +364,9 @@ The `<...>` notation means the argument.
|
|
322
364
|
# Contributing
|
323
365
|
|
324
366
|
Bug reports and pull requests are welcome on GitHub at https://github.com/ruby/debug.
|
367
|
+
|
368
|
+
Please also check the [contributing guideline](/CONTRIBUTING.md).
|
369
|
+
|
370
|
+
# Acknowledgement
|
371
|
+
|
372
|
+
* Some tests are based on [deivid-rodriguez/byebug: Debugging in Ruby 2](https://github.com/deivid-rodriguez/byebug)
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: debug
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.beta7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Koichi Sasada
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
12
|
-
dependencies:
|
11
|
+
date: 2021-07-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: irb
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
description: Debugging functionality for Ruby. This is completely rewritten debug.rb
|
14
28
|
which was contained by the encient Ruby versions.
|
15
29
|
email:
|
@@ -20,12 +34,16 @@ extensions:
|
|
20
34
|
- ext/debug/extconf.rb
|
21
35
|
extra_rdoc_files: []
|
22
36
|
files:
|
37
|
+
- ".github/workflows/ruby.yml"
|
23
38
|
- ".gitignore"
|
39
|
+
- CONTRIBUTING.md
|
24
40
|
- Gemfile
|
25
41
|
- LICENSE.txt
|
26
42
|
- README.md
|
27
43
|
- Rakefile
|
44
|
+
- TODO.md
|
28
45
|
- bin/console
|
46
|
+
- bin/gentest
|
29
47
|
- bin/setup
|
30
48
|
- debug.gemspec
|
31
49
|
- exe/rdbg
|
@@ -36,11 +54,14 @@ files:
|
|
36
54
|
- lib/debug/bp.vim
|
37
55
|
- lib/debug/breakpoint.rb
|
38
56
|
- lib/debug/client.rb
|
57
|
+
- lib/debug/color.rb
|
39
58
|
- lib/debug/config.rb
|
40
59
|
- lib/debug/console.rb
|
60
|
+
- lib/debug/frame_info.rb
|
41
61
|
- lib/debug/open.rb
|
42
62
|
- lib/debug/run.rb
|
43
63
|
- lib/debug/server.rb
|
64
|
+
- lib/debug/server_dap.rb
|
44
65
|
- lib/debug/session.rb
|
45
66
|
- lib/debug/source_repository.rb
|
46
67
|
- lib/debug/thread_client.rb
|