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.
Files changed (96) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +72 -34
  3. data/CONTRIBUTING.md +26 -31
  4. data/README.md +3 -3
  5. data/lib/byebug/breakpoint.rb +2 -1
  6. data/lib/byebug/command.rb +27 -49
  7. data/lib/byebug/commands/break.rb +21 -15
  8. data/lib/byebug/commands/catch.rb +9 -15
  9. data/lib/byebug/commands/condition.rb +12 -15
  10. data/lib/byebug/commands/continue.rb +8 -11
  11. data/lib/byebug/commands/delete.rb +9 -12
  12. data/lib/byebug/commands/disable.rb +32 -0
  13. data/lib/byebug/commands/disable/breakpoints.rb +38 -0
  14. data/lib/byebug/commands/disable/display.rb +39 -0
  15. data/lib/byebug/commands/display.rb +18 -51
  16. data/lib/byebug/commands/down.rb +39 -0
  17. data/lib/byebug/commands/edit.rb +8 -14
  18. data/lib/byebug/commands/enable.rb +25 -0
  19. data/lib/byebug/commands/enable/breakpoints.rb +38 -0
  20. data/lib/byebug/commands/enable/display.rb +39 -0
  21. data/lib/byebug/commands/eval.rb +10 -192
  22. data/lib/byebug/commands/finish.rb +11 -12
  23. data/lib/byebug/commands/frame.rb +17 -182
  24. data/lib/byebug/commands/help.rb +18 -18
  25. data/lib/byebug/commands/history.rb +9 -10
  26. data/lib/byebug/commands/info.rb +17 -190
  27. data/lib/byebug/commands/info/args.rb +39 -0
  28. data/lib/byebug/commands/info/breakpoints.rb +59 -0
  29. data/lib/byebug/commands/info/catch.rb +39 -0
  30. data/lib/byebug/commands/info/display.rb +42 -0
  31. data/lib/byebug/commands/info/file.rb +81 -0
  32. data/lib/byebug/commands/info/line.rb +31 -0
  33. data/lib/byebug/commands/info/program.rb +51 -0
  34. data/lib/byebug/commands/interrupt.rb +5 -9
  35. data/lib/byebug/commands/irb.rb +5 -9
  36. data/lib/byebug/commands/kill.rb +6 -12
  37. data/lib/byebug/commands/list.rb +47 -19
  38. data/lib/byebug/commands/method.rb +8 -14
  39. data/lib/byebug/commands/next.rb +36 -0
  40. data/lib/byebug/commands/pp.rb +41 -0
  41. data/lib/byebug/commands/pry.rb +5 -9
  42. data/lib/byebug/commands/ps.rb +44 -0
  43. data/lib/byebug/commands/putl.rb +43 -0
  44. data/lib/byebug/commands/quit.rb +8 -12
  45. data/lib/byebug/commands/restart.rb +6 -12
  46. data/lib/byebug/commands/save.rb +30 -39
  47. data/lib/byebug/commands/set.rb +19 -21
  48. data/lib/byebug/commands/show.rb +10 -16
  49. data/lib/byebug/commands/source.rb +6 -12
  50. data/lib/byebug/commands/step.rb +36 -0
  51. data/lib/byebug/commands/thread.rb +13 -130
  52. data/lib/byebug/commands/thread/current.rb +35 -0
  53. data/lib/byebug/commands/thread/list.rb +41 -0
  54. data/lib/byebug/commands/thread/resume.rb +45 -0
  55. data/lib/byebug/commands/thread/stop.rb +41 -0
  56. data/lib/byebug/commands/thread/switch.rb +43 -0
  57. data/lib/byebug/commands/tracevar.rb +8 -14
  58. data/lib/byebug/commands/undisplay.rb +12 -15
  59. data/lib/byebug/commands/untracevar.rb +5 -11
  60. data/lib/byebug/commands/up.rb +39 -0
  61. data/lib/byebug/commands/var.rb +15 -94
  62. data/lib/byebug/commands/var/all.rb +37 -0
  63. data/lib/byebug/commands/var/const.rb +38 -0
  64. data/lib/byebug/commands/var/global.rb +33 -0
  65. data/lib/byebug/commands/var/instance.rb +35 -0
  66. data/lib/byebug/commands/var/local.rb +35 -0
  67. data/lib/byebug/commands/where.rb +47 -0
  68. data/lib/byebug/core.rb +10 -0
  69. data/lib/byebug/helpers/eval.rb +47 -0
  70. data/lib/byebug/helpers/file.rb +46 -0
  71. data/lib/byebug/helpers/frame.rb +76 -0
  72. data/lib/byebug/helpers/parse.rb +74 -0
  73. data/lib/byebug/helpers/string.rb +24 -0
  74. data/lib/byebug/helpers/thread.rb +53 -0
  75. data/lib/byebug/helpers/toggle.rb +56 -0
  76. data/lib/byebug/helpers/var.rb +45 -0
  77. data/lib/byebug/history.rb +2 -4
  78. data/lib/byebug/interface.rb +5 -3
  79. data/lib/byebug/interfaces/local_interface.rb +3 -1
  80. data/lib/byebug/interfaces/remote_interface.rb +3 -1
  81. data/lib/byebug/interfaces/test_interface.rb +6 -2
  82. data/lib/byebug/printers/plain.rb +1 -1
  83. data/lib/byebug/processors/command_processor.rb +9 -11
  84. data/lib/byebug/processors/control_command_processor.rb +1 -1
  85. data/lib/byebug/remote.rb +3 -0
  86. data/lib/byebug/runner.rb +5 -3
  87. data/lib/byebug/setting.rb +2 -18
  88. data/lib/byebug/settings/savefile.rb +21 -0
  89. data/lib/byebug/states/regular_state.rb +15 -6
  90. data/lib/byebug/subcommand_list.rb +33 -0
  91. data/lib/byebug/subcommands.rb +53 -0
  92. data/lib/byebug/version.rb +1 -1
  93. metadata +45 -6
  94. data/lib/byebug/commands/enable_disable.rb +0 -132
  95. data/lib/byebug/commands/stepping.rb +0 -75
  96. data/lib/byebug/helper.rb +0 -131
