debug 1.10.0 → 1.11.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/README.md +119 -93
- data/lib/debug/config.rb +38 -36
- data/lib/debug/console.rb +22 -11
- data/lib/debug/frame_info.rb +3 -1
- data/lib/debug/session.rb +15 -7
- data/lib/debug/thread_client.rb +5 -3
- data/lib/debug/version.rb +1 -1
- data/misc/README.md.erb +116 -92
- metadata +4 -5
data/lib/debug/console.rb
CHANGED
@@ -153,21 +153,28 @@ module DEBUGGER__
|
|
153
153
|
end
|
154
154
|
|
155
155
|
def history_file
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
156
|
+
case
|
157
|
+
when (path = CONFIG[:history_file]) && !path.empty?
|
158
|
+
path = File.expand_path(path)
|
159
|
+
when (path = File.expand_path("~/.rdbg_history")) && File.exist?(path) # for compatibility
|
160
|
+
# path
|
160
161
|
else
|
161
|
-
|
162
|
+
state_dir = ENV['XDG_STATE_HOME'] || File.join(Dir.home, '.local', 'state')
|
163
|
+
path = File.join(File.expand_path(state_dir), 'rdbg', 'history')
|
162
164
|
end
|
165
|
+
|
166
|
+
FileUtils.mkdir_p(File.dirname(path)) unless File.exist?(path)
|
167
|
+
path
|
163
168
|
end
|
164
169
|
|
165
170
|
FH = "# Today's OMIKUJI: "
|
166
171
|
|
167
172
|
def read_history_file
|
168
|
-
if history && File.exist?(path = history_file)
|
173
|
+
if history && File.exist?(path = history_file())
|
169
174
|
f = (['', 'DAI-', 'CHU-', 'SHO-'].map{|e| e+'KICHI'}+['KYO']).sample
|
170
|
-
|
175
|
+
# Read history file and scrub invalid characters to prevent encoding errors
|
176
|
+
lines = File.readlines(path).map(&:scrub)
|
177
|
+
["#{FH}#{f}".dup] + lines
|
171
178
|
else
|
172
179
|
[]
|
173
180
|
end
|
@@ -186,15 +193,17 @@ module DEBUGGER__
|
|
186
193
|
def deactivate
|
187
194
|
if history && @init_history_lines
|
188
195
|
added_records = history.to_a[@init_history_lines .. -1]
|
189
|
-
path = history_file
|
196
|
+
path = history_file()
|
190
197
|
max = CONFIG[:save_history]
|
191
198
|
|
192
199
|
if !added_records.empty? && !path.empty?
|
193
200
|
orig_records = read_history_file
|
194
|
-
open(history_file, 'w'){|f|
|
201
|
+
open(history_file(), 'w'){|f|
|
195
202
|
(orig_records + added_records).last(max).each{|line|
|
196
|
-
|
197
|
-
|
203
|
+
# Use scrub to handle encoding issues gracefully
|
204
|
+
scrubbed_line = line.scrub.strip
|
205
|
+
if !line.start_with?(FH) && !scrubbed_line.empty?
|
206
|
+
f.puts scrubbed_line
|
198
207
|
end
|
199
208
|
}
|
200
209
|
}
|
@@ -204,6 +213,8 @@ module DEBUGGER__
|
|
204
213
|
|
205
214
|
def load_history
|
206
215
|
read_history_file.each{|line|
|
216
|
+
# Use scrub to handle encoding issues gracefully, then strip
|
217
|
+
line.scrub!
|
207
218
|
line.strip!
|
208
219
|
history << line unless line.empty?
|
209
220
|
} if history.empty?
|
data/lib/debug/frame_info.rb
CHANGED
@@ -86,7 +86,9 @@ module DEBUGGER__
|
|
86
86
|
|
87
87
|
def block_identifier
|
88
88
|
return unless frame_type == :block
|
89
|
-
|
89
|
+
re_match = location.label.match(BLOCK_LABL_REGEXP)
|
90
|
+
_, level, block_loc = re_match ? re_match.to_a : [nil, nil, location.label]
|
91
|
+
|
90
92
|
[level || "", block_loc]
|
91
93
|
end
|
92
94
|
|
data/lib/debug/session.rb
CHANGED
@@ -931,7 +931,6 @@ module DEBUGGER__
|
|
931
931
|
register_command 'eval', 'call' do |arg|
|
932
932
|
if arg == nil || arg.empty?
|
933
933
|
show_help 'eval'
|
934
|
-
@ui.puts "\nTo evaluate the variable `#{cmd}`, use `pp #{cmd}` instead."
|
935
934
|
:retry
|
936
935
|
else
|
937
936
|
request_eval :call, arg
|
@@ -1144,7 +1143,7 @@ module DEBUGGER__
|
|
1144
1143
|
|
1145
1144
|
def process_command line
|
1146
1145
|
if line.empty?
|
1147
|
-
if @repl_prev_line
|
1146
|
+
if @repl_prev_line && !CONFIG[:no_repeat]
|
1148
1147
|
line = @repl_prev_line
|
1149
1148
|
else
|
1150
1149
|
return :retry
|
@@ -2301,11 +2300,20 @@ module DEBUGGER__
|
|
2301
2300
|
end
|
2302
2301
|
|
2303
2302
|
def self.load_rc
|
2304
|
-
[
|
2305
|
-
|
2306
|
-
|
2307
|
-
|
2308
|
-
|
2303
|
+
rc_file_paths = [
|
2304
|
+
[File.expand_path('~/.rdbgrc'), true],
|
2305
|
+
[File.expand_path('~/.rdbgrc.rb'), true],
|
2306
|
+
# ['./.rdbgrc', true], # disable because of security concern
|
2307
|
+
]
|
2308
|
+
|
2309
|
+
if (xdg_home = ENV["XDG_CONFIG_HOME"])
|
2310
|
+
rc_file_paths << [File.expand_path(File.join(xdg_home, "rdbg", "config")), true]
|
2311
|
+
rc_file_paths << [File.expand_path(File.join(xdg_home, "rdbg", "config.rb")), true]
|
2312
|
+
end
|
2313
|
+
|
2314
|
+
rc_file_paths << [CONFIG[:init_script], false]
|
2315
|
+
|
2316
|
+
rc_file_paths.each{|(path, rc)|
|
2309
2317
|
next unless path
|
2310
2318
|
next if rc && CONFIG[:no_rc] # ignore rc
|
2311
2319
|
|
data/lib/debug/thread_client.rb
CHANGED
@@ -350,6 +350,7 @@ module DEBUGGER__
|
|
350
350
|
next if tp.path.start_with?(__dir__)
|
351
351
|
next if tp.path.start_with?('<internal:trace_point>')
|
352
352
|
next unless File.exist?(tp.path) if CONFIG[:skip_nosrc]
|
353
|
+
next if skip_internal_path?(tp.path)
|
353
354
|
loc = caller_locations(1, 1).first
|
354
355
|
next if skip_location?(loc)
|
355
356
|
next if iter && (iter -= 1) > 0
|
@@ -369,6 +370,7 @@ module DEBUGGER__
|
|
369
370
|
next if tp.path.start_with?(__dir__)
|
370
371
|
next if tp.path.start_with?('<internal:trace_point>')
|
371
372
|
next unless File.exist?(tp.path) if CONFIG[:skip_nosrc]
|
373
|
+
next if skip_internal_path?(tp.path)
|
372
374
|
loc = caller_locations(1, 1).first
|
373
375
|
next if skip_location?(loc)
|
374
376
|
next if iter && (iter -= 1) > 0
|
@@ -1079,13 +1081,13 @@ module DEBUGGER__
|
|
1079
1081
|
when :up
|
1080
1082
|
if @current_frame_index + 1 < @target_frames.size
|
1081
1083
|
@current_frame_index += 1
|
1082
|
-
show_src max_lines:
|
1084
|
+
show_src max_lines: CONFIG[:show_src_lines_frame]
|
1083
1085
|
show_frame(@current_frame_index)
|
1084
1086
|
end
|
1085
1087
|
when :down
|
1086
1088
|
if @current_frame_index > 0
|
1087
1089
|
@current_frame_index -= 1
|
1088
|
-
show_src max_lines:
|
1090
|
+
show_src max_lines: CONFIG[:show_src_lines_frame]
|
1089
1091
|
show_frame(@current_frame_index)
|
1090
1092
|
end
|
1091
1093
|
when :set
|
@@ -1097,7 +1099,7 @@ module DEBUGGER__
|
|
1097
1099
|
puts "out of frame index: #{index}"
|
1098
1100
|
end
|
1099
1101
|
end
|
1100
|
-
show_src max_lines:
|
1102
|
+
show_src max_lines: CONFIG[:show_src_lines_frame]
|
1101
1103
|
show_frame(@current_frame_index)
|
1102
1104
|
else
|
1103
1105
|
raise "unsupported frame operation: #{arg.inspect}"
|
data/lib/debug/version.rb
CHANGED