debug 1.4.0 → 1.6.1
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 +195 -3
- data/Gemfile +1 -0
- data/README.md +55 -32
- data/Rakefile +28 -10
- data/debug.gemspec +7 -5
- data/exe/rdbg +7 -3
- data/ext/debug/debug.c +76 -14
- data/ext/debug/extconf.rb +22 -0
- data/lib/debug/breakpoint.rb +90 -66
- data/lib/debug/client.rb +21 -5
- data/lib/debug/config.rb +55 -24
- data/lib/debug/console.rb +43 -16
- data/lib/debug/frame_info.rb +32 -26
- data/lib/debug/local.rb +1 -1
- data/lib/debug/server.rb +105 -40
- data/lib/debug/server_cdp.rb +373 -152
- data/lib/debug/server_dap.rb +273 -170
- data/lib/debug/session.rb +450 -236
- data/lib/debug/source_repository.rb +104 -51
- data/lib/debug/thread_client.rb +252 -103
- data/lib/debug/tracer.rb +7 -12
- data/lib/debug/version.rb +1 -1
- data/misc/README.md.erb +34 -14
- metadata +6 -16
- data/.github/ISSUE_TEMPLATE/bug_report.md +0 -24
- data/.github/ISSUE_TEMPLATE/custom.md +0 -10
- data/.github/ISSUE_TEMPLATE/feature_request.md +0 -14
- data/.github/pull_request_template.md +0 -9
- data/.github/workflows/ruby.yml +0 -34
- data/.gitignore +0 -12
- data/bin/console +0 -14
- data/bin/gentest +0 -30
- data/bin/setup +0 -8
- data/lib/debug/bp.vim +0 -68
data/misc/README.md.erb
CHANGED
@@ -1,19 +1,23 @@
|
|
1
|
-
[](https://github.com/ruby/debug/actions/workflows/ruby.yml?query=branch%3Amaster)
|
1
|
+
[](https://github.com/ruby/debug/actions/workflows/ruby.yml?query=branch%3Amaster) [](https://github.com/ruby/debug/actions/workflows/protocol.yml)
|
2
2
|
|
3
3
|
# debug.rb
|
4
4
|
|
5
|
-
This library provides debugging functionality to Ruby.
|
5
|
+
This library provides debugging functionality to Ruby (MRI) 2.6 and later.
|
6
6
|
|
7
7
|
This debug.rb is 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.
|
11
11
|
* [Remote debugging](#remote-debugging): Support remote debugging natively.
|
12
|
-
* UNIX domain socket
|
12
|
+
* UNIX domain socket (UDS)
|
13
13
|
* TCP/IP
|
14
|
-
* Integration with rich debugger
|
15
|
-
|
16
|
-
|
14
|
+
* Integration with rich debugger frontends
|
15
|
+
|
16
|
+
Frontend | [Console](https://github.com/ruby/debug#invoke-as-a-remote-debuggee) | [VSCode](https://github.com/ruby/debug#vscode-integration) | [Chrome DevTool](#chrome-devtool-integration) |
|
17
|
+
---|---|---|---|
|
18
|
+
Connection | UDS, TCP/IP | UDS, TCP/IP | TCP/IP |
|
19
|
+
Requirement | No | [vscode-rdbg](https://marketplace.visualstudio.com/items?itemName=KoichiSasada.vscode-rdbg) | Chrome |
|
20
|
+
|
17
21
|
* Extensible: application can introduce debugging support with several ways:
|
18
22
|
* By `rdbg` command
|
19
23
|
* By loading libraries with `-r` command line option
|
@@ -38,6 +42,9 @@ If you use Bundler, write the following line to your Gemfile.
|
|
38
42
|
gem "debug", ">= 1.0.0"
|
39
43
|
```
|
40
44
|
|
45
|
+
(The version constraint is important; `debug < 1.0.0` is an older,
|
46
|
+
abandoned gem that is completely different from this product.)
|
47
|
+
|
41
48
|
# HOW TO USE
|
42
49
|
|
43
50
|
To use a debugger, roughly you will do the following steps:
|
@@ -113,7 +120,7 @@ d => nil
|
|
113
120
|
5| binding.break
|
114
121
|
6| c = 3
|
115
122
|
7| d = 4
|
116
|
-
=> 8| binding.break # Again the program stops
|
123
|
+
=> 8| binding.break # Again the program stops here
|
117
124
|
9| p [a, b, c, d]
|
118
125
|
10|
|
119
126
|
11| __END__
|
@@ -134,7 +141,7 @@ d => 4
|
|
134
141
|
### Invoke the program from the debugger as a traditional debuggers
|
135
142
|
|
136
143
|
If you don't want to modify the source code, you can set breakpoints with a debug command `break` (`b` for short).
|
137
|
-
Using `rdbg` command to launch the program without any modifications, you can run the program with the debugger.
|
144
|
+
Using `rdbg` command (or `bundle exec rdbg`) to launch the program without any modifications, you can run the program with the debugger.
|
138
145
|
|
139
146
|
```shell
|
140
147
|
$ cat target.rb # Sample program
|
@@ -280,7 +287,12 @@ You can run your application as a remote debuggee and the remote debugger consol
|
|
280
287
|
|
281
288
|
### Invoke as a remote debuggee
|
282
289
|
|
283
|
-
There are
|
290
|
+
There are multiple ways to run your program as a debuggee:
|
291
|
+
|
292
|
+
Stop at program start | [`rdbg` option](https://github.com/ruby/debug#rdbg---open-or-rdbg--o-for-short) | [require](https://github.com/ruby/debug#require-debugopen-in-a-program) | [debugger API](https://github.com/ruby/debug#start-by-method)
|
293
|
+
---|---|---|---|
|
294
|
+
Yes | `rdbg --open` | `require "debug/open"` | `DEBUGGER__.open`
|
295
|
+
No | `rdbg --open --nonstop` | `require "debug/open_nonstop"` | `DEBUGGER__.open(nonstop: true)`
|
284
296
|
|
285
297
|
#### `rdbg --open` (or `rdbg -O` for short)
|
286
298
|
|
@@ -358,6 +370,8 @@ Also `open` command allows opening the debug port.
|
|
358
370
|
|
359
371
|
#### VSCode integration
|
360
372
|
|
373
|
+
([vscode-rdbg v0.0.9](https://marketplace.visualstudio.com/items?itemName=KoichiSasada.vscode-rdbg) or later is required)
|
374
|
+
|
361
375
|
If you don't run a debuggee Ruby process on VSCode, you can attach with VSCode later with the following steps.
|
362
376
|
|
363
377
|
`rdbg --open=vscode` opens the debug port and tries to invoke the VSCode (`code` command).
|
@@ -417,7 +431,7 @@ Note that you can attach with `rdbg --attach` and continue REPL debugging.
|
|
417
431
|
|
418
432
|
#### Chrome DevTool integration
|
419
433
|
|
420
|
-
With `rdbg --open=chrome` command will
|
434
|
+
With `rdbg --open=chrome` command will show the following message.
|
421
435
|
|
422
436
|
```
|
423
437
|
$ rdbg target.rb --open=chrome
|
@@ -435,8 +449,6 @@ Also `open chrome` command works like `open vscode`.
|
|
435
449
|
|
436
450
|
For more information about how to use Chrome debugging, you might want to read [here](https://developer.chrome.com/docs/devtools/).
|
437
451
|
|
438
|
-
Note: If you want to maximize Chrome DevTools, click [Toggle Device Toolbar](https://developer.chrome.com/docs/devtools/device-mode/#viewport).
|
439
|
-
|
440
452
|
## Configuration
|
441
453
|
|
442
454
|
You can configure the debugger's behavior with debug commands and environment variables.
|
@@ -452,10 +464,18 @@ config set log_level INFO
|
|
452
464
|
config set no_color true
|
453
465
|
```
|
454
466
|
|
455
|
-
<% cat = nil; DEBUGGER__::CONFIG_SET.each do |key, (env, desc)| %>
|
467
|
+
<% cat = nil; DEBUGGER__::CONFIG_SET.each do |key, (env, desc, _, default)| %>
|
456
468
|
<% /\A(\w+): (.+)/ =~ desc; if cat != $1; cat = 1 %>
|
457
469
|
* <%= $1 %>
|
458
|
-
<% cat = $1; end %> * `<%= env %>` (`<%= key %>`): <%= $2 %><% end %>
|
470
|
+
<% cat = $1; end %> * `<%= env %>` (`<%= key %>`): <%= default ? "#{$2} (default: #{default})" : $2 %><% end %>
|
471
|
+
|
472
|
+
There are other environment variables:
|
473
|
+
|
474
|
+
* `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/)).
|
475
|
+
* `RUBY_DEBUG_ENABLE`: If the value is `0`, do not enable debug.gem feature.
|
476
|
+
* `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.
|
477
|
+
* `RUBY_DEBUG_EDITOR` or `EDITOR`: An editor used by `edit` debug command.
|
478
|
+
* `RUBY_DEBUG_BB`: Define `Kernel#bb` method which is alias of `Kernel#debugger`.
|
459
479
|
|
460
480
|
### Initial scripts
|
461
481
|
|
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.
|
4
|
+
version: 1.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Koichi Sasada
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-07-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: irb
|
@@ -30,16 +30,16 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: 0.3.1
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.
|
40
|
+
version: 0.3.1
|
41
41
|
description: Debugging functionality for Ruby. This is completely rewritten debug.rb
|
42
|
-
which was contained by the
|
42
|
+
which was contained by the ancient Ruby versions.
|
43
43
|
email:
|
44
44
|
- ko1@atdot.net
|
45
45
|
executables:
|
@@ -48,28 +48,18 @@ extensions:
|
|
48
48
|
- ext/debug/extconf.rb
|
49
49
|
extra_rdoc_files: []
|
50
50
|
files:
|
51
|
-
- ".github/ISSUE_TEMPLATE/bug_report.md"
|
52
|
-
- ".github/ISSUE_TEMPLATE/custom.md"
|
53
|
-
- ".github/ISSUE_TEMPLATE/feature_request.md"
|
54
|
-
- ".github/pull_request_template.md"
|
55
|
-
- ".github/workflows/ruby.yml"
|
56
|
-
- ".gitignore"
|
57
51
|
- CONTRIBUTING.md
|
58
52
|
- Gemfile
|
59
53
|
- LICENSE.txt
|
60
54
|
- README.md
|
61
55
|
- Rakefile
|
62
56
|
- TODO.md
|
63
|
-
- bin/console
|
64
|
-
- bin/gentest
|
65
|
-
- bin/setup
|
66
57
|
- debug.gemspec
|
67
58
|
- exe/rdbg
|
68
59
|
- ext/debug/debug.c
|
69
60
|
- ext/debug/extconf.rb
|
70
61
|
- ext/debug/iseq_collector.c
|
71
62
|
- lib/debug.rb
|
72
|
-
- lib/debug/bp.vim
|
73
63
|
- lib/debug/breakpoint.rb
|
74
64
|
- lib/debug/client.rb
|
75
65
|
- lib/debug/color.rb
|
@@ -112,7 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
102
|
- !ruby/object:Gem::Version
|
113
103
|
version: '0'
|
114
104
|
requirements: []
|
115
|
-
rubygems_version: 3.
|
105
|
+
rubygems_version: 3.3.7
|
116
106
|
signing_key:
|
117
107
|
specification_version: 4
|
118
108
|
summary: Debugging functionality for Ruby
|
@@ -1,24 +0,0 @@
|
|
1
|
-
---
|
2
|
-
name: Bug report
|
3
|
-
about: Create a report to help us improve
|
4
|
-
title: ''
|
5
|
-
labels: ''
|
6
|
-
assignees: ''
|
7
|
-
|
8
|
-
---
|
9
|
-
|
10
|
-
**Your environment**
|
11
|
-
|
12
|
-
* `ruby -v`:
|
13
|
-
* `rdbg -v`:
|
14
|
-
|
15
|
-
**Describe the bug**
|
16
|
-
A clear and concise description of what the bug is.
|
17
|
-
|
18
|
-
**To Reproduce**
|
19
|
-
|
20
|
-
**Expected behavior**
|
21
|
-
A clear and concise description of what you expected to happen.
|
22
|
-
|
23
|
-
**Additional context**
|
24
|
-
Add any other context about the problem here.
|
@@ -1,14 +0,0 @@
|
|
1
|
-
---
|
2
|
-
name: Feature request
|
3
|
-
about: Suggest an idea for this project
|
4
|
-
title: ''
|
5
|
-
labels: ''
|
6
|
-
assignees: ''
|
7
|
-
|
8
|
-
---
|
9
|
-
|
10
|
-
**Your proposal**
|
11
|
-
What is your idea?
|
12
|
-
|
13
|
-
**Additional context**
|
14
|
-
Add any other context or screenshots about the feature request here.
|
@@ -1,9 +0,0 @@
|
|
1
|
-
Thanks for your Pull Request 🎉
|
2
|
-
|
3
|
-
**Please follow these instructions to help us review it more efficiently:**
|
4
|
-
|
5
|
-
- Add references of related issues/PRs in the description if available.
|
6
|
-
- If you're updating the readme file, make sure you followed [the instruction here](https://github.com/ruby/debug/blob/master/CONTRIBUTING.md#to-update-readme).
|
7
|
-
|
8
|
-
## Description
|
9
|
-
Describe your changes:
|
data/.github/workflows/ruby.yml
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
# This workflow uses actions that are not certified by GitHub.
|
2
|
-
# They are provided by a third-party and are governed by
|
3
|
-
# separate terms of service, privacy policy, and support
|
4
|
-
# documentation.
|
5
|
-
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
6
|
-
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
7
|
-
|
8
|
-
name: Ruby
|
9
|
-
|
10
|
-
on:
|
11
|
-
push:
|
12
|
-
branches: [ master ]
|
13
|
-
pull_request:
|
14
|
-
branches: [ master ]
|
15
|
-
|
16
|
-
jobs:
|
17
|
-
test:
|
18
|
-
|
19
|
-
runs-on: ubuntu-latest
|
20
|
-
strategy:
|
21
|
-
matrix:
|
22
|
-
ruby-version: ['2.6', '2.7', '3.0', 'head', 'debug']
|
23
|
-
|
24
|
-
steps:
|
25
|
-
- uses: actions/checkout@v2
|
26
|
-
- name: Set up Ruby
|
27
|
-
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
|
28
|
-
# change this to (see https://github.com/ruby/setup-ruby#versioning):
|
29
|
-
uses: ruby/setup-ruby@v1
|
30
|
-
with:
|
31
|
-
ruby-version: ${{ matrix.ruby-version }}
|
32
|
-
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
33
|
-
- name: Run tests
|
34
|
-
run: bundle exec rake
|
data/.gitignore
DELETED
data/bin/console
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "bundler/setup"
|
4
|
-
require "debug"
|
5
|
-
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
8
|
-
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require "pry"
|
11
|
-
# Pry.start
|
12
|
-
|
13
|
-
require "irb"
|
14
|
-
IRB.start(__FILE__)
|
data/bin/gentest
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'optparse'
|
4
|
-
|
5
|
-
require_relative '../test/tool/test_builder'
|
6
|
-
|
7
|
-
options = {}
|
8
|
-
|
9
|
-
OptionParser.new do |opt|
|
10
|
-
opt.banner = 'Usage: bin/gentest [file] [option]'
|
11
|
-
opt.on('-m METHOD', 'Method name in the test file') do |m|
|
12
|
-
options[:method] = m
|
13
|
-
end
|
14
|
-
opt.on('-c CLASS', 'Class name in the test file') do |c|
|
15
|
-
options[:class] = c
|
16
|
-
end
|
17
|
-
opt.on('--open=FRONTEND', 'Start remote debugging with opening the network port.',
|
18
|
-
'Currently, only vscode is supported.') do |f|
|
19
|
-
options[:open] = f.downcase
|
20
|
-
end
|
21
|
-
opt.parse!(ARGV)
|
22
|
-
end
|
23
|
-
|
24
|
-
exit if ARGV.empty?
|
25
|
-
|
26
|
-
if options[:open] == 'vscode'
|
27
|
-
DEBUGGER__::DAPTestBuilder.new(ARGV, options[:method], options[:class]).start
|
28
|
-
else
|
29
|
-
DEBUGGER__::LocalTestBuilder.new(ARGV, options[:method], options[:class]).start
|
30
|
-
end
|
data/bin/setup
DELETED
data/lib/debug/bp.vim
DELETED
@@ -1,68 +0,0 @@
|
|
1
|
-
let g:rdb_bps = {}
|
2
|
-
|
3
|
-
function SET_BP()
|
4
|
-
let signed = sign_getplaced(bufname(), {'lnum': line('.')})
|
5
|
-
if empty(signed[0]['signs'])
|
6
|
-
call sign_place(0, '', 'signBP', bufname(), {'lnum': line('.')})
|
7
|
-
else
|
8
|
-
"echo signed[0]['signs']
|
9
|
-
call sign_unplace('', {'buffer': bufname(), 'id': signed[0]['signs'][0]['id']})
|
10
|
-
endif
|
11
|
-
endfunction
|
12
|
-
|
13
|
-
function UPDATE_BPS()
|
14
|
-
let signs = sign_getplaced(bufname())
|
15
|
-
let key = expand('%:p')
|
16
|
-
|
17
|
-
if empty(signs[0]['signs'])
|
18
|
-
let removed = remove(g:rdb_bps, key)
|
19
|
-
else
|
20
|
-
let g:rdb_bps[key] = signs[0]['signs']
|
21
|
-
endif
|
22
|
-
endfunction
|
23
|
-
|
24
|
-
function APPLY_BPS()
|
25
|
-
let key = expand('%:p')
|
26
|
-
if has_key(g:rdb_bps, key)
|
27
|
-
for b in g:rdb_bps[key]
|
28
|
-
call sign_place(0, '', 'signBP', bufname(), {'lnum': b['lnum']})
|
29
|
-
endfor
|
30
|
-
endif
|
31
|
-
endfunction
|
32
|
-
|
33
|
-
function WRITE_BPS()
|
34
|
-
call writefile([json_encode(g:rdb_bps)], '.rdb_breakpoints.json')
|
35
|
-
endfunction
|
36
|
-
|
37
|
-
" load
|
38
|
-
try
|
39
|
-
let json = readfile('.rdb_breakpoints.json')
|
40
|
-
let g:rdb_bps = json_decode(json[0])
|
41
|
-
" {"/full/path/to/file1": [{"lnum": 10}, ...], ...}
|
42
|
-
catch /Can't open/
|
43
|
-
let g:rdb_bps = {}
|
44
|
-
catch /Invalid arguments for function json_decode/
|
45
|
-
let g:rdb_bps = {}
|
46
|
-
endtry
|
47
|
-
|
48
|
-
sign define signBP text=BR
|
49
|
-
|
50
|
-
call APPLY_BPS()
|
51
|
-
|
52
|
-
autocmd BufReadPost * call APPLY_BPS()
|
53
|
-
autocmd BufUnload * call UPDATE_BPS()
|
54
|
-
autocmd VimLeave * call WRITE_BPS()
|
55
|
-
|
56
|
-
function! s:ruby_bp_settings() abort
|
57
|
-
echomsg "Type <Space> to toggle break points and <q> to quit"
|
58
|
-
|
59
|
-
if &readonly
|
60
|
-
nnoremap <silent> <buffer> <Space> :call SET_BP()<CR>
|
61
|
-
nnoremap <silent> <buffer> q :<C-u>quit<CR>
|
62
|
-
endif
|
63
|
-
endfunction
|
64
|
-
|
65
|
-
" autocmd FileType ruby call s:ruby_bp_settings()
|
66
|
-
autocmd BufEnter *.rb call s:ruby_bp_settings()
|
67
|
-
|
68
|
-
call s:ruby_bp_settings()
|