byebug 3.2.0 → 3.3.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/.rubocop.yml +3 -0
- data/CHANGELOG.md +125 -99
- data/CONTRIBUTING.md +4 -6
- data/GUIDE.md +42 -20
- data/Gemfile +5 -3
- data/README.md +2 -3
- data/Rakefile +11 -7
- data/bin/byebug +2 -252
- data/byebug.gemspec +7 -4
- data/ext/byebug/byebug.c +17 -18
- data/ext/byebug/byebug.h +4 -5
- data/ext/byebug/context.c +37 -39
- data/ext/byebug/threads.c +39 -18
- data/lib/byebug.rb +2 -110
- data/lib/byebug/attacher.rb +23 -0
- data/lib/byebug/breakpoint.rb +60 -0
- data/lib/byebug/command.rb +62 -70
- data/lib/byebug/commands/break.rb +24 -24
- data/lib/byebug/commands/catchpoint.rb +18 -10
- data/lib/byebug/commands/condition.rb +18 -17
- data/lib/byebug/commands/continue.rb +17 -9
- data/lib/byebug/commands/delete.rb +19 -13
- data/lib/byebug/commands/display.rb +19 -53
- data/lib/byebug/commands/edit.rb +7 -4
- data/lib/byebug/commands/enable_disable.rb +130 -0
- data/lib/byebug/commands/eval.rb +40 -22
- data/lib/byebug/commands/finish.rb +13 -4
- data/lib/byebug/commands/frame.rb +65 -45
- data/lib/byebug/commands/help.rb +17 -18
- data/lib/byebug/commands/history.rb +14 -8
- data/lib/byebug/commands/info.rb +160 -182
- data/lib/byebug/commands/interrupt.rb +4 -1
- data/lib/byebug/commands/irb.rb +30 -0
- data/lib/byebug/commands/kill.rb +7 -8
- data/lib/byebug/commands/list.rb +71 -66
- data/lib/byebug/commands/method.rb +14 -6
- data/lib/byebug/commands/pry.rb +35 -0
- data/lib/byebug/commands/quit.rb +9 -6
- data/lib/byebug/commands/reload.rb +5 -2
- data/lib/byebug/commands/restart.rb +13 -9
- data/lib/byebug/commands/save.rb +17 -17
- data/lib/byebug/commands/set.rb +16 -15
- data/lib/byebug/commands/show.rb +10 -11
- data/lib/byebug/commands/source.rb +11 -5
- data/lib/byebug/commands/stepping.rb +38 -24
- data/lib/byebug/commands/threads.rb +45 -31
- data/lib/byebug/commands/trace.rb +22 -9
- data/lib/byebug/commands/undisplay.rb +45 -0
- data/lib/byebug/commands/variables.rb +83 -27
- data/lib/byebug/context.rb +25 -22
- data/lib/byebug/core.rb +82 -0
- data/lib/byebug/helper.rb +37 -28
- data/lib/byebug/history.rb +8 -4
- data/lib/byebug/interface.rb +12 -17
- data/lib/byebug/interfaces/local_interface.rb +11 -8
- data/lib/byebug/interfaces/remote_interface.rb +11 -8
- data/lib/byebug/interfaces/script_interface.rb +9 -6
- data/lib/byebug/options.rb +46 -0
- data/lib/byebug/processor.rb +7 -1
- data/lib/byebug/processors/command_processor.rb +135 -125
- data/lib/byebug/processors/control_command_processor.rb +23 -23
- data/lib/byebug/remote.rb +17 -26
- data/lib/byebug/runner.rb +100 -0
- data/lib/byebug/setting.rb +33 -8
- data/lib/byebug/settings/autoeval.rb +5 -15
- data/lib/byebug/settings/autoirb.rb +4 -1
- data/lib/byebug/settings/autolist.rb +5 -2
- data/lib/byebug/settings/autoreload.rb +5 -2
- data/lib/byebug/settings/autosave.rb +6 -2
- data/lib/byebug/settings/basename.rb +7 -2
- data/lib/byebug/settings/callstyle.rb +4 -1
- data/lib/byebug/settings/forcestep.rb +6 -3
- data/lib/byebug/settings/fullpath.rb +5 -2
- data/lib/byebug/settings/histfile.rb +5 -3
- data/lib/byebug/settings/histsize.rb +5 -3
- data/lib/byebug/settings/linetrace.rb +4 -1
- data/lib/byebug/settings/listsize.rb +5 -1
- data/lib/byebug/settings/post_mortem.rb +21 -13
- data/lib/byebug/settings/stack_on_error.rb +6 -2
- data/lib/byebug/settings/testing.rb +6 -1
- data/lib/byebug/settings/tracing_plus.rb +5 -1
- data/lib/byebug/settings/verbose.rb +13 -2
- data/lib/byebug/settings/width.rb +4 -1
- data/lib/byebug/version.rb +1 -1
- data/test/{break_test.rb → commands/break_test.rb} +41 -53
- data/test/{condition_test.rb → commands/condition_test.rb} +14 -14
- data/test/{continue_test.rb → commands/continue_test.rb} +0 -0
- data/test/{delete_test.rb → commands/delete_test.rb} +2 -2
- data/test/commands/display_test.rb +37 -0
- data/test/{edit_test.rb → commands/edit_test.rb} +0 -0
- data/test/{eval_test.rb → commands/eval_test.rb} +1 -0
- data/test/{finish_test.rb → commands/finish_test.rb} +11 -1
- data/test/{frame_test.rb → commands/frame_test.rb} +12 -16
- data/test/{help_test.rb → commands/help_test.rb} +21 -4
- data/test/{history_test.rb → commands/history_test.rb} +0 -0
- data/test/{info_test.rb → commands/info_test.rb} +5 -55
- data/test/{interrupt_test.rb → commands/interrupt_test.rb} +0 -0
- data/test/commands/irb_test.rb +28 -0
- data/test/{kill_test.rb → commands/kill_test.rb} +1 -1
- data/test/{list_test.rb → commands/list_test.rb} +1 -1
- data/test/{method_test.rb → commands/method_test.rb} +0 -0
- data/test/{post_mortem_test.rb → commands/post_mortem_test.rb} +6 -10
- data/test/{pry_test.rb → commands/pry_test.rb} +4 -13
- data/test/{quit_test.rb → commands/quit_test.rb} +4 -4
- data/test/{reload_test.rb → commands/reload_test.rb} +0 -0
- data/test/{restart_test.rb → commands/restart_test.rb} +6 -0
- data/test/{save_test.rb → commands/save_test.rb} +2 -2
- data/test/{set_test.rb → commands/set_test.rb} +9 -2
- data/test/{show_test.rb → commands/show_test.rb} +1 -1
- data/test/{source_test.rb → commands/source_test.rb} +3 -3
- data/test/{stepping_test.rb → commands/stepping_test.rb} +44 -35
- data/test/{thread_test.rb → commands/thread_test.rb} +0 -0
- data/test/{trace_test.rb → commands/trace_test.rb} +0 -0
- data/test/{display_test.rb → commands/undisplay_test.rb} +7 -45
- data/test/{variables_test.rb → commands/variables_test.rb} +10 -1
- data/test/debugger_alias_test.rb +2 -2
- data/test/runner_test.rb +127 -0
- data/test/support/matchers.rb +27 -25
- data/test/support/test_interface.rb +9 -5
- data/test/support/utils.rb +96 -101
- data/test/test_helper.rb +32 -20
- metadata +93 -68
- data/lib/byebug/commands/enable.rb +0 -154
- data/lib/byebug/commands/repl.rb +0 -126
- data/test/irb_test.rb +0 -47
- data/test/support/breakpoint.rb +0 -13
@@ -1,154 +0,0 @@
|
|
1
|
-
module Byebug
|
2
|
-
#
|
3
|
-
# Mixin to assist command parsing
|
4
|
-
#
|
5
|
-
module EnableDisableFunctions
|
6
|
-
def enable_disable_breakpoints(is_enable, args)
|
7
|
-
return errmsg "No breakpoints have been set" if Byebug.breakpoints.empty?
|
8
|
-
|
9
|
-
all_breakpoints = Byebug.breakpoints.sort_by {|b| b.id }
|
10
|
-
if args.empty?
|
11
|
-
selected_breakpoints = all_breakpoints
|
12
|
-
else
|
13
|
-
selected_ids = []
|
14
|
-
args.each do |pos|
|
15
|
-
pos = get_int(pos, "#{is_enable} breakpoints", 1, all_breakpoints.last.id)
|
16
|
-
return nil unless pos
|
17
|
-
selected_ids << pos
|
18
|
-
end
|
19
|
-
selected_breakpoints = all_breakpoints.select {
|
20
|
-
|b| selected_ids.include?(b.id) }
|
21
|
-
end
|
22
|
-
|
23
|
-
selected_breakpoints.each do |b|
|
24
|
-
enabled = ('enable' == is_enable)
|
25
|
-
if enabled && !syntax_valid?(b.expr)
|
26
|
-
errmsg "Expression \"#{b.expr}\" syntactically incorrect; " \
|
27
|
-
"breakpoint remains disabled.\n"
|
28
|
-
else
|
29
|
-
b.enabled = enabled
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def enable_disable_display(is_enable, args)
|
35
|
-
if 0 == @state.display.size
|
36
|
-
return errmsg "No display expressions have been set\n"
|
37
|
-
end
|
38
|
-
args.each do |pos|
|
39
|
-
pos = get_int(pos, "#{is_enable} display", 1, @state.display.size)
|
40
|
-
return nil unless pos
|
41
|
-
@state.display[pos-1][0] = ('enable' == is_enable)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
class EnableCommand < Command
|
47
|
-
Subcommands = [
|
48
|
-
['breakpoints', 2, 'Enable breakpoints. This is used to cancel the ' \
|
49
|
-
'effect of the "disable" command. Give breakpoint' \
|
50
|
-
' numbers (separated by spaces) as arguments or ' \
|
51
|
-
'no argument at all if you want to reenable ' \
|
52
|
-
'every breakpoint' ],
|
53
|
-
['display' , 2, 'Enable some expressions to be displayed when ' \
|
54
|
-
'program stops. Arguments are the code numbers of' \
|
55
|
-
' the expressions to resume displaying. Do "info ' \
|
56
|
-
'display" to see the current list of code numbers' ]
|
57
|
-
].map do |name, min, help|
|
58
|
-
Subcmd.new(name, min, help)
|
59
|
-
end unless defined?(Subcommands)
|
60
|
-
|
61
|
-
def regexp
|
62
|
-
/^\s* en(?:able)? (?:\s+(.+))? \s*$/x
|
63
|
-
end
|
64
|
-
|
65
|
-
def execute
|
66
|
-
return errmsg "\"enable\" must be followed by \"display\", " \
|
67
|
-
"\"breakpoints\" or breakpoint ids\n" unless @match[1]
|
68
|
-
|
69
|
-
args = @match[1].split(/[ \t]+/)
|
70
|
-
param = args.shift
|
71
|
-
subcmd = Command.find(Subcommands, param)
|
72
|
-
if subcmd
|
73
|
-
send("enable_#{subcmd.name}", args)
|
74
|
-
else
|
75
|
-
send('enable_breakpoints', args.unshift(param))
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
def enable_breakpoints(args)
|
80
|
-
enable_disable_breakpoints('enable', args)
|
81
|
-
end
|
82
|
-
|
83
|
-
def enable_display(args)
|
84
|
-
enable_disable_display('enable', args)
|
85
|
-
end
|
86
|
-
|
87
|
-
class << self
|
88
|
-
def names
|
89
|
-
%w(enable)
|
90
|
-
end
|
91
|
-
|
92
|
-
def description
|
93
|
-
%{Enable breakpoints or displays.
|
94
|
-
|
95
|
-
This is used to cancel the effect of the "disable" command.}
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
class DisableCommand < Command
|
101
|
-
Subcommands = [
|
102
|
-
['breakpoints', 1, 'Disable breakpoints. A disabled breakpoint is ' \
|
103
|
-
'not forgotten, but has no effect until ' \
|
104
|
-
'reenabled. Give breakpoint numbers (separated by' \
|
105
|
-
'spaces) as arguments or no argument at all if ' \
|
106
|
-
'you want to disable every breakpoint' ],
|
107
|
-
['display' , 1, 'Disable some display expressions when program ' \
|
108
|
-
'stops. Arguments are the code numbers of the ' \
|
109
|
-
'expressions to stop displaying. Do "info ' \
|
110
|
-
'display" to see the current list of code numbers.' ]
|
111
|
-
].map do |name, min, help|
|
112
|
-
Subcmd.new(name, min, help)
|
113
|
-
end unless defined?(Subcommands)
|
114
|
-
|
115
|
-
def regexp
|
116
|
-
/^\s* dis(?:able)? (?:\s+(.+))? \s*$/x
|
117
|
-
end
|
118
|
-
|
119
|
-
def execute
|
120
|
-
return errmsg "\"disable\" must be followed by \"display\", " \
|
121
|
-
"\"breakpoints\" or breakpoint ids\n" unless @match[1]
|
122
|
-
|
123
|
-
args = @match[1].split(/[ \t]+/)
|
124
|
-
param = args.shift
|
125
|
-
subcmd = Command.find(Subcommands, param)
|
126
|
-
if subcmd
|
127
|
-
send("disable_#{subcmd.name}", args)
|
128
|
-
else
|
129
|
-
send('disable_breakpoints', args.unshift(param))
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
def disable_breakpoints(args)
|
134
|
-
enable_disable_breakpoints('disable', args)
|
135
|
-
end
|
136
|
-
|
137
|
-
def disable_display(args)
|
138
|
-
enable_disable_display('disable', args)
|
139
|
-
end
|
140
|
-
|
141
|
-
class << self
|
142
|
-
def names
|
143
|
-
%w(disable)
|
144
|
-
end
|
145
|
-
|
146
|
-
def description
|
147
|
-
%{Disable breakpoints or displays.
|
148
|
-
|
149
|
-
A disabled item is not forgotten, but has no effect until reenabled.
|
150
|
-
Use the "enable" command to have it take effect again.}
|
151
|
-
end
|
152
|
-
end
|
153
|
-
end
|
154
|
-
end
|
data/lib/byebug/commands/repl.rb
DELETED
@@ -1,126 +0,0 @@
|
|
1
|
-
module IRB
|
2
|
-
module ExtendCommand
|
3
|
-
class Continue
|
4
|
-
def self.execute(conf)
|
5
|
-
throw :IRB_EXIT, :cont
|
6
|
-
end
|
7
|
-
end
|
8
|
-
class Next
|
9
|
-
def self.execute(conf)
|
10
|
-
throw :IRB_EXIT, :next
|
11
|
-
end
|
12
|
-
end
|
13
|
-
class Step
|
14
|
-
def self.execute(conf)
|
15
|
-
throw :IRB_EXIT, :step
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
require 'irb'
|
21
|
-
ExtendCommandBundle.def_extend_command 'cont', :Continue
|
22
|
-
ExtendCommandBundle.def_extend_command 'next', :Next
|
23
|
-
ExtendCommandBundle.def_extend_command 'step', :Step
|
24
|
-
|
25
|
-
def self.start_session(binding)
|
26
|
-
unless @__initialized ||= false
|
27
|
-
args = ARGV.dup
|
28
|
-
ARGV.replace([])
|
29
|
-
IRB.setup(nil)
|
30
|
-
ARGV.replace(args)
|
31
|
-
@__initialized = true
|
32
|
-
end
|
33
|
-
|
34
|
-
workspace = WorkSpace.new(binding)
|
35
|
-
irb = Irb.new(workspace)
|
36
|
-
|
37
|
-
@CONF[:IRB_RC].call(irb.context) if @CONF[:IRB_RC]
|
38
|
-
@CONF[:MAIN_CONTEXT] = irb.context
|
39
|
-
|
40
|
-
trap('SIGINT') do
|
41
|
-
irb.signal_handle
|
42
|
-
end
|
43
|
-
|
44
|
-
catch(:IRB_EXIT) do
|
45
|
-
irb.eval_input
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
module Byebug
|
51
|
-
class IrbCommand < Command
|
52
|
-
def regexp
|
53
|
-
/^\s* irb \s*$/x
|
54
|
-
end
|
55
|
-
|
56
|
-
def execute
|
57
|
-
unless @state.interface.kind_of?(LocalInterface)
|
58
|
-
print "Command is available only in local mode.\n"
|
59
|
-
throw :debug_error
|
60
|
-
end
|
61
|
-
|
62
|
-
cont = IRB.start_session(get_binding)
|
63
|
-
case cont
|
64
|
-
when :cont
|
65
|
-
@state.proceed
|
66
|
-
when :step
|
67
|
-
force = Setting[:forcestep]
|
68
|
-
@state.context.step_into 1, force
|
69
|
-
@state.proceed
|
70
|
-
when :next
|
71
|
-
force = Setting[:forcestep]
|
72
|
-
@state.context.step_over 1, @state.frame_pos, force
|
73
|
-
@state.proceed
|
74
|
-
else
|
75
|
-
print @state.location
|
76
|
-
@state.previous_line = nil
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
class << self
|
81
|
-
def names
|
82
|
-
%w(irb)
|
83
|
-
end
|
84
|
-
|
85
|
-
def description
|
86
|
-
%{irb\tstarts an Interactive Ruby (IRB) session.
|
87
|
-
|
88
|
-
IRB is extended with methods "cont", "n" and "step" which run the
|
89
|
-
corresponding byebug commands. In contrast to the real byebug commands
|
90
|
-
these commands don't allow arguments.}
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
begin
|
96
|
-
require 'pry'
|
97
|
-
has_pry = true
|
98
|
-
rescue LoadError
|
99
|
-
has_pry = false
|
100
|
-
end
|
101
|
-
|
102
|
-
class PryCommand < Command
|
103
|
-
def regexp
|
104
|
-
/^\s* pry \s*$/x
|
105
|
-
end
|
106
|
-
|
107
|
-
def execute
|
108
|
-
unless @state.interface.kind_of?(LocalInterface)
|
109
|
-
print "Command is available only in local mode.\n"
|
110
|
-
throw :debug_error
|
111
|
-
end
|
112
|
-
|
113
|
-
get_binding.pry
|
114
|
-
end
|
115
|
-
|
116
|
-
class << self
|
117
|
-
def names
|
118
|
-
%w(pry)
|
119
|
-
end
|
120
|
-
|
121
|
-
def description
|
122
|
-
%{pry\tstarts a Pry session.}
|
123
|
-
end
|
124
|
-
end
|
125
|
-
end if has_pry
|
126
|
-
end
|
data/test/irb_test.rb
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
module Byebug
|
2
|
-
class IrbTestCase < TestCase
|
3
|
-
def setup
|
4
|
-
@example = -> do
|
5
|
-
byebug
|
6
|
-
a = 2
|
7
|
-
a = 3
|
8
|
-
a = 4
|
9
|
-
a = 5
|
10
|
-
a = 6
|
11
|
-
end
|
12
|
-
|
13
|
-
super
|
14
|
-
|
15
|
-
interface.stubs(:kind_of?).with(LocalInterface).returns(true)
|
16
|
-
IRB::Irb.stubs(:new).returns(irb)
|
17
|
-
end
|
18
|
-
|
19
|
-
def irb
|
20
|
-
@irb ||= stub(context: -> {})
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_irb_supports_next_command
|
24
|
-
irb.stubs(:eval_input).throws(:IRB_EXIT, :next)
|
25
|
-
enter 'irb'
|
26
|
-
debug_proc(@example) { assert_equal 7, state.line }
|
27
|
-
end
|
28
|
-
|
29
|
-
def test_irb_supports_step_command
|
30
|
-
irb.stubs(:eval_input).throws(:IRB_EXIT, :step)
|
31
|
-
enter 'irb'
|
32
|
-
debug_proc(@example) { assert_equal 7, state.line }
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_irb_supports_cont_command
|
36
|
-
irb.stubs(:eval_input).throws(:IRB_EXIT, :cont)
|
37
|
-
enter 'break 8', 'irb'
|
38
|
-
debug_proc(@example) { assert_equal 8, state.line }
|
39
|
-
end
|
40
|
-
|
41
|
-
def test_autoirb_calls_irb_automatically_after_every_stop
|
42
|
-
irb.expects(:eval_input)
|
43
|
-
enter 'set autoirb', 'break 8', 'cont'
|
44
|
-
debug_proc(@example)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
data/test/support/breakpoint.rb
DELETED