debug 1.3.1 → 1.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +9 -11
- data/README.md +4 -4
- data/ext/debug/debug.c +1 -1
- data/lib/debug/color.rb +1 -1
- data/lib/debug/server.rb +2 -0
- data/lib/debug/server_cdp.rb +22 -8
- data/lib/debug/server_dap.rb +1 -1
- data/lib/debug/session.rb +32 -2
- data/lib/debug/version.rb +1 -1
- data/misc/README.md.erb +4 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d2f3adfa33baa3d7ef0a8ff1924d4d148be909f8cbdfc1992efda7e4ef564a17
|
4
|
+
data.tar.gz: 43085e7bec187d698d42bf7a4fc7c3ee2f4cde387cf411b2648411dc6cbb1721
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5bafcaeeb661378a3696968655cfc9b24aadb6c0ada385d143406472db4cc1a51d55bb460431ef9679d8e6ffe846c269f731335380999256565b2d259139f2d9
|
7
|
+
data.tar.gz: 961d6a453a4f117af9e056658d31afc39e173668f32eb1745f0bdad842c4891a2b6bff0bfec45d6e17fc94108da3ac4a5274118a4f0213ae0a2a5a181de89f99
|
data/CONTRIBUTING.md
CHANGED
@@ -206,17 +206,15 @@ end
|
|
206
206
|
#### gentest options
|
207
207
|
You can get more information about `gentest` here.
|
208
208
|
|
209
|
-
The default method name is `
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
$ bin/gentest target.rb -c StepTest -m test_step
|
219
|
-
```
|
209
|
+
The default method name is `test_#{some integer numbers}`, the class name is `FooTest`, and the file name will be `foo_test.rb`.
|
210
|
+
The following table shows examples of the gentest options.
|
211
|
+
|
212
|
+
| Command | Description | File | Class | Method |
|
213
|
+
| --- | --- | --- | --- | --- |
|
214
|
+
| `$ bin/gentest target.rb` | Run without any options | `foo_test.rb` | `FooTest` | `test_#{some integer numbers}` |
|
215
|
+
| `$ bin/gentest target.rb -c step` | Specify the class name | `step_test.rb` | `StepTest` | `test_#{some integer numbers}` |
|
216
|
+
| `$ bin/gentest target.rb -m test_step` | Specify the method name | `foo_test.rb` | `FooTest` | `test_step` |
|
217
|
+
| `$ bin/gentest target.rb -c step -m test_step` | Specify the class name and the method name | `step_test.rb` | `StepTest` | `test_step` |
|
220
218
|
|
221
219
|
## To Update README
|
222
220
|
|
data/README.md
CHANGED
@@ -11,7 +11,7 @@ New debug.rb has several advantages:
|
|
11
11
|
* [Remote debugging](#remote-debugging): Support remote debugging natively.
|
12
12
|
* UNIX domain socket
|
13
13
|
* TCP/IP
|
14
|
-
*
|
14
|
+
* Integration with rich debugger frontend
|
15
15
|
* VSCode/DAP ([VSCode rdbg Ruby Debugger - Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=KoichiSasada.vscode-rdbg))
|
16
16
|
* Chrome DevTools
|
17
17
|
* Extensible: application can introduce debugging support with several ways:
|
@@ -340,7 +340,7 @@ $ RUBY_DEBUG_PORT=12345 ruby target.rb
|
|
340
340
|
|
341
341
|
### Integration with external debugger frontend
|
342
342
|
|
343
|
-
You can attach with external
|
343
|
+
You can attach with external debugger frontend with VSCode and Chrome.
|
344
344
|
|
345
345
|
```
|
346
346
|
$ rdbg --open=[frontend] target.rb
|
@@ -352,7 +352,7 @@ Also `open` command allows opening the debug port.
|
|
352
352
|
|
353
353
|
#### VSCode integration
|
354
354
|
|
355
|
-
If you don't run a debuggee Ruby process on VSCode, you can attach with VSCode later with the
|
355
|
+
If you don't run a debuggee Ruby process on VSCode, you can attach with VSCode later with the following steps.
|
356
356
|
|
357
357
|
`rdbg --open=vscode` opens the debug port and tries to invoke the VSCode (`code` command).
|
358
358
|
|
@@ -364,7 +364,7 @@ Launching: code /tmp/ruby-debug-vscode-20211014-27706-gd7e85/ /tmp/ruby-debug-vs
|
|
364
364
|
DEBUGGER: Connected.
|
365
365
|
```
|
366
366
|
|
367
|
-
And it
|
367
|
+
And it tries to invoke the new VSCode window and VSCode starts attaching to the debuggee Ruby program automatically.
|
368
368
|
|
369
369
|
You can also use `open vscode` command in REPL.
|
370
370
|
|
data/ext/debug/debug.c
CHANGED
@@ -64,7 +64,7 @@ di_body(const rb_debug_inspector_t *dc, void *ptr)
|
|
64
64
|
|
65
65
|
if (!NIL_P(iseq)) {
|
66
66
|
VALUE path = iseq_realpath(iseq);
|
67
|
-
if (!NIL_P(path) && str_start_with(path, skip_path_prefix)) continue;
|
67
|
+
if (!NIL_P(path) && !NIL_P(skip_path_prefix) && str_start_with(path, skip_path_prefix)) continue;
|
68
68
|
}
|
69
69
|
|
70
70
|
loc = RARRAY_AREF(locs, i);
|
data/lib/debug/color.rb
CHANGED
data/lib/debug/server.rb
CHANGED
data/lib/debug/server_cdp.rb
CHANGED
@@ -14,9 +14,7 @@ module DEBUGGER__
|
|
14
14
|
@sock = s
|
15
15
|
end
|
16
16
|
|
17
|
-
def handshake
|
18
|
-
CONFIG.set_config no_color: true
|
19
|
-
|
17
|
+
def handshake
|
20
18
|
req = @sock.readpartial 4096
|
21
19
|
$stderr.puts '[>]' + req if SHOW_PROTOCOL
|
22
20
|
|
@@ -97,10 +95,11 @@ module DEBUGGER__
|
|
97
95
|
end
|
98
96
|
|
99
97
|
def process
|
98
|
+
bps = []
|
99
|
+
@src_map = {}
|
100
100
|
loop do
|
101
101
|
req = @web_sock.extract_data
|
102
102
|
$stderr.puts '[>]' + req.inspect if SHOW_PROTOCOL
|
103
|
-
bps = []
|
104
103
|
|
105
104
|
case req['method']
|
106
105
|
|
@@ -108,6 +107,7 @@ module DEBUGGER__
|
|
108
107
|
when 'Page.getResourceTree'
|
109
108
|
abs = File.absolute_path($0)
|
110
109
|
src = File.read(abs)
|
110
|
+
@src_map[abs] = src
|
111
111
|
send_response req,
|
112
112
|
frameTree: {
|
113
113
|
frame: {
|
@@ -124,7 +124,7 @@ module DEBUGGER__
|
|
124
124
|
url: "http://debuggee#{abs}",
|
125
125
|
startLine: 0,
|
126
126
|
startColumn: 0,
|
127
|
-
endLine: src.count(
|
127
|
+
endLine: src.count("\n"),
|
128
128
|
endColumn: 0,
|
129
129
|
executionContextId: 1,
|
130
130
|
hash: src.hash
|
@@ -136,7 +136,7 @@ module DEBUGGER__
|
|
136
136
|
}
|
137
137
|
when 'Debugger.getScriptSource'
|
138
138
|
s_id = req.dig('params', 'scriptId')
|
139
|
-
src =
|
139
|
+
src = get_source_code s_id
|
140
140
|
send_response req, scriptSource: src
|
141
141
|
@q_msg << req
|
142
142
|
when 'Page.startScreencast', 'Emulation.setTouchEmulationEnabled', 'Emulation.setEmitTouchEventsForMouse',
|
@@ -169,7 +169,10 @@ module DEBUGGER__
|
|
169
169
|
# breakpoint
|
170
170
|
when 'Debugger.getPossibleBreakpoints'
|
171
171
|
s_id = req.dig('params', 'start', 'scriptId')
|
172
|
-
line = req.dig('params', 'lineNumber')
|
172
|
+
line = req.dig('params', 'start', 'lineNumber')
|
173
|
+
src = get_source_code s_id
|
174
|
+
end_line = src.count("\n")
|
175
|
+
line = end_line if line > end_line
|
173
176
|
send_response req,
|
174
177
|
locations: [
|
175
178
|
{ scriptId: s_id,
|
@@ -180,6 +183,9 @@ module DEBUGGER__
|
|
180
183
|
line = req.dig('params', 'lineNumber')
|
181
184
|
path = req.dig('params', 'url').match('http://debuggee(.*)')[1]
|
182
185
|
cond = req.dig('params', 'condition')
|
186
|
+
src = get_source_code path
|
187
|
+
end_line = src.count("\n")
|
188
|
+
line = end_line if line > end_line
|
183
189
|
if cond != ''
|
184
190
|
bps << SESSION.add_line_breakpoint(path, line + 1, cond: cond)
|
185
191
|
else
|
@@ -202,6 +208,14 @@ module DEBUGGER__
|
|
202
208
|
end
|
203
209
|
end
|
204
210
|
|
211
|
+
def get_source_code path
|
212
|
+
return @src_map[path] if @src_map[path]
|
213
|
+
|
214
|
+
src = File.read(path)
|
215
|
+
@src_map[path] = src
|
216
|
+
src
|
217
|
+
end
|
218
|
+
|
205
219
|
## Called by the SESSION thread
|
206
220
|
|
207
221
|
def readline prompt
|
@@ -269,7 +283,7 @@ module DEBUGGER__
|
|
269
283
|
url: frame[:url],
|
270
284
|
startLine: 0,
|
271
285
|
startColumn: 0,
|
272
|
-
endLine: src.count(
|
286
|
+
endLine: src.count("\n"),
|
273
287
|
endColumn: 0,
|
274
288
|
executionContextId: @script_paths.size + 1,
|
275
289
|
hash: src.hash
|
data/lib/debug/server_dap.rb
CHANGED
@@ -491,7 +491,7 @@ module DEBUGGER__
|
|
491
491
|
case type
|
492
492
|
when :backtrace
|
493
493
|
event! :dap_result, :backtrace, req, {
|
494
|
-
stackFrames: @target_frames.map.
|
494
|
+
stackFrames: @target_frames.map.{|frame|
|
495
495
|
path = frame.realpath || frame.path
|
496
496
|
ref = frame.file_lines unless path && File.exist?(path)
|
497
497
|
|
data/lib/debug/session.rb
CHANGED
@@ -91,7 +91,7 @@ module DEBUGGER__
|
|
91
91
|
# [:check, expr] => CheckBreakpoint
|
92
92
|
#
|
93
93
|
@tracers = {}
|
94
|
-
@th_clients =
|
94
|
+
@th_clients = {} # {Thread => ThreadClient}
|
95
95
|
@q_evt = Queue.new
|
96
96
|
@displays = []
|
97
97
|
@tc = nil
|
@@ -1358,7 +1358,7 @@ module DEBUGGER__
|
|
1358
1358
|
end
|
1359
1359
|
|
1360
1360
|
def setup_threads
|
1361
|
-
prev_clients = @th_clients
|
1361
|
+
prev_clients = @th_clients
|
1362
1362
|
@th_clients = {}
|
1363
1363
|
|
1364
1364
|
Thread.list.each{|th|
|
@@ -1555,6 +1555,36 @@ module DEBUGGER__
|
|
1555
1555
|
@postmortem = false
|
1556
1556
|
end
|
1557
1557
|
|
1558
|
+
def capture_exception_frames *exclude_path
|
1559
|
+
postmortem_hook = TracePoint.new(:raise){|tp|
|
1560
|
+
exc = tp.raised_exception
|
1561
|
+
frames = DEBUGGER__.capture_frames(__dir__)
|
1562
|
+
|
1563
|
+
exclude_path.each{|ex|
|
1564
|
+
if Regexp === ex
|
1565
|
+
frames.delete_if{|e| ex =~ e.path}
|
1566
|
+
else
|
1567
|
+
frames.delete_if{|e| e.path.start_with? ex.to_s}
|
1568
|
+
end
|
1569
|
+
}
|
1570
|
+
exc.instance_variable_set(:@__debugger_postmortem_frames, frames)
|
1571
|
+
}
|
1572
|
+
postmortem_hook.enable
|
1573
|
+
|
1574
|
+
begin
|
1575
|
+
yield
|
1576
|
+
nil
|
1577
|
+
rescue Exception => e
|
1578
|
+
if e.instance_variable_defined? :@__debugger_postmortem_frames
|
1579
|
+
e
|
1580
|
+
else
|
1581
|
+
raise
|
1582
|
+
end
|
1583
|
+
ensure
|
1584
|
+
postmortem_hook.disable
|
1585
|
+
end
|
1586
|
+
end
|
1587
|
+
|
1558
1588
|
def postmortem=(is_enable)
|
1559
1589
|
if is_enable
|
1560
1590
|
unless @postmortem_hook
|
data/lib/debug/version.rb
CHANGED
data/misc/README.md.erb
CHANGED
@@ -11,7 +11,7 @@ New debug.rb has several advantages:
|
|
11
11
|
* [Remote debugging](#remote-debugging): Support remote debugging natively.
|
12
12
|
* UNIX domain socket
|
13
13
|
* TCP/IP
|
14
|
-
*
|
14
|
+
* Integration with rich debugger frontend
|
15
15
|
* VSCode/DAP ([VSCode rdbg Ruby Debugger - Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=KoichiSasada.vscode-rdbg))
|
16
16
|
* Chrome DevTools
|
17
17
|
* Extensible: application can introduce debugging support with several ways:
|
@@ -340,7 +340,7 @@ $ RUBY_DEBUG_PORT=12345 ruby target.rb
|
|
340
340
|
|
341
341
|
### Integration with external debugger frontend
|
342
342
|
|
343
|
-
You can attach with external
|
343
|
+
You can attach with external debugger frontend with VSCode and Chrome.
|
344
344
|
|
345
345
|
```
|
346
346
|
$ rdbg --open=[frontend] target.rb
|
@@ -352,7 +352,7 @@ Also `open` command allows opening the debug port.
|
|
352
352
|
|
353
353
|
#### VSCode integration
|
354
354
|
|
355
|
-
If you don't run a debuggee Ruby process on VSCode, you can attach with VSCode later with the
|
355
|
+
If you don't run a debuggee Ruby process on VSCode, you can attach with VSCode later with the following steps.
|
356
356
|
|
357
357
|
`rdbg --open=vscode` opens the debug port and tries to invoke the VSCode (`code` command).
|
358
358
|
|
@@ -364,7 +364,7 @@ Launching: code /tmp/ruby-debug-vscode-20211014-27706-gd7e85/ /tmp/ruby-debug-vs
|
|
364
364
|
DEBUGGER: Connected.
|
365
365
|
```
|
366
366
|
|
367
|
-
And it
|
367
|
+
And it tries to invoke the new VSCode window and VSCode starts attaching to the debuggee Ruby program automatically.
|
368
368
|
|
369
369
|
You can also use `open vscode` command in REPL.
|
370
370
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: debug
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.3
|
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-10-
|
11
|
+
date: 2021-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: irb
|