debug 1.4.0 → 1.9.2
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 +210 -6
- data/Gemfile +2 -0
- data/LICENSE.txt +0 -0
- data/README.md +161 -85
- data/Rakefile +33 -10
- data/TODO.md +8 -8
- data/debug.gemspec +9 -7
- data/exe/rdbg +23 -4
- data/ext/debug/debug.c +111 -21
- data/ext/debug/extconf.rb +23 -0
- data/ext/debug/iseq_collector.c +2 -0
- data/lib/debug/abbrev_command.rb +77 -0
- data/lib/debug/breakpoint.rb +102 -74
- data/lib/debug/client.rb +46 -12
- data/lib/debug/color.rb +0 -0
- data/lib/debug/config.rb +129 -36
- data/lib/debug/console.rb +46 -40
- data/lib/debug/dap_custom/traceInspector.rb +336 -0
- data/lib/debug/frame_info.rb +40 -25
- data/lib/debug/irb_integration.rb +37 -0
- data/lib/debug/local.rb +17 -11
- data/lib/debug/open.rb +0 -0
- data/lib/debug/open_nonstop.rb +0 -0
- data/lib/debug/prelude.rb +3 -2
- data/lib/debug/server.rb +126 -56
- data/lib/debug/server_cdp.rb +673 -248
- data/lib/debug/server_dap.rb +497 -261
- data/lib/debug/session.rb +899 -441
- data/lib/debug/source_repository.rb +122 -49
- data/lib/debug/start.rb +1 -1
- data/lib/debug/thread_client.rb +460 -155
- data/lib/debug/tracer.rb +10 -16
- data/lib/debug/version.rb +1 -1
- data/lib/debug.rb +7 -2
- data/misc/README.md.erb +106 -56
- metadata +14 -24
- 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
@@ -4,72 +4,145 @@ require_relative 'color'
|
|
4
4
|
|
5
5
|
module DEBUGGER__
|
6
6
|
class SourceRepository
|
7
|
-
|
7
|
+
include Color
|
8
8
|
|
9
|
-
def
|
10
|
-
|
9
|
+
def file_src iseq
|
10
|
+
if (path = (iseq.absolute_path || iseq.path)) && File.exist?(path)
|
11
|
+
File.readlines(path, chomp: true)
|
12
|
+
end
|
11
13
|
end
|
12
14
|
|
13
|
-
def
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
def get iseq
|
16
|
+
return unless iseq
|
17
|
+
|
18
|
+
if CONFIG[:show_evaledsrc]
|
19
|
+
orig_src(iseq) || file_src(iseq)
|
20
|
+
else
|
21
|
+
file_src(iseq) || orig_src(iseq)
|
18
22
|
end
|
19
23
|
end
|
20
24
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
}
|
26
|
-
rs
|
27
|
-
end
|
25
|
+
if defined?(RubyVM.keep_script_lines)
|
26
|
+
# Ruby 3.1 and later
|
27
|
+
RubyVM.keep_script_lines = true
|
28
|
+
require 'objspace'
|
28
29
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
30
|
+
def initialize
|
31
|
+
# cache
|
32
|
+
@cmap = ObjectSpace::WeakMap.new
|
33
|
+
@loaded_file_map = {} # path => nil
|
33
34
|
end
|
34
|
-
si = SrcInfo.new(src.lines)
|
35
35
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
36
|
+
def add iseq, src
|
37
|
+
# only manage loaded file names
|
38
|
+
if (path = (iseq.absolute_path || iseq.path)) && File.exist?(path)
|
39
|
+
if @loaded_file_map.has_key? path
|
40
|
+
return path, true # reloaded
|
41
|
+
else
|
42
|
+
@loaded_file_map[path] = path
|
43
|
+
return path, false
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
41
47
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
+
def orig_src iseq
|
49
|
+
lines = iseq.script_lines&.map(&:chomp)
|
50
|
+
line = iseq.first_line
|
51
|
+
if line > 1
|
52
|
+
[*([''] * (line - 1)), *lines]
|
53
|
+
else
|
54
|
+
lines
|
55
|
+
end
|
56
|
+
end
|
48
57
|
|
49
|
-
|
50
|
-
|
58
|
+
def get_colored iseq
|
59
|
+
if lines = @cmap[iseq]
|
60
|
+
lines
|
61
|
+
else
|
62
|
+
if src_lines = get(iseq)
|
63
|
+
@cmap[iseq] = colorize_code(src_lines.join("\n")).lines
|
64
|
+
else
|
65
|
+
nil
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
else
|
70
|
+
# ruby 3.0 or earlier
|
71
|
+
SrcInfo = Struct.new(:src, :colored)
|
51
72
|
|
52
|
-
|
53
|
-
|
54
|
-
elsif @files.has_key?(path = iseq.absolute_path)
|
55
|
-
@files[path]
|
56
|
-
elsif path
|
57
|
-
add_path(path)
|
73
|
+
def initialize
|
74
|
+
@files = {} # filename => SrcInfo
|
58
75
|
end
|
59
|
-
end
|
60
76
|
|
61
|
-
|
62
|
-
|
63
|
-
|
77
|
+
def add iseq, src
|
78
|
+
path = (iseq.absolute_path || iseq.path)
|
79
|
+
|
80
|
+
if path && File.exist?(path)
|
81
|
+
reloaded = @files.has_key? path
|
82
|
+
|
83
|
+
if src
|
84
|
+
add_iseq iseq, src
|
85
|
+
return path, reloaded
|
86
|
+
else
|
87
|
+
add_path path
|
88
|
+
return path, reloaded
|
89
|
+
end
|
90
|
+
else
|
91
|
+
add_iseq iseq, src
|
92
|
+
nil
|
93
|
+
end
|
64
94
|
end
|
65
|
-
end
|
66
95
|
|
67
|
-
|
96
|
+
private def all_iseq iseq, rs = []
|
97
|
+
rs << iseq
|
98
|
+
iseq.each_child{|ci|
|
99
|
+
all_iseq(ci, rs)
|
100
|
+
}
|
101
|
+
rs
|
102
|
+
end
|
103
|
+
|
104
|
+
private def add_iseq iseq, src
|
105
|
+
line = iseq.first_line
|
106
|
+
if line > 1
|
107
|
+
src = ("\n" * (line - 1)) + src
|
108
|
+
end
|
109
|
+
|
110
|
+
si = SrcInfo.new(src.each_line.map{|l| l.chomp})
|
111
|
+
all_iseq(iseq).each{|e|
|
112
|
+
e.instance_variable_set(:@debugger_si, si)
|
113
|
+
e.freeze
|
114
|
+
}
|
115
|
+
end
|
116
|
+
|
117
|
+
private def add_path path
|
118
|
+
src_lines = File.readlines(path, chomp: true)
|
119
|
+
@files[path] = SrcInfo.new(src_lines)
|
120
|
+
rescue SystemCallError
|
121
|
+
end
|
122
|
+
|
123
|
+
private def get_si iseq
|
124
|
+
return unless iseq
|
125
|
+
|
126
|
+
if iseq.instance_variable_defined?(:@debugger_si)
|
127
|
+
iseq.instance_variable_get(:@debugger_si)
|
128
|
+
elsif @files.has_key?(path = (iseq.absolute_path || iseq.path))
|
129
|
+
@files[path]
|
130
|
+
elsif path
|
131
|
+
add_path(path)
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
def orig_src iseq
|
136
|
+
if si = get_si(iseq)
|
137
|
+
si.src
|
138
|
+
end
|
139
|
+
end
|
68
140
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
141
|
+
def get_colored iseq
|
142
|
+
if si = get_si(iseq)
|
143
|
+
si.colored || begin
|
144
|
+
si.colored = colorize_code(si.src.join("\n")).lines
|
145
|
+
end
|
73
146
|
end
|
74
147
|
end
|
75
148
|
end
|
data/lib/debug/start.rb
CHANGED