byebug 4.0.5 → 5.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 +4 -4
- data/CHANGELOG.md +72 -34
- data/CONTRIBUTING.md +26 -31
- data/README.md +3 -3
- data/lib/byebug/breakpoint.rb +2 -1
- data/lib/byebug/command.rb +27 -49
- data/lib/byebug/commands/break.rb +21 -15
- data/lib/byebug/commands/catch.rb +9 -15
- data/lib/byebug/commands/condition.rb +12 -15
- data/lib/byebug/commands/continue.rb +8 -11
- data/lib/byebug/commands/delete.rb +9 -12
- data/lib/byebug/commands/disable.rb +32 -0
- data/lib/byebug/commands/disable/breakpoints.rb +38 -0
- data/lib/byebug/commands/disable/display.rb +39 -0
- data/lib/byebug/commands/display.rb +18 -51
- data/lib/byebug/commands/down.rb +39 -0
- data/lib/byebug/commands/edit.rb +8 -14
- data/lib/byebug/commands/enable.rb +25 -0
- data/lib/byebug/commands/enable/breakpoints.rb +38 -0
- data/lib/byebug/commands/enable/display.rb +39 -0
- data/lib/byebug/commands/eval.rb +10 -192
- data/lib/byebug/commands/finish.rb +11 -12
- data/lib/byebug/commands/frame.rb +17 -182
- data/lib/byebug/commands/help.rb +18 -18
- data/lib/byebug/commands/history.rb +9 -10
- data/lib/byebug/commands/info.rb +17 -190
- data/lib/byebug/commands/info/args.rb +39 -0
- data/lib/byebug/commands/info/breakpoints.rb +59 -0
- data/lib/byebug/commands/info/catch.rb +39 -0
- data/lib/byebug/commands/info/display.rb +42 -0
- data/lib/byebug/commands/info/file.rb +81 -0
- data/lib/byebug/commands/info/line.rb +31 -0
- data/lib/byebug/commands/info/program.rb +51 -0
- data/lib/byebug/commands/interrupt.rb +5 -9
- data/lib/byebug/commands/irb.rb +5 -9
- data/lib/byebug/commands/kill.rb +6 -12
- data/lib/byebug/commands/list.rb +47 -19
- data/lib/byebug/commands/method.rb +8 -14
- data/lib/byebug/commands/next.rb +36 -0
- data/lib/byebug/commands/pp.rb +41 -0
- data/lib/byebug/commands/pry.rb +5 -9
- data/lib/byebug/commands/ps.rb +44 -0
- data/lib/byebug/commands/putl.rb +43 -0
- data/lib/byebug/commands/quit.rb +8 -12
- data/lib/byebug/commands/restart.rb +6 -12
- data/lib/byebug/commands/save.rb +30 -39
- data/lib/byebug/commands/set.rb +19 -21
- data/lib/byebug/commands/show.rb +10 -16
- data/lib/byebug/commands/source.rb +6 -12
- data/lib/byebug/commands/step.rb +36 -0
- data/lib/byebug/commands/thread.rb +13 -130
- data/lib/byebug/commands/thread/current.rb +35 -0
- data/lib/byebug/commands/thread/list.rb +41 -0
- data/lib/byebug/commands/thread/resume.rb +45 -0
- data/lib/byebug/commands/thread/stop.rb +41 -0
- data/lib/byebug/commands/thread/switch.rb +43 -0
- data/lib/byebug/commands/tracevar.rb +8 -14
- data/lib/byebug/commands/undisplay.rb +12 -15
- data/lib/byebug/commands/untracevar.rb +5 -11
- data/lib/byebug/commands/up.rb +39 -0
- data/lib/byebug/commands/var.rb +15 -94
- data/lib/byebug/commands/var/all.rb +37 -0
- data/lib/byebug/commands/var/const.rb +38 -0
- data/lib/byebug/commands/var/global.rb +33 -0
- data/lib/byebug/commands/var/instance.rb +35 -0
- data/lib/byebug/commands/var/local.rb +35 -0
- data/lib/byebug/commands/where.rb +47 -0
- data/lib/byebug/core.rb +10 -0
- data/lib/byebug/helpers/eval.rb +47 -0
- data/lib/byebug/helpers/file.rb +46 -0
- data/lib/byebug/helpers/frame.rb +76 -0
- data/lib/byebug/helpers/parse.rb +74 -0
- data/lib/byebug/helpers/string.rb +24 -0
- data/lib/byebug/helpers/thread.rb +53 -0
- data/lib/byebug/helpers/toggle.rb +56 -0
- data/lib/byebug/helpers/var.rb +45 -0
- data/lib/byebug/history.rb +2 -4
- data/lib/byebug/interface.rb +5 -3
- data/lib/byebug/interfaces/local_interface.rb +3 -1
- data/lib/byebug/interfaces/remote_interface.rb +3 -1
- data/lib/byebug/interfaces/test_interface.rb +6 -2
- data/lib/byebug/printers/plain.rb +1 -1
- data/lib/byebug/processors/command_processor.rb +9 -11
- data/lib/byebug/processors/control_command_processor.rb +1 -1
- data/lib/byebug/remote.rb +3 -0
- data/lib/byebug/runner.rb +5 -3
- data/lib/byebug/setting.rb +2 -18
- data/lib/byebug/settings/savefile.rb +21 -0
- data/lib/byebug/states/regular_state.rb +15 -6
- data/lib/byebug/subcommand_list.rb +33 -0
- data/lib/byebug/subcommands.rb +53 -0
- data/lib/byebug/version.rb +1 -1
- metadata +45 -6
- data/lib/byebug/commands/enable_disable.rb +0 -132
- data/lib/byebug/commands/stepping.rb +0 -75
- data/lib/byebug/helper.rb +0 -131
@@ -0,0 +1,42 @@
|
|
1
|
+
module Byebug
|
2
|
+
#
|
3
|
+
# Reopens the +info+ command to define the +display+ subcommand
|
4
|
+
#
|
5
|
+
class InfoCommand < Command
|
6
|
+
#
|
7
|
+
# Information about display expressions
|
8
|
+
#
|
9
|
+
class DisplaySubcommand < Command
|
10
|
+
def regexp
|
11
|
+
/^\s* d(?:isplay)? \s*$/x
|
12
|
+
end
|
13
|
+
|
14
|
+
def execute
|
15
|
+
display = @state.display
|
16
|
+
|
17
|
+
unless display.find { |d| d[0] }
|
18
|
+
return puts('There are no auto-display expressions now.')
|
19
|
+
end
|
20
|
+
|
21
|
+
puts 'Auto-display expressions now in effect:'
|
22
|
+
puts 'Num Enb Expression'
|
23
|
+
|
24
|
+
display.each_with_index do |d, i|
|
25
|
+
puts(format('%3d: %s %s', i + 1, d[0] ? 'y' : 'n', d[1]))
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def short_description
|
30
|
+
'List of expressions to display when program stops'
|
31
|
+
end
|
32
|
+
|
33
|
+
def description
|
34
|
+
<<-EOD
|
35
|
+
inf[o] d[display]
|
36
|
+
|
37
|
+
#{short_description}
|
38
|
+
EOD
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'byebug/helpers/file'
|
2
|
+
|
3
|
+
module Byebug
|
4
|
+
#
|
5
|
+
# Reopens the +info+ command to define the +file+ subcommand
|
6
|
+
#
|
7
|
+
class InfoCommand < Command
|
8
|
+
#
|
9
|
+
# Information about a particular source file
|
10
|
+
#
|
11
|
+
class FileSubcommand < Command
|
12
|
+
include Helpers::FileHelper
|
13
|
+
|
14
|
+
def regexp
|
15
|
+
/^\s* f(?:ile)? (?:\s+ (\S+))? \s*$/x
|
16
|
+
end
|
17
|
+
|
18
|
+
def execute
|
19
|
+
file = @match[1] || @state.file
|
20
|
+
unless File.exist?(file)
|
21
|
+
return errmsg(pr('info.errors.undefined_file', file: file))
|
22
|
+
end
|
23
|
+
|
24
|
+
puts <<-EOC.gsub(/^ {6}/, '')
|
25
|
+
|
26
|
+
File #{info_file_basic(file)}
|
27
|
+
|
28
|
+
Breakpoint line numbers:
|
29
|
+
#{info_file_breakpoints(file)}
|
30
|
+
|
31
|
+
Modification time: #{info_file_mtime(file)}
|
32
|
+
|
33
|
+
Sha1 Signature: #{info_file_sha1(file)}
|
34
|
+
|
35
|
+
EOC
|
36
|
+
end
|
37
|
+
|
38
|
+
def short_description
|
39
|
+
'Information about a particular source file.'
|
40
|
+
end
|
41
|
+
|
42
|
+
def description
|
43
|
+
<<-EOD
|
44
|
+
inf[o] f[ile]
|
45
|
+
|
46
|
+
#{short_description}
|
47
|
+
|
48
|
+
It informs about file name, number of lines, possible breakpoints in
|
49
|
+
the file, last modification time and sha1 digest.
|
50
|
+
EOD
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def info_file_basic(file)
|
56
|
+
path = File.expand_path(file)
|
57
|
+
return unless File.exist?(path)
|
58
|
+
|
59
|
+
s = n_lines(path) == 1 ? '' : 's'
|
60
|
+
"#{path} (#{n_lines(path)} line#{s})"
|
61
|
+
end
|
62
|
+
|
63
|
+
def info_file_breakpoints(file)
|
64
|
+
breakpoints = Breakpoint.potential_lines(file)
|
65
|
+
return unless breakpoints
|
66
|
+
|
67
|
+
breakpoints.to_a.sort.columnize(line_prefix: ' ',
|
68
|
+
displaywidth: Setting[:width])
|
69
|
+
end
|
70
|
+
|
71
|
+
def info_file_mtime(file)
|
72
|
+
File.stat(file).mtime
|
73
|
+
end
|
74
|
+
|
75
|
+
def info_file_sha1(file)
|
76
|
+
require 'digest/sha1'
|
77
|
+
Digest::SHA1.hexdigest(file)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Byebug
|
2
|
+
#
|
3
|
+
# Reopens the +info+ command to define the +line+ subcommand
|
4
|
+
#
|
5
|
+
class InfoCommand < Command
|
6
|
+
#
|
7
|
+
# Information about current location
|
8
|
+
#
|
9
|
+
class LineSubcommand < Command
|
10
|
+
def regexp
|
11
|
+
/^\s* l(?:ine)? \s*$/x
|
12
|
+
end
|
13
|
+
|
14
|
+
def execute
|
15
|
+
puts "Line #{@state.line} of \"#{@state.file}\""
|
16
|
+
end
|
17
|
+
|
18
|
+
def short_description
|
19
|
+
'Line number and file name of current position in source file.'
|
20
|
+
end
|
21
|
+
|
22
|
+
def description
|
23
|
+
<<-EOD
|
24
|
+
inf[o] l[ine]
|
25
|
+
|
26
|
+
#{short_description}
|
27
|
+
EOD
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module Byebug
|
2
|
+
#
|
3
|
+
# Reopens the +info+ command to define the +args+ subcommand
|
4
|
+
#
|
5
|
+
class InfoCommand < Command
|
6
|
+
#
|
7
|
+
# Information about arguments of the current method/block
|
8
|
+
#
|
9
|
+
class ProgramSubcommand < Command
|
10
|
+
def regexp
|
11
|
+
/^\s* p(?:rogram)? \s*$/x
|
12
|
+
end
|
13
|
+
|
14
|
+
def execute
|
15
|
+
if @state.context.dead?
|
16
|
+
puts 'The program crashed.'
|
17
|
+
excpt = Byebug.last_exception
|
18
|
+
return puts("Exception: #{excpt.inspect}") if excpt
|
19
|
+
end
|
20
|
+
|
21
|
+
puts 'Program stopped. '
|
22
|
+
format_stop_reason @state.context.stop_reason
|
23
|
+
end
|
24
|
+
|
25
|
+
def short_description
|
26
|
+
'Information about the current status of the debugged program.'
|
27
|
+
end
|
28
|
+
|
29
|
+
def description
|
30
|
+
<<-EOD
|
31
|
+
inf[o] p[rogram]
|
32
|
+
|
33
|
+
#{short_description}
|
34
|
+
EOD
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def format_stop_reason(stop_reason)
|
40
|
+
case stop_reason
|
41
|
+
when :step
|
42
|
+
puts "It stopped after stepping, next'ing or initial start."
|
43
|
+
when :breakpoint
|
44
|
+
puts 'It stopped at a breakpoint.'
|
45
|
+
when :catchpoint
|
46
|
+
puts 'It stopped at a catchpoint.'
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -17,16 +17,12 @@ module Byebug
|
|
17
17
|
context.interrupt
|
18
18
|
end
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
end
|
20
|
+
def description
|
21
|
+
<<-EOD
|
22
|
+
i[nterrupt]
|
24
23
|
|
25
|
-
|
26
|
-
|
27
|
-
i[nterrupt] Interrupts the program.
|
28
|
-
EOD
|
29
|
-
end
|
24
|
+
Interrupts the program.
|
25
|
+
EOD
|
30
26
|
end
|
31
27
|
end
|
32
28
|
end
|
data/lib/byebug/commands/irb.rb
CHANGED
@@ -18,16 +18,12 @@ module Byebug
|
|
18
18
|
IRB.start(__FILE__)
|
19
19
|
end
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
end
|
21
|
+
def description
|
22
|
+
<<-EOD
|
23
|
+
irb
|
25
24
|
|
26
|
-
|
27
|
-
|
28
|
-
irb Starts an Interactive Ruby (IRB) session.
|
29
|
-
EOD
|
30
|
-
end
|
25
|
+
Starts an Interactive Ruby (IRB) session.
|
26
|
+
EOD
|
31
27
|
end
|
32
28
|
end
|
33
29
|
end
|
data/lib/byebug/commands/kill.rb
CHANGED
@@ -27,19 +27,13 @@ module Byebug
|
|
27
27
|
Process.kill(signame, Process.pid)
|
28
28
|
end
|
29
29
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
end
|
34
|
-
|
35
|
-
def description
|
36
|
-
prettify <<-EOD
|
37
|
-
kill[ SIGNAL]
|
30
|
+
def description
|
31
|
+
<<-EOD
|
32
|
+
kill[ signal]
|
38
33
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
end
|
34
|
+
Send [signal] to Process.pid
|
35
|
+
Equivalent of Process.kill(Process.pid)
|
36
|
+
EOD
|
43
37
|
end
|
44
38
|
end
|
45
39
|
end
|
data/lib/byebug/commands/list.rb
CHANGED
@@ -1,10 +1,15 @@
|
|
1
1
|
require 'byebug/command'
|
2
|
+
require 'byebug/helpers/file'
|
3
|
+
require 'byebug/helpers/parse'
|
2
4
|
|
3
5
|
module Byebug
|
4
6
|
#
|
5
7
|
# List parts of the source code.
|
6
8
|
#
|
7
9
|
class ListCommand < Command
|
10
|
+
include Helpers::FileHelper
|
11
|
+
include Helpers::ParseHelper
|
12
|
+
|
8
13
|
def regexp
|
9
14
|
/^\s* l(?:ist)? (?:\s*([-=])|\s+(\S+))? \s*$/x
|
10
15
|
end
|
@@ -23,22 +28,16 @@ module Byebug
|
|
23
28
|
@state.prev_line = b
|
24
29
|
end
|
25
30
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
end
|
30
|
-
|
31
|
-
def description
|
32
|
-
prettify <<-EOD
|
33
|
-
l[ist][[-=]][ nn-mm]
|
31
|
+
def description
|
32
|
+
<<-EOD
|
33
|
+
l[ist][[-=]][ nn-mm]
|
34
34
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
end
|
35
|
+
Lists lines of code forward from current line or from the place where
|
36
|
+
code was last listed. If "list-" is specified, lists backwards instead.
|
37
|
+
If "list=" is specified, lists from current line regardless of where
|
38
|
+
code was last listed. A line range can also be specified to list
|
39
|
+
specific sections of code.
|
40
|
+
EOD
|
42
41
|
end
|
43
42
|
|
44
43
|
private
|
@@ -78,11 +77,11 @@ module Byebug
|
|
78
77
|
end
|
79
78
|
|
80
79
|
def parse_range(input, size, max_line)
|
81
|
-
first, err = get_int(input
|
80
|
+
first, err = get_int(lower_bound(input), 'List', 1, max_line)
|
82
81
|
return [-1, -1] if err
|
83
82
|
|
84
|
-
if input
|
85
|
-
last,
|
83
|
+
if upper_bound(input)
|
84
|
+
last, = get_int(upper_bound(input), 'List', 1, max_line)
|
86
85
|
return [-1, -1] unless last
|
87
86
|
|
88
87
|
last = amend(last, max_line)
|
@@ -116,12 +115,41 @@ module Byebug
|
|
116
115
|
puts "\n[#{min}, #{max}] in #{@state.file}"
|
117
116
|
|
118
117
|
File.foreach(@state.file).with_index do |line, lineno|
|
119
|
-
|
118
|
+
break if lineno + 1 > max
|
120
119
|
next unless (min..max).include?(lineno + 1)
|
121
120
|
|
122
121
|
mark = lineno + 1 == @state.line ? '=> ' : ' '
|
123
122
|
puts format("#{mark}%#{max.to_s.size}d: %s", lineno + 1, line)
|
124
123
|
end
|
125
124
|
end
|
125
|
+
|
126
|
+
private
|
127
|
+
|
128
|
+
#
|
129
|
+
# @param range [String] A string with an integer range format
|
130
|
+
#
|
131
|
+
# @return [String] The lower bound of the given range
|
132
|
+
#
|
133
|
+
def lower_bound(range)
|
134
|
+
split_range(range)[0]
|
135
|
+
end
|
136
|
+
|
137
|
+
#
|
138
|
+
# @param range [String] A string with an integer range format
|
139
|
+
#
|
140
|
+
# @return [String] The upper bound of the given range
|
141
|
+
#
|
142
|
+
def upper_bound(range)
|
143
|
+
split_range(range)[1]
|
144
|
+
end
|
145
|
+
|
146
|
+
#
|
147
|
+
# @param range [String] A string with an integer range format
|
148
|
+
#
|
149
|
+
# @return [Array] The upper & lower bounds of the given range
|
150
|
+
#
|
151
|
+
def split_range(str)
|
152
|
+
str.split(/[-,]/)
|
153
|
+
end
|
126
154
|
end
|
127
155
|
end
|
@@ -26,22 +26,16 @@ module Byebug
|
|
26
26
|
puts result
|
27
27
|
end
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
end
|
29
|
+
def description
|
30
|
+
<<-EOD
|
31
|
+
m[ethod] (i[nstance][ <obj>]|<class|module>)
|
33
32
|
|
34
|
-
|
35
|
-
|
36
|
-
m[ethod] (i[nstance][ <obj>]|<class|module>)
|
33
|
+
When invoked with "instance", shows instance methods of the object
|
34
|
+
specified as argument or of self no object was specified.
|
37
35
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
When invoked only with a class or module, shows class methods of the
|
42
|
-
class or module specified as argument.
|
43
|
-
EOD
|
44
|
-
end
|
36
|
+
When invoked only with a class or module, shows class methods of the
|
37
|
+
class or module specified as argument.
|
38
|
+
EOD
|
45
39
|
end
|
46
40
|
end
|
47
41
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'byebug/command'
|
2
|
+
require 'byebug/helpers/parse'
|
3
|
+
|
4
|
+
module Byebug
|
5
|
+
#
|
6
|
+
# Implements the next functionality.
|
7
|
+
#
|
8
|
+
# Allows the user the continue execution until the next instruction in the
|
9
|
+
# current frame.
|
10
|
+
#
|
11
|
+
class NextCommand < Command
|
12
|
+
include Helpers::ParseHelper
|
13
|
+
|
14
|
+
self.allow_in_post_mortem = false
|
15
|
+
|
16
|
+
def regexp
|
17
|
+
/^\s* n(?:ext)? (?:\s+(\S+))? \s*$/x
|
18
|
+
end
|
19
|
+
|
20
|
+
def execute
|
21
|
+
steps, err = parse_steps(@match[1], 'Next')
|
22
|
+
return errmsg(err) unless steps
|
23
|
+
|
24
|
+
@state.context.step_over(steps, @state.frame)
|
25
|
+
@state.proceed
|
26
|
+
end
|
27
|
+
|
28
|
+
def description
|
29
|
+
<<-EOD
|
30
|
+
n[ext][ nnn]
|
31
|
+
|
32
|
+
Steps over once or nnn times.
|
33
|
+
EOD
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|