byebug 9.1.0 → 10.0.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 +5 -5
- data/CHANGELOG.md +24 -3
- data/CONTRIBUTING.md +39 -18
- data/GUIDE.md +16 -17
- data/README.md +64 -52
- data/exe/byebug +6 -0
- data/ext/byebug/breakpoint.c +1 -1
- data/ext/byebug/byebug.c +16 -16
- data/ext/byebug/byebug.h +40 -26
- data/ext/byebug/context.c +26 -26
- data/ext/byebug/extconf.rb +7 -5
- data/ext/byebug/threads.c +8 -8
- data/lib/byebug.rb +3 -1
- data/lib/byebug/attacher.rb +17 -3
- data/lib/byebug/breakpoint.rb +25 -3
- data/lib/byebug/command.rb +20 -14
- data/lib/byebug/command_list.rb +3 -1
- data/lib/byebug/commands.rb +39 -37
- data/lib/byebug/commands/break.rb +33 -15
- data/lib/byebug/commands/catch.rb +16 -14
- data/lib/byebug/commands/condition.rb +11 -9
- data/lib/byebug/commands/continue.rb +9 -7
- data/lib/byebug/commands/debug.rb +7 -5
- data/lib/byebug/commands/delete.rb +11 -9
- data/lib/byebug/commands/disable.rb +8 -6
- data/lib/byebug/commands/disable/breakpoints.rb +7 -5
- data/lib/byebug/commands/disable/display.rb +7 -5
- data/lib/byebug/commands/display.rb +11 -9
- data/lib/byebug/commands/down.rb +10 -8
- data/lib/byebug/commands/edit.rb +10 -8
- data/lib/byebug/commands/enable.rb +8 -6
- data/lib/byebug/commands/enable/breakpoints.rb +7 -5
- data/lib/byebug/commands/enable/display.rb +7 -5
- data/lib/byebug/commands/finish.rb +8 -6
- data/lib/byebug/commands/frame.rb +11 -9
- data/lib/byebug/commands/help.rb +7 -5
- data/lib/byebug/commands/history.rb +7 -5
- data/lib/byebug/commands/info.rb +11 -9
- data/lib/byebug/commands/info/breakpoints.rb +17 -11
- data/lib/byebug/commands/info/display.rb +16 -7
- data/lib/byebug/commands/info/file.rb +12 -10
- data/lib/byebug/commands/info/line.rb +5 -3
- data/lib/byebug/commands/info/program.rb +8 -6
- data/lib/byebug/commands/interrupt.rb +8 -4
- data/lib/byebug/commands/irb.rb +9 -7
- data/lib/byebug/commands/kill.rb +9 -7
- data/lib/byebug/commands/list.rb +41 -46
- data/lib/byebug/commands/method.rb +10 -8
- data/lib/byebug/commands/next.rb +8 -6
- data/lib/byebug/commands/pry.rb +10 -8
- data/lib/byebug/commands/quit.rb +7 -5
- data/lib/byebug/commands/restart.rb +13 -11
- data/lib/byebug/commands/save.rb +9 -7
- data/lib/byebug/commands/set.rb +12 -10
- data/lib/byebug/commands/show.rb +7 -5
- data/lib/byebug/commands/source.rb +7 -5
- data/lib/byebug/commands/step.rb +8 -6
- data/lib/byebug/commands/thread.rb +11 -9
- data/lib/byebug/commands/thread/current.rb +6 -4
- data/lib/byebug/commands/thread/list.rb +7 -5
- data/lib/byebug/commands/thread/resume.rb +7 -5
- data/lib/byebug/commands/thread/stop.rb +6 -4
- data/lib/byebug/commands/thread/switch.rb +6 -4
- data/lib/byebug/commands/tracevar.rb +10 -8
- data/lib/byebug/commands/undisplay.rb +10 -8
- data/lib/byebug/commands/untracevar.rb +8 -6
- data/lib/byebug/commands/up.rb +10 -8
- data/lib/byebug/commands/var.rb +12 -10
- data/lib/byebug/commands/var/all.rb +7 -5
- data/lib/byebug/commands/var/args.rb +6 -4
- data/lib/byebug/commands/var/const.rb +9 -7
- data/lib/byebug/commands/var/global.rb +5 -3
- data/lib/byebug/commands/var/instance.rb +6 -4
- data/lib/byebug/commands/var/local.rb +6 -4
- data/lib/byebug/commands/where.rb +9 -7
- data/lib/byebug/context.rb +7 -5
- data/lib/byebug/core.rb +25 -25
- data/lib/byebug/errors.rb +4 -2
- data/lib/byebug/frame.rb +16 -16
- data/lib/byebug/helpers/bin.rb +28 -7
- data/lib/byebug/helpers/eval.rb +8 -6
- data/lib/byebug/helpers/file.rb +4 -2
- data/lib/byebug/helpers/frame.rb +5 -3
- data/lib/byebug/helpers/parse.rb +5 -3
- data/lib/byebug/helpers/path.rb +7 -5
- data/lib/byebug/helpers/reflection.rb +2 -0
- data/lib/byebug/helpers/string.rb +4 -2
- data/lib/byebug/helpers/thread.rb +10 -8
- data/lib/byebug/helpers/toggle.rb +10 -8
- data/lib/byebug/helpers/var.rb +8 -6
- data/lib/byebug/history.rb +7 -5
- data/lib/byebug/interface.rb +13 -11
- data/lib/byebug/interfaces/local_interface.rb +4 -4
- data/lib/byebug/interfaces/remote_interface.rb +21 -9
- data/lib/byebug/interfaces/script_interface.rb +2 -0
- data/lib/byebug/interfaces/test_interface.rb +5 -3
- data/lib/byebug/option_setter.rb +14 -12
- data/lib/byebug/printers/base.rb +6 -6
- data/lib/byebug/printers/plain.rb +8 -6
- data/lib/byebug/printers/texts/base.yml +3 -3
- data/lib/byebug/processors/command_processor.rb +11 -12
- data/lib/byebug/processors/control_processor.rb +4 -6
- data/lib/byebug/processors/post_mortem_processor.rb +4 -2
- data/lib/byebug/processors/script_processor.rb +7 -3
- data/lib/byebug/remote.rb +45 -65
- data/lib/byebug/remote/client.rb +55 -0
- data/lib/byebug/remote/server.rb +47 -0
- data/lib/byebug/runner.rb +26 -19
- data/lib/byebug/setting.rb +10 -4
- data/lib/byebug/settings/autoirb.rb +5 -3
- data/lib/byebug/settings/autolist.rb +5 -3
- data/lib/byebug/settings/autopry.rb +5 -3
- data/lib/byebug/settings/autosave.rb +4 -2
- data/lib/byebug/settings/basename.rb +4 -2
- data/lib/byebug/settings/callstyle.rb +3 -3
- data/lib/byebug/settings/fullpath.rb +4 -2
- data/lib/byebug/settings/histfile.rb +5 -3
- data/lib/byebug/settings/histsize.rb +4 -2
- data/lib/byebug/settings/linetrace.rb +4 -2
- data/lib/byebug/settings/listsize.rb +4 -2
- data/lib/byebug/settings/post_mortem.rb +4 -2
- data/lib/byebug/settings/savefile.rb +4 -2
- data/lib/byebug/settings/stack_on_error.rb +4 -2
- data/lib/byebug/settings/width.rb +3 -1
- data/lib/byebug/source_file_formatter.rb +71 -0
- data/lib/byebug/subcommands.rb +6 -4
- data/lib/byebug/version.rb +1 -1
- metadata +8 -5
- data/bin/byebug +0 -9
data/lib/byebug.rb
CHANGED
data/lib/byebug/attacher.rb
CHANGED
@@ -1,13 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
#
|
2
4
|
# Main Container for all of Byebug's code
|
3
5
|
#
|
4
6
|
module Byebug
|
5
7
|
#
|
6
|
-
#
|
7
|
-
# events occur. Before entering byebug the init script is read.
|
8
|
+
# Starts byebug, and stops at the first line of user's code.
|
8
9
|
#
|
9
10
|
def self.attach
|
10
|
-
require
|
11
|
+
require "byebug/core"
|
11
12
|
|
12
13
|
unless started?
|
13
14
|
self.mode = :attached
|
@@ -18,6 +19,13 @@ module Byebug
|
|
18
19
|
|
19
20
|
current_context.step_out(3, true)
|
20
21
|
end
|
22
|
+
|
23
|
+
def self.spawn(host = "localhost", port = nil)
|
24
|
+
require "byebug/core"
|
25
|
+
|
26
|
+
self.wait_connection = true
|
27
|
+
start_server(host, port || PORT)
|
28
|
+
end
|
21
29
|
end
|
22
30
|
|
23
31
|
#
|
@@ -30,5 +38,11 @@ module Kernel
|
|
30
38
|
Byebug.attach
|
31
39
|
end
|
32
40
|
|
41
|
+
def remote_byebug(host = "localhost", port = nil)
|
42
|
+
Byebug.spawn(host, port)
|
43
|
+
|
44
|
+
Byebug.attach
|
45
|
+
end
|
46
|
+
|
33
47
|
alias debugger byebug
|
34
48
|
end
|
data/lib/byebug/breakpoint.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Byebug
|
2
4
|
#
|
3
5
|
# Implements breakpoints
|
@@ -49,12 +51,30 @@ module Byebug
|
|
49
51
|
#
|
50
52
|
def self.potential_lines(filename)
|
51
53
|
name = "#{Time.new.to_i}_#{rand(2**31)}"
|
52
|
-
lines = {}
|
53
54
|
iseq = RubyVM::InstructionSequence.compile(File.read(filename), name)
|
54
55
|
|
56
|
+
if iseq.respond_to?(:each_child)
|
57
|
+
potential_lines_with_trace_points(iseq, {})
|
58
|
+
else
|
59
|
+
potential_lines_without_trace_points(iseq, {})
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.potential_lines_with_trace_points(iseq, lines)
|
64
|
+
iseq.trace_points.each { |(line, _)| lines[line] = true }
|
65
|
+
iseq.each_child do |child|
|
66
|
+
potential_lines_with_trace_points(child, lines)
|
67
|
+
end
|
68
|
+
|
69
|
+
lines.keys.sort
|
70
|
+
end
|
71
|
+
|
72
|
+
private_class_method :potential_lines_with_trace_points
|
73
|
+
|
74
|
+
def self.potential_lines_without_trace_points(iseq, lines)
|
55
75
|
iseq.disasm.each_line do |line|
|
56
76
|
res = /^\d+ (?<insn>\w+)\s+.+\(\s*(?<lineno>\d+)\)$/.match(line)
|
57
|
-
next unless res && res[:insn] ==
|
77
|
+
next unless res && res[:insn] == "trace"
|
58
78
|
|
59
79
|
lines[res[:lineno].to_i] = true
|
60
80
|
end
|
@@ -62,6 +82,8 @@ module Byebug
|
|
62
82
|
lines.keys
|
63
83
|
end
|
64
84
|
|
85
|
+
private_class_method :potential_lines_without_trace_points
|
86
|
+
|
65
87
|
#
|
66
88
|
# Returns true if a breakpoint could be set in line number +lineno+ in file
|
67
89
|
# name +filename.
|
@@ -82,7 +104,7 @@ module Byebug
|
|
82
104
|
#
|
83
105
|
def inspect
|
84
106
|
meths = %w[id pos source expr hit_condition hit_count hit_value enabled?]
|
85
|
-
values = meths.map { |field| "#{field}: #{send(field)}" }.join(
|
107
|
+
values = meths.map { |field| "#{field}: #{send(field)}" }.join(", ")
|
86
108
|
"#<Byebug::Breakpoint #{values}>"
|
87
109
|
end
|
88
110
|
end
|
data/lib/byebug/command.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "forwardable"
|
4
|
+
require "byebug/helpers/string"
|
3
5
|
|
4
6
|
module Byebug
|
5
7
|
#
|
@@ -16,11 +18,11 @@ module Byebug
|
|
16
18
|
# end
|
17
19
|
#
|
18
20
|
# def self.description
|
19
|
-
#
|
21
|
+
# "Custom long desc"
|
20
22
|
# end
|
21
23
|
#
|
22
24
|
# def.short_description
|
23
|
-
#
|
25
|
+
# "Custom short desc"
|
24
26
|
# end
|
25
27
|
#
|
26
28
|
# def execute
|
@@ -47,16 +49,16 @@ module Byebug
|
|
47
49
|
end
|
48
50
|
|
49
51
|
def arguments
|
50
|
-
@match[0].split(
|
52
|
+
@match[0].split(" ").drop(1).join(" ")
|
51
53
|
end
|
52
54
|
|
53
|
-
def_delegators
|
55
|
+
def_delegators "self.class", :help, :match
|
54
56
|
|
55
|
-
def_delegator
|
56
|
-
def_delegator
|
57
|
-
def_delegator
|
57
|
+
def_delegator "processor.printer", :print, :pr
|
58
|
+
def_delegator "processor.printer", :print_collection, :prc
|
59
|
+
def_delegator "processor.printer", :print_variables, :prv
|
58
60
|
|
59
|
-
def_delegators
|
61
|
+
def_delegators "processor.interface", :errmsg, :puts, :print, :confirm
|
60
62
|
|
61
63
|
class << self
|
62
64
|
include Helpers::StringHelper
|
@@ -77,14 +79,18 @@ module Byebug
|
|
77
79
|
#
|
78
80
|
def to_s
|
79
81
|
name
|
80
|
-
.split(
|
81
|
-
.map { |n| n.gsub(/Command$/,
|
82
|
+
.split("::")
|
83
|
+
.map { |n| n.gsub(/Command$/, "").downcase if n =~ /Command$/ }
|
82
84
|
.compact
|
83
|
-
.join(
|
85
|
+
.join(" ")
|
84
86
|
end
|
85
87
|
|
86
88
|
def columnize(width)
|
87
|
-
format(
|
89
|
+
format(
|
90
|
+
" %-<name>#{width}s -- %<description>s\n",
|
91
|
+
name: to_s,
|
92
|
+
description: short_description
|
93
|
+
)
|
88
94
|
end
|
89
95
|
|
90
96
|
#
|
data/lib/byebug/command_list.rb
CHANGED
data/lib/byebug/commands.rb
CHANGED
@@ -1,37 +1,39 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
11
|
-
require
|
12
|
-
require
|
13
|
-
require
|
14
|
-
require
|
15
|
-
require
|
16
|
-
require
|
17
|
-
require
|
18
|
-
require
|
19
|
-
require
|
20
|
-
require
|
21
|
-
require
|
22
|
-
require
|
23
|
-
require
|
24
|
-
require
|
25
|
-
require
|
26
|
-
require
|
27
|
-
require
|
28
|
-
require
|
29
|
-
require
|
30
|
-
require
|
31
|
-
require
|
32
|
-
require
|
33
|
-
require
|
34
|
-
require
|
35
|
-
require
|
36
|
-
require
|
37
|
-
require
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "byebug/commands/break"
|
4
|
+
require "byebug/commands/catch"
|
5
|
+
require "byebug/commands/condition"
|
6
|
+
require "byebug/commands/continue"
|
7
|
+
require "byebug/commands/debug"
|
8
|
+
require "byebug/commands/delete"
|
9
|
+
require "byebug/commands/disable"
|
10
|
+
require "byebug/commands/display"
|
11
|
+
require "byebug/commands/down"
|
12
|
+
require "byebug/commands/edit"
|
13
|
+
require "byebug/commands/enable"
|
14
|
+
require "byebug/commands/finish"
|
15
|
+
require "byebug/commands/frame"
|
16
|
+
require "byebug/commands/help"
|
17
|
+
require "byebug/commands/history"
|
18
|
+
require "byebug/commands/info"
|
19
|
+
require "byebug/commands/interrupt"
|
20
|
+
require "byebug/commands/irb"
|
21
|
+
require "byebug/commands/kill"
|
22
|
+
require "byebug/commands/list"
|
23
|
+
require "byebug/commands/method"
|
24
|
+
require "byebug/commands/next"
|
25
|
+
require "byebug/commands/pry"
|
26
|
+
require "byebug/commands/quit"
|
27
|
+
require "byebug/commands/restart"
|
28
|
+
require "byebug/commands/save"
|
29
|
+
require "byebug/commands/set"
|
30
|
+
require "byebug/commands/show"
|
31
|
+
require "byebug/commands/source"
|
32
|
+
require "byebug/commands/step"
|
33
|
+
require "byebug/commands/thread"
|
34
|
+
require "byebug/commands/tracevar"
|
35
|
+
require "byebug/commands/undisplay"
|
36
|
+
require "byebug/commands/untracevar"
|
37
|
+
require "byebug/commands/up"
|
38
|
+
require "byebug/commands/var"
|
39
|
+
require "byebug/commands/where"
|
@@ -1,7 +1,10 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require
|
4
|
-
require
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "byebug/command"
|
4
|
+
require "byebug/helpers/eval"
|
5
|
+
require "byebug/helpers/file"
|
6
|
+
require "byebug/helpers/parse"
|
7
|
+
require "byebug/source_file_formatter"
|
5
8
|
|
6
9
|
module Byebug
|
7
10
|
#
|
@@ -19,7 +22,7 @@ module Byebug
|
|
19
22
|
end
|
20
23
|
|
21
24
|
def self.description
|
22
|
-
<<-
|
25
|
+
<<-DESCRIPTION
|
23
26
|
b[reak] [file:]line [if expr]
|
24
27
|
b[reak] [module::...]class(.|#)method [if expr]
|
25
28
|
|
@@ -27,24 +30,24 @@ module Byebug
|
|
27
30
|
for conditionally enabled breakpoints.
|
28
31
|
|
29
32
|
#{short_description}
|
30
|
-
|
33
|
+
DESCRIPTION
|
31
34
|
end
|
32
35
|
|
33
36
|
def self.short_description
|
34
|
-
|
37
|
+
"Sets breakpoints in the source code"
|
35
38
|
end
|
36
39
|
|
37
40
|
def execute
|
38
41
|
return puts(help) unless @match[1]
|
39
42
|
|
40
43
|
b = line_breakpoint(@match[1]) || method_breakpoint(@match[1])
|
41
|
-
return errmsg(pr(
|
44
|
+
return errmsg(pr("break.errors.location")) unless b
|
42
45
|
|
43
46
|
if syntax_valid?(@match[2])
|
44
|
-
return puts(pr(
|
47
|
+
return puts(pr("break.created", id: b.id, file: b.source, line: b.pos))
|
45
48
|
end
|
46
49
|
|
47
|
-
errmsg(pr(
|
50
|
+
errmsg(pr("break.errors.expression", expr: @match[2]))
|
48
51
|
b.enabled = false
|
49
52
|
end
|
50
53
|
|
@@ -74,25 +77,40 @@ module Byebug
|
|
74
77
|
k = error_eval(str)
|
75
78
|
|
76
79
|
k && k.is_a?(Module) ? k.name : str
|
77
|
-
rescue
|
78
|
-
errmsg(
|
80
|
+
rescue StandardError
|
81
|
+
errmsg("Warning: breakpoint source is not yet defined")
|
79
82
|
str
|
80
83
|
end
|
81
84
|
|
82
85
|
def add_line_breakpoint(file, line)
|
83
|
-
raise(pr(
|
86
|
+
raise(pr("break.errors.source", file: file)) unless File.exist?(file)
|
84
87
|
|
85
88
|
fullpath = File.realpath(file)
|
86
89
|
|
87
90
|
if line > n_lines(file)
|
88
|
-
raise(pr(
|
91
|
+
raise(pr("break.errors.far_line", lines: n_lines(file), file: fullpath))
|
89
92
|
end
|
90
93
|
|
91
94
|
unless Breakpoint.potential_line?(fullpath, line)
|
92
|
-
|
95
|
+
msg = pr(
|
96
|
+
"break.errors.line",
|
97
|
+
file: fullpath,
|
98
|
+
line: line,
|
99
|
+
valid_breakpoints: valid_breakpoints_for(fullpath, line)
|
100
|
+
)
|
101
|
+
|
102
|
+
raise(msg)
|
93
103
|
end
|
94
104
|
|
95
105
|
Breakpoint.add(fullpath, line, @match[2])
|
96
106
|
end
|
107
|
+
|
108
|
+
def valid_breakpoints_for(path, line)
|
109
|
+
potential_lines = Breakpoint.potential_lines(path)
|
110
|
+
annotator = ->(n) { potential_lines.include?(n) ? "[B]" : " " }
|
111
|
+
source_file_formatter = SourceFileFormatter.new(path, annotator)
|
112
|
+
|
113
|
+
source_file_formatter.lines_around(line).join.chomp
|
114
|
+
end
|
97
115
|
end
|
98
116
|
end
|
@@ -1,5 +1,7 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "byebug/command"
|
4
|
+
require "byebug/helpers/eval"
|
3
5
|
|
4
6
|
module Byebug
|
5
7
|
#
|
@@ -17,7 +19,7 @@ module Byebug
|
|
17
19
|
end
|
18
20
|
|
19
21
|
def self.description
|
20
|
-
<<-
|
22
|
+
<<-DESCRIPTION
|
21
23
|
cat[ch][ (off|<exception>[ off])]
|
22
24
|
|
23
25
|
#{short_description}
|
@@ -26,19 +28,19 @@ module Byebug
|
|
26
28
|
catch off -- deletes all catchpoints
|
27
29
|
catch <exception> -- enables handling <exception>
|
28
30
|
catch <exception> off -- disables handling <exception>
|
29
|
-
|
31
|
+
DESCRIPTION
|
30
32
|
end
|
31
33
|
|
32
34
|
def self.short_description
|
33
|
-
|
35
|
+
"Handles exception catchpoints"
|
34
36
|
end
|
35
37
|
|
36
38
|
def execute
|
37
39
|
return info unless @match[1]
|
38
40
|
|
39
|
-
return @match[1] ==
|
41
|
+
return @match[1] == "off" ? clear : add(@match[1]) unless @match[2]
|
40
42
|
|
41
|
-
return errmsg pr(
|
43
|
+
return errmsg pr("catch.errors.off", off: cmd) unless @match[2] == "off"
|
42
44
|
|
43
45
|
remove(@match[1])
|
44
46
|
end
|
@@ -47,33 +49,33 @@ module Byebug
|
|
47
49
|
|
48
50
|
def remove(exception)
|
49
51
|
unless Byebug.catchpoints.member?(exception)
|
50
|
-
return errmsg pr(
|
52
|
+
return errmsg pr("catch.errors.not_found", exception: exception)
|
51
53
|
end
|
52
54
|
|
53
|
-
puts pr(
|
55
|
+
puts pr("catch.removed", exception: exception)
|
54
56
|
Byebug.catchpoints.delete(exception)
|
55
57
|
end
|
56
58
|
|
57
59
|
def add(exception)
|
58
60
|
if warning_eval(exception.is_a?(Class).to_s)
|
59
|
-
errmsg pr(
|
61
|
+
errmsg pr("catch.errors.not_class", class: exception)
|
60
62
|
end
|
61
63
|
|
62
|
-
puts pr(
|
64
|
+
puts pr("catch.added", exception: exception)
|
63
65
|
Byebug.add_catchpoint(exception)
|
64
66
|
end
|
65
67
|
|
66
68
|
def clear
|
67
|
-
Byebug.catchpoints.clear if confirm(pr(
|
69
|
+
Byebug.catchpoints.clear if confirm(pr("catch.confirmations.delete_all"))
|
68
70
|
end
|
69
71
|
|
70
72
|
def info
|
71
73
|
if Byebug.catchpoints && !Byebug.catchpoints.empty?
|
72
|
-
Byebug.catchpoints.
|
74
|
+
Byebug.catchpoints.each_key do |exception|
|
73
75
|
puts("#{exception}: #{exception.is_a?(Class)}")
|
74
76
|
end
|
75
77
|
else
|
76
|
-
puts
|
78
|
+
puts "No exceptions set to be caught."
|
77
79
|
end
|
78
80
|
end
|
79
81
|
end
|
@@ -1,5 +1,7 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "byebug/command"
|
4
|
+
require "byebug/helpers/parse"
|
3
5
|
|
4
6
|
module Byebug
|
5
7
|
#
|
@@ -17,7 +19,7 @@ module Byebug
|
|
17
19
|
end
|
18
20
|
|
19
21
|
def self.description
|
20
|
-
<<-
|
22
|
+
<<-DESCRIPTION
|
21
23
|
cond[ition] <n>[ expr]
|
22
24
|
|
23
25
|
#{short_description}
|
@@ -26,27 +28,27 @@ module Byebug
|
|
26
28
|
an integer and <expr> is an expression to be evaluated whenever
|
27
29
|
breakpoint <n> is reached. If no expression is specified, the condition
|
28
30
|
is removed.
|
29
|
-
|
31
|
+
DESCRIPTION
|
30
32
|
end
|
31
33
|
|
32
34
|
def self.short_description
|
33
|
-
|
35
|
+
"Sets conditions on breakpoints"
|
34
36
|
end
|
35
37
|
|
36
38
|
def execute
|
37
39
|
return puts(help) unless @match[1]
|
38
40
|
|
39
41
|
breakpoints = Byebug.breakpoints.sort_by(&:id)
|
40
|
-
return errmsg(pr(
|
42
|
+
return errmsg(pr("condition.errors.no_breakpoints")) if breakpoints.empty?
|
41
43
|
|
42
|
-
pos, err = get_int(@match[1],
|
44
|
+
pos, err = get_int(@match[1], "Condition", 1)
|
43
45
|
return errmsg(err) if err
|
44
46
|
|
45
47
|
breakpoint = breakpoints.find { |b| b.id == pos }
|
46
|
-
return errmsg(pr(
|
48
|
+
return errmsg(pr("break.errors.no_breakpoint")) unless breakpoint
|
47
49
|
|
48
50
|
unless syntax_valid?(@match[2])
|
49
|
-
return errmsg(pr(
|
51
|
+
return errmsg(pr("break.errors.not_changed", expr: @match[2]))
|
50
52
|
end
|
51
53
|
|
52
54
|
breakpoint.expr = @match[2]
|