@@ -1,132 +0,0 @@
1
- require 'byebug/command'
2
-
3
- module Byebug
4
- #
5
- # Mixin to assist command parsing
6
- #
7
- module EnableDisableFunctions
8
- def enable_disable_breakpoints(is_enable, args)
9
- return errmsg(pr('toggle.errors.no_breakpoints')) if Breakpoint.none?
10
-
11
- all_breakpoints = Byebug.breakpoints.sort_by(&:id)
12
- if args.empty?
13
- selected_breakpoints = all_breakpoints
14
- else
15
- selected_ids = []
16
- args.each do |pos|
17
- last_id = all_breakpoints.last.id
18
- pos, err = get_int(pos, "#{is_enable} breakpoints", 1, last_id)
19
- return errmsg(err) unless pos
20
-
21
- selected_ids << pos
22
- end
23
- selected_breakpoints = all_breakpoints.select do |b|
24
- selected_ids.include?(b.id)
25
- end
26
- end
27
-
28
- selected_breakpoints.each do |b|
29
- enabled = ('enable' == is_enable)
30
- if enabled && !syntax_valid?(b.expr)
31
- return errmsg(pr('toggle.errors.expression', expr: b.expr))
32
- end
33
-
34
- b.enabled = enabled
35
- end
36
- end
37
-
38
- def enable_disable_display(is_enable, args)
39
- return errmsg(pr('toggle.errors.no_display')) if 0 == @state.display.size
40
-
41
- args.each do |pos|
42
- pos, err = get_int(pos, "#{is_enable} display", 1, @state.display.size)
43
- return errmsg(err) unless err.nil?
44
-
45
- @state.display[pos - 1][0] = ('enable' == is_enable)
46
- end
47
- end
48
- end
49
-
50
- #
51
- # Enabling or disabling custom display expressions or breakpoints.
52
- #
53
- class EnableDisableCommand < Command
54
- include EnableDisableFunctions
55
-
56
- Subcommands = [
57
- ['breakpoints', 2, 'Enable/disable breakpoints. Give breakpoint ' \
58
- 'numbers (separated by spaces) as arguments or no ' \
59
- 'argument at all if you want to enable/disable ' \
60
- 'every breakpoint'],
61
- ['display', 2, 'Enable/disable some expressions to be displayed when ' \
62
- ' when program stops. Arguments are the code numbers ' \
63
- 'of the expressions to resume/stop displaying. Do ' \
64
- '"info display" to see the current list of code ' \
65
- 'numbers']
66
- ].map do |name, min, help|
67
- Subcmd.new(name, min, help)
68
- end
69
-
70
- def regexp
71
- /^\s* (dis|en)(?:able)? (?:\s+(.+))? \s*$/x
72
- end
73
-
74
- def execute
75
- cmd = @match[1] == 'dis' ? 'disable' : 'enable'
76
-
77
- return errmsg(pr('toggle.errors.syntax', toggle: cmd)) unless @match[2]
78
-
79
- args = @match[2].split(/ +/)
80
- param = args.shift
81
- subcmd = Command.find(Subcommands, param)
82
- if subcmd
83
- send("#{cmd}_#{subcmd.name}", args)
84
- else
85
- send("#{cmd}_breakpoints", args.unshift(param))
86
- end
87
- end
88
-
89
- def enable_breakpoints(args)
90
- enable_disable_breakpoints('enable', args)
91
- end
92
-
93
- def enable_display(args)
94
- enable_disable_display('enable', args)
95
- end
96
-
97
- def disable_breakpoints(args)
98
- enable_disable_breakpoints('disable', args)
99
- end
100
-
101
- def disable_display(args)
102
- enable_disable_display('disable', args)
103
- end
104
-
105
- class << self
106
- def names
107
- %w((en|dis)able)
108
- end
109
-
110
- def description
111
- prettify <<-EOD
112
- (en|dis)[able][[ (breakpoints|display)][ n1[ n2[ ...[ nn]]]]]
113
-
114
- Enables or disables breakpoints or displays.
115
-
116
- "enable" by itself enables all breakpoints, just like
117
- "enable breakpoints". On the other side, "disable" or
118
- "disable breakpoints" disable all breakpoints.
119
-
120
- You can also specify a space separated list of breakpoint numbers to
121
- enable or disable specific breakpoints. You can use either
122
- "enable <id1> ... <idn>" or "enable breakpoints <id1> ... <idn>" and
123
- the same with "disable".
124
-
125
- If instead of "breakpoints" you specify "display", the command will
126
- work exactly the same way, but displays will get enabled/disabled
127
- instead of breakpoints.
128
- EOD
129
- end
130
- end
131
- end
132
- end
@@ -1,75 +0,0 @@
1
- require 'byebug/command'
2
-
3
- module Byebug
4
- #
5
- # Implements the next functionality.
6
- #
7
- # Allows the user the continue execution until the next instruction in the
8
- # current frame.
9
- #
10
- class NextCommand < Command
11
- self.allow_in_post_mortem = false
12
-
13
- def regexp
14
- /^\s* n(?:ext)? (?:\s+(\S+))? \s*$/x
15
- end
16
-
17
- def execute
18
- steps, err = parse_steps(@match[1], 'Next')
19
- return errmsg(err) unless steps
20
-
21
- @state.context.step_over(steps, @state.frame)
22
- @state.proceed
23
- end
24
-
25
- class << self
26
- def names
27
- %w(next)
28
- end
29
-
30
- def description
31
- prettify <<-EOD
32
- n[ext][ nnn]
33
-
34
- Steps over once or nnn times.
35
- EOD
36
- end
37
- end
38
- end
39
-
40
- #
41
- # Implements the step functionality.
42
- #
43
- # Allows the user the continue execution until the next instruction, possibily
44
- # in a different frame. Use step to step into method calls or blocks.
45
- #
46
- class StepCommand < Command
47
- self.allow_in_post_mortem = false
48
-
49
- def regexp
50
- /^\s* s(?:tep)? (?:\s+(\S+))? \s*$/x
51
- end
52
-
53
- def execute
54
- steps, err = parse_steps(@match[1], 'Steps')
55
- return errmsg(err) unless steps
56
-
57
- @state.context.step_into(steps, @state.frame)
58
- @state.proceed
59
- end
60
-
61
- class << self
62
- def names
63
- %w(step)
64
- end
65
-
66
- def description
67
- prettify <<-EOD
68
- s[tep][ nnn]
69
-
70
- Steps (into methods) once or nnn times.
71
- EOD
72
- end
73
- end
74
- end
75
- end
@@ -1,131 +0,0 @@
1
- module Byebug
2
- #
3
- # Utilities for interaction with files
4
- #
5
- module FileFunctions
6
- #
7
- # Reads lines of source file +filename+ into an array
8
- #
9
- def get_lines(filename)
10
- File.foreach(filename).reduce([]) { |a, e| a << e.chomp }
11
- end
12
-
13
- #
14
- # Reads line number +lineno+ from file named +filename+
15
- #
16
- def get_line(filename, lineno)
17
- File.open(filename) do |f|
18
- f.gets until f.lineno == lineno - 1
19
- f.gets
20
- end
21
- end
22
-
23
- #
24
- # Returns the number of lines in file +filename+ in a portable,
25
- # one-line-at-a-time way.
26
- #
27
- def n_lines(filename)
28
- File.foreach(filename).reduce(0) { |a, _e| a + 1 }
29
- end
30
-
31
- #
32
- # Regularize file name.
33
- #
34
- def normalize(filename)
35
- return filename if ['(irb)', '-e'].include?(filename)
36
-
37
- return File.basename(filename) if Setting[:basename]
38
-
39
- path = File.expand_path(filename)
40
-
41
- File.exist?(path) ? File.realpath(path) : filename
42
- end
43
- end
44
-
45
- #
46
- # Utilities for interaction with files
47
- #
48
- module StringFunctions
49
- #
50
- # Converts +str+ from an_underscored-or-dasherized_string to
51
- # ACamelizedString.
52
- #
53
- def camelize(str)
54
- str.dup.split(/[_-]/).map(&:capitalize).join('')
55
- end
56
-
57
- #
58
- # Improves indentation and spacing in +str+ for readability in Byebug's
59
- # command prompt.
60
- #
61
- def prettify(str)
62
- "\n" + str.gsub(/^ {8}/, '') + "\n"
63
- end
64
- end
65
-
66
- #
67
- # Utilities to assist command parsing
68
- #
69
- module ParseFunctions
70
- #
71
- # Parse 'str' of command 'cmd' as an integer between min and max. If either
72
- # min or max is nil, that value has no bound.
73
- #
74
- def get_int(str, cmd, min = nil, max = nil)
75
- if str !~ /\A[0-9]+\z/
76
- return nil, pr('parse.errors.int.not_number', cmd: cmd, str: str)
77
- end
78
-
79
- int = str.to_i
80
- if min && int < min
81
- return min, pr('parse.errors.int.too_low', cmd: cmd, str: str, min: min)
82
- elsif max && int > max
83
- return max, pr('parse.errors.int.too_high',
84
- cmd: cmd, str: str, max: max)
85
- end
86
-
87
- int
88
- end
89
-
90
- #
91
- # Returns true if code is syntactically correct for Ruby
92
- #
93
- def syntax_valid?(code)
94
- return true unless code
95
-
96
- without_stderr do
97
- begin
98
- RubyVM::InstructionSequence.compile(code)
99
- true
100
- rescue SyntaxError
101
- false
102
- end
103
- end
104
- end
105
-
106
- #
107
- # Temporarily disable output to $stderr
108
- #
109
- def without_stderr
110
- stderr = $stderr
111
- $stderr.reopen(IO::NULL)
112
-
113
- yield
114
- ensure
115
- $stderr.reopen(stderr)
116
- end
117
-
118
- #
119
- # Returns the number of steps specified in <str> as an integer or 1 if <str>
120
- # is empty.
121
- #
122
- def parse_steps(str, cmd)
123
- return 1 unless str
124
-
125
- steps, err = get_int(str, cmd, 1)
126
- return nil, err unless steps
127
-
128
- steps
129
- end
130
- end
131
- end