byebug 5.0.0 → 6.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +26 -1
- data/CONTRIBUTING.md +35 -13
- data/GUIDE.md +256 -198
- data/README.md +5 -11
- data/ext/byebug/byebug.c +5 -43
- data/ext/byebug/byebug.h +6 -1
- data/ext/byebug/context.c +4 -5
- data/lib/byebug/command.rb +64 -64
- data/lib/byebug/command_list.rb +32 -0
- data/lib/byebug/commands.rb +37 -0
- data/lib/byebug/commands/break.rb +45 -37
- data/lib/byebug/commands/catch.rb +52 -28
- data/lib/byebug/commands/condition.rb +19 -13
- data/lib/byebug/commands/continue.rb +15 -11
- data/lib/byebug/commands/delete.rb +18 -12
- data/lib/byebug/commands/disable.rb +9 -10
- data/lib/byebug/commands/disable/breakpoints.rb +13 -11
- data/lib/byebug/commands/disable/display.rb +13 -11
- data/lib/byebug/commands/display.rb +32 -24
- data/lib/byebug/commands/down.rb +18 -14
- data/lib/byebug/commands/edit.rb +42 -26
- data/lib/byebug/commands/enable.rb +9 -3
- data/lib/byebug/commands/enable/breakpoints.rb +13 -11
- data/lib/byebug/commands/enable/display.rb +13 -11
- data/lib/byebug/commands/finish.rb +23 -14
- data/lib/byebug/commands/frame.rb +21 -18
- data/lib/byebug/commands/help.rb +39 -16
- data/lib/byebug/commands/history.rb +16 -10
- data/lib/byebug/commands/info.rb +8 -5
- data/lib/byebug/commands/info/breakpoints.rb +16 -14
- data/lib/byebug/commands/info/display.rb +18 -18
- data/lib/byebug/commands/info/file.rb +22 -22
- data/lib/byebug/commands/info/line.rb +13 -11
- data/lib/byebug/commands/info/program.rb +13 -17
- data/lib/byebug/commands/interrupt.rb +13 -11
- data/lib/byebug/commands/irb.rb +16 -10
- data/lib/byebug/commands/kill.rb +19 -13
- data/lib/byebug/commands/list.rb +35 -24
- data/lib/byebug/commands/method.rb +25 -15
- data/lib/byebug/commands/next.rb +15 -13
- data/lib/byebug/commands/pry.rb +18 -11
- data/lib/byebug/commands/ps.rb +21 -23
- data/lib/byebug/commands/quit.rb +17 -11
- data/lib/byebug/commands/restart.rb +28 -24
- data/lib/byebug/commands/save.rb +23 -15
- data/lib/byebug/commands/set.rb +26 -19
- data/lib/byebug/commands/show.rb +20 -14
- data/lib/byebug/commands/source.rb +15 -14
- data/lib/byebug/commands/step.rb +15 -13
- data/lib/byebug/commands/thread.rb +8 -4
- data/lib/byebug/commands/thread/current.rb +11 -11
- data/lib/byebug/commands/thread/list.rb +14 -14
- data/lib/byebug/commands/thread/resume.rb +14 -14
- data/lib/byebug/commands/thread/stop.rb +14 -14
- data/lib/byebug/commands/thread/switch.rb +15 -14
- data/lib/byebug/commands/tracevar.rb +20 -16
- data/lib/byebug/commands/undisplay.rb +22 -18
- data/lib/byebug/commands/untracevar.rb +13 -11
- data/lib/byebug/commands/up.rb +18 -14
- data/lib/byebug/commands/var.rb +10 -3
- data/lib/byebug/commands/var/all.rb +15 -13
- data/lib/byebug/commands/var/args.rb +37 -0
- data/lib/byebug/commands/var/const.rb +25 -14
- data/lib/byebug/commands/var/global.rb +13 -11
- data/lib/byebug/commands/var/instance.rb +13 -11
- data/lib/byebug/commands/var/local.rb +13 -11
- data/lib/byebug/commands/where.rb +15 -11
- data/lib/byebug/context.rb +71 -73
- data/lib/byebug/core.rb +45 -26
- data/lib/byebug/errors.rb +27 -0
- data/lib/byebug/frame.rb +181 -0
- data/lib/byebug/helpers/eval.rb +67 -26
- data/lib/byebug/helpers/file.rb +18 -3
- data/lib/byebug/helpers/frame.rb +36 -39
- data/lib/byebug/helpers/parse.rb +15 -13
- data/lib/byebug/helpers/path.rb +21 -0
- data/lib/byebug/helpers/reflection.rb +17 -0
- data/lib/byebug/helpers/thread.rb +20 -14
- data/lib/byebug/helpers/toggle.rb +10 -5
- data/lib/byebug/helpers/var.rb +36 -15
- data/lib/byebug/interface.rb +27 -9
- data/lib/byebug/option_setter.rb +93 -0
- data/lib/byebug/printers/base.rb +3 -0
- data/lib/byebug/printers/plain.rb +4 -14
- data/lib/byebug/printers/texts/base.yml +2 -7
- data/lib/byebug/processors/command_processor.rb +101 -102
- data/lib/byebug/processors/control_processor.rb +20 -0
- data/lib/byebug/processors/post_mortem_processor.rb +16 -0
- data/lib/byebug/processors/script_processor.rb +49 -0
- data/lib/byebug/remote.rb +13 -7
- data/lib/byebug/runner.rb +39 -65
- data/lib/byebug/setting.rb +4 -1
- data/lib/byebug/settings/post_mortem.rb +0 -16
- data/lib/byebug/settings/savefile.rb +1 -4
- data/lib/byebug/subcommands.rb +27 -29
- data/lib/byebug/version.rb +4 -1
- metadata +14 -29
- data/lib/byebug/commands/eval.rb +0 -43
- data/lib/byebug/commands/info/args.rb +0 -39
- data/lib/byebug/commands/info/catch.rb +0 -39
- data/lib/byebug/commands/pp.rb +0 -41
- data/lib/byebug/commands/putl.rb +0 -43
- data/lib/byebug/processor.rb +0 -43
- data/lib/byebug/processors/control_command_processor.rb +0 -48
- data/lib/byebug/settings/verbose.rb +0 -20
- data/lib/byebug/state.rb +0 -12
- data/lib/byebug/states/control_state.rb +0 -26
- data/lib/byebug/states/regular_state.rb +0 -187
- data/lib/byebug/subcommand_list.rb +0 -33
data/lib/byebug/commands/down.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
require 'pathname'
|
4
2
|
require 'byebug/command'
|
5
3
|
require 'byebug/helpers/frame'
|
@@ -13,27 +11,33 @@ module Byebug
|
|
13
11
|
include Helpers::FrameHelper
|
14
12
|
include Helpers::ParseHelper
|
15
13
|
|
16
|
-
|
17
|
-
/^\s* down (?:\s+(\S+))? \s*$/x
|
18
|
-
end
|
14
|
+
self.allow_in_post_mortem = true
|
19
15
|
|
20
|
-
def
|
21
|
-
|
22
|
-
return errmsg(err) unless pos
|
23
|
-
|
24
|
-
adjust_frame(-pos, false)
|
25
|
-
|
26
|
-
ListCommand.new(@state).execute if Setting[:autolist]
|
16
|
+
def self.regexp
|
17
|
+
/^\s* down (?:\s+(\S+))? \s*$/x
|
27
18
|
end
|
28
19
|
|
29
|
-
def description
|
20
|
+
def self.description
|
30
21
|
<<-EOD
|
31
22
|
down[ count]
|
32
23
|
|
33
|
-
|
24
|
+
#{short_description}
|
34
25
|
|
35
26
|
Use the "bt" command to find out where you want to go.
|
36
27
|
EOD
|
37
28
|
end
|
29
|
+
|
30
|
+
def self.short_description
|
31
|
+
'Moves to a lower frame in the stack trace'
|
32
|
+
end
|
33
|
+
|
34
|
+
def execute
|
35
|
+
pos, err = parse_steps(@match[1], 'Down')
|
36
|
+
return errmsg(err) unless pos
|
37
|
+
|
38
|
+
jump_frames(-pos)
|
39
|
+
|
40
|
+
ListCommand.new(processor).execute if Setting[:autolist]
|
41
|
+
end
|
38
42
|
end
|
39
43
|
end
|
data/lib/byebug/commands/edit.rb
CHANGED
@@ -6,45 +6,61 @@ module Byebug
|
|
6
6
|
#
|
7
7
|
class EditCommand < Command
|
8
8
|
self.allow_in_control = true
|
9
|
+
self.allow_in_post_mortem = true
|
9
10
|
|
10
|
-
def regexp
|
11
|
+
def self.regexp
|
11
12
|
/^\s* ed(?:it)? (?:\s+(\S+))? \s*$/x
|
12
13
|
end
|
13
14
|
|
14
|
-
def
|
15
|
-
|
16
|
-
|
17
|
-
file = @state.file
|
18
|
-
line = @state.line if @state.line
|
19
|
-
elsif (@pos_match = /([^:]+)[:]([0-9]+)/.match(@match[1]))
|
20
|
-
file, line = @pos_match.captures
|
21
|
-
else
|
22
|
-
file = @match[1]
|
23
|
-
end
|
15
|
+
def self.description
|
16
|
+
<<-EOD
|
17
|
+
edit[ file:lineno]
|
24
18
|
|
25
|
-
|
26
|
-
file = File.expand_path(file)
|
19
|
+
#{short_description}
|
27
20
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
21
|
+
With no argumnt, edits file containing most re line listed. Editing
|
22
|
+
targets can also be specified to start editing at a specific line in a
|
23
|
+
specific file
|
24
|
+
EOD
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.short_description
|
28
|
+
'Edits source files'
|
29
|
+
end
|
30
|
+
|
31
|
+
def execute
|
32
|
+
file, line = location(@match[1])
|
33
|
+
return edit_error('not_exist', file) unless File.exist?(file)
|
34
|
+
return edit_error('not_readable', file) unless File.readable?(file)
|
34
35
|
|
35
36
|
cmd = line ? "#{editor} +#{line} #{file}" : "#{editor} #{file}"
|
36
37
|
|
37
38
|
system(cmd)
|
38
39
|
end
|
39
40
|
|
40
|
-
|
41
|
-
<<-EOD
|
42
|
-
edit[ file:lineno] Edit specified files.
|
41
|
+
private
|
43
42
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
43
|
+
def location(matched)
|
44
|
+
if matched.nil?
|
45
|
+
file = frame.file
|
46
|
+
return errmsg(pr('edit.errors.state')) unless file
|
47
|
+
line = frame.line
|
48
|
+
elsif (@pos_match = /([^:]+)[:]([0-9]+)/.match(matched))
|
49
|
+
file, line = @pos_match.captures
|
50
|
+
else
|
51
|
+
file = matched
|
52
|
+
line = nil
|
53
|
+
end
|
54
|
+
|
55
|
+
[File.expand_path(file), line]
|
56
|
+
end
|
57
|
+
|
58
|
+
def editor
|
59
|
+
ENV['EDITOR'] || 'vim'
|
60
|
+
end
|
61
|
+
|
62
|
+
def edit_error(type, file)
|
63
|
+
errmsg(pr("edit.errors.#{type}", file: file))
|
48
64
|
end
|
49
65
|
end
|
50
66
|
end
|
@@ -10,16 +10,22 @@ module Byebug
|
|
10
10
|
class EnableCommand < Command
|
11
11
|
include Subcommands
|
12
12
|
|
13
|
-
|
13
|
+
self.allow_in_post_mortem = true
|
14
|
+
|
15
|
+
def self.regexp
|
14
16
|
/^\s* en(?:able)? (?:\s+ (.+))? \s*$/x
|
15
17
|
end
|
16
18
|
|
17
|
-
def description
|
19
|
+
def self.description
|
18
20
|
<<-EOD
|
19
21
|
en[able][[ b[reakpoints]| d[isplay])][ n1[ n2[ ...[ nn]]]]]
|
20
22
|
|
21
|
-
|
23
|
+
#{short_description}
|
22
24
|
EOD
|
23
25
|
end
|
26
|
+
|
27
|
+
def self.short_description
|
28
|
+
'Enables breakpoints or displays'
|
29
|
+
end
|
24
30
|
end
|
25
31
|
end
|
@@ -8,22 +8,16 @@ module Byebug
|
|
8
8
|
#
|
9
9
|
# Enables all or specific breakpoints
|
10
10
|
#
|
11
|
-
class
|
11
|
+
class BreakpointsCommand < Command
|
12
12
|
include Helpers::ToggleHelper
|
13
13
|
|
14
|
-
|
15
|
-
/^\s* b(?:reakpoints)? (?:\s+ (.+))? \s*$/x
|
16
|
-
end
|
17
|
-
|
18
|
-
def execute
|
19
|
-
enable_disable_breakpoints('enable', @match[1])
|
20
|
-
end
|
14
|
+
self.allow_in_post_mortem = true
|
21
15
|
|
22
|
-
def
|
23
|
-
|
16
|
+
def self.regexp
|
17
|
+
/^\s* b(?:reakpoints)? (?:\s+ (.+))? \s*$/x
|
24
18
|
end
|
25
19
|
|
26
|
-
def description
|
20
|
+
def self.description
|
27
21
|
<<-EOD
|
28
22
|
en[able] b[reakpoints][ <ids>]
|
29
23
|
|
@@ -33,6 +27,14 @@ module Byebug
|
|
33
27
|
argument at all if you want to enable every breakpoint.
|
34
28
|
EOD
|
35
29
|
end
|
30
|
+
|
31
|
+
def self.short_description
|
32
|
+
'Disable all or specific breakpoints'
|
33
|
+
end
|
34
|
+
|
35
|
+
def execute
|
36
|
+
enable_disable_breakpoints('enable', @match[1])
|
37
|
+
end
|
36
38
|
end
|
37
39
|
end
|
38
40
|
end
|
@@ -8,22 +8,16 @@ module Byebug
|
|
8
8
|
#
|
9
9
|
# Enables all or specific displays
|
10
10
|
#
|
11
|
-
class
|
11
|
+
class DisplayCommand < Command
|
12
12
|
include Helpers::ToggleHelper
|
13
13
|
|
14
|
-
|
15
|
-
/^\s* d(?:isplay)? (?:\s+ (.+))? \s*$/x
|
16
|
-
end
|
17
|
-
|
18
|
-
def execute
|
19
|
-
enable_disable_display('enable', @match[1])
|
20
|
-
end
|
14
|
+
self.allow_in_post_mortem = true
|
21
15
|
|
22
|
-
def
|
23
|
-
|
16
|
+
def self.regexp
|
17
|
+
/^\s* d(?:isplay)? (?:\s+ (.+))? \s*$/x
|
24
18
|
end
|
25
19
|
|
26
|
-
def description
|
20
|
+
def self.description
|
27
21
|
<<-EOD
|
28
22
|
en[able] d[isplay][ <id1> <id2> .. <idn>]
|
29
23
|
|
@@ -34,6 +28,14 @@ module Byebug
|
|
34
28
|
specified, all displays are enabled.
|
35
29
|
EOD
|
36
30
|
end
|
31
|
+
|
32
|
+
def self.short_description
|
33
|
+
'Enables expressions to be displayed when program stops.'
|
34
|
+
end
|
35
|
+
|
36
|
+
def execute
|
37
|
+
enable_disable_display('enable', @match[1])
|
38
|
+
end
|
37
39
|
end
|
38
40
|
end
|
39
41
|
end
|
@@ -12,12 +12,27 @@ module Byebug
|
|
12
12
|
|
13
13
|
self.allow_in_post_mortem = false
|
14
14
|
|
15
|
-
def regexp
|
15
|
+
def self.regexp
|
16
16
|
/^\s* fin(?:ish)? (?:\s+(\S+))? \s*$/x
|
17
17
|
end
|
18
18
|
|
19
|
+
def self.description
|
20
|
+
<<-EOD
|
21
|
+
fin[ish][ n_frames]
|
22
|
+
|
23
|
+
#{short_description}
|
24
|
+
|
25
|
+
If no number is given, we run until the current frame returns. If a
|
26
|
+
number of frames `n_frames` is given, then we run until `n_frames`
|
27
|
+
return from the current position.
|
28
|
+
EOD
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.short_description
|
32
|
+
'Runs the program until frame returns'
|
33
|
+
end
|
34
|
+
|
19
35
|
def execute
|
20
|
-
max_frames = @state.context.stack_size - @state.frame
|
21
36
|
if @match[1]
|
22
37
|
n_frames, err = get_int(@match[1], 'finish', 0, max_frames - 1)
|
23
38
|
return errmsg(err) unless n_frames
|
@@ -26,21 +41,15 @@ module Byebug
|
|
26
41
|
end
|
27
42
|
|
28
43
|
force = n_frames == 0 ? true : false
|
29
|
-
|
30
|
-
|
31
|
-
|
44
|
+
context.step_out(context.frame.pos + n_frames, force)
|
45
|
+
context.frame = 0
|
46
|
+
processor.proceed!
|
32
47
|
end
|
33
48
|
|
34
|
-
|
35
|
-
<<-EOD
|
36
|
-
fin[ish][ n_frames]
|
37
|
-
|
38
|
-
Execute until frame returns.
|
49
|
+
private
|
39
50
|
|
40
|
-
|
41
|
-
|
42
|
-
return from the current position.
|
43
|
-
EOD
|
51
|
+
def max_frames
|
52
|
+
context.stack_size - context.frame.pos
|
44
53
|
end
|
45
54
|
end
|
46
55
|
end
|
@@ -1,5 +1,3 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
require 'pathname'
|
4
2
|
require 'byebug/command'
|
5
3
|
require 'byebug/helpers/frame'
|
@@ -13,28 +11,20 @@ module Byebug
|
|
13
11
|
include Helpers::FrameHelper
|
14
12
|
include Helpers::ParseHelper
|
15
13
|
|
16
|
-
|
17
|
-
/^\s* f(?:rame)? (?:\s+(\S+))? \s*$/x
|
18
|
-
end
|
19
|
-
|
20
|
-
def execute
|
21
|
-
unless @match[1]
|
22
|
-
print(pr('frame.line', get_pr_arguments(@state.frame)))
|
23
|
-
return
|
24
|
-
end
|
25
|
-
|
26
|
-
pos, err = get_int(@match[1], 'Frame')
|
27
|
-
return errmsg(err) unless pos
|
14
|
+
self.allow_in_post_mortem = true
|
28
15
|
|
29
|
-
|
16
|
+
def self.regexp
|
17
|
+
/^\s* f(?:rame)? (?:\s+(\S+))? \s*$/x
|
30
18
|
end
|
31
19
|
|
32
|
-
def description
|
20
|
+
def self.description
|
33
21
|
<<-EOD
|
34
22
|
f[rame][ frame-number]
|
35
23
|
|
36
|
-
|
37
|
-
|
24
|
+
#{short_description}
|
25
|
+
|
26
|
+
If a frame number has been specified, to moves to that frame. Otherwise
|
27
|
+
it moves to the newest frame.
|
38
28
|
|
39
29
|
A negative number indicates position from the other end, so "frame -1"
|
40
30
|
moves to the oldest frame, and "frame 0" moves to the newest frame.
|
@@ -46,5 +36,18 @@ module Byebug
|
|
46
36
|
Use the "bt" command to find out where you want to go.
|
47
37
|
EOD
|
48
38
|
end
|
39
|
+
|
40
|
+
def self.short_description
|
41
|
+
'Moves to a frame in the call stack'
|
42
|
+
end
|
43
|
+
|
44
|
+
def execute
|
45
|
+
return print(pr('frame.line', context.frame.to_hash)) unless @match[1]
|
46
|
+
|
47
|
+
pos, err = get_int(@match[1], 'Frame')
|
48
|
+
return errmsg(err) unless pos
|
49
|
+
|
50
|
+
switch_to_frame(pos)
|
51
|
+
end
|
49
52
|
end
|
50
53
|
end
|
data/lib/byebug/commands/help.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'byebug/command'
|
2
|
+
require 'byebug/errors'
|
2
3
|
|
3
4
|
module Byebug
|
4
5
|
#
|
@@ -6,34 +7,56 @@ module Byebug
|
|
6
7
|
#
|
7
8
|
class HelpCommand < Command
|
8
9
|
self.allow_in_control = true
|
10
|
+
self.allow_in_post_mortem = true
|
9
11
|
|
10
|
-
def regexp
|
12
|
+
def self.regexp
|
11
13
|
/^\s* h(?:elp)? (?:\s+(\S+))? (?:\s+(\S+))? \s*$/x
|
12
14
|
end
|
13
15
|
|
16
|
+
def self.description
|
17
|
+
<<-EOD
|
18
|
+
h[elp][ <cmd>[ <subcmd>]]
|
19
|
+
|
20
|
+
#{short_description}
|
21
|
+
|
22
|
+
help -- prints a summary of all commands
|
23
|
+
help <cmd> -- prints help on command <cmd>
|
24
|
+
help <cmd> <subcmd> -- prints help on <cmd>'s subcommand <subcmd>
|
25
|
+
EOD
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.short_description
|
29
|
+
'Helps you using byebug'
|
30
|
+
end
|
31
|
+
|
14
32
|
def execute
|
15
|
-
return
|
33
|
+
return help_for_all unless @match[1]
|
16
34
|
|
17
|
-
|
18
|
-
return errmsg(pr('help.errors.undefined', cmd: @match[1])) unless cmd
|
35
|
+
return help_for(@match[1], command) unless @match[2]
|
19
36
|
|
20
|
-
|
21
|
-
|
37
|
+
help_for(@match[2], subcommand)
|
38
|
+
end
|
22
39
|
|
23
|
-
|
24
|
-
return errmsg(pr('help.errors.undefined', cmd: @match[2])) unless subcmd
|
40
|
+
private
|
25
41
|
|
26
|
-
|
42
|
+
def help_for_all
|
43
|
+
puts(processor.command_list.to_s)
|
27
44
|
end
|
28
45
|
|
29
|
-
def
|
30
|
-
|
31
|
-
h[elp][ <cmd>[ <subcmd>]]
|
46
|
+
def help_for(input, cmd)
|
47
|
+
fail CommandNotFound.new(input, command) unless cmd
|
32
48
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
49
|
+
puts(cmd.help)
|
50
|
+
end
|
51
|
+
|
52
|
+
def command
|
53
|
+
@command ||= processor.command_list.match(@match[1])
|
54
|
+
end
|
55
|
+
|
56
|
+
def subcommand
|
57
|
+
return unless command
|
58
|
+
|
59
|
+
@subcommand ||= command.subcommand_list.match(@match[2])
|
37
60
|
end
|
38
61
|
end
|
39
62
|
end
|