byebug 5.0.0 → 6.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (110) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +26 -1
  3. data/CONTRIBUTING.md +35 -13
  4. data/GUIDE.md +256 -198
  5. data/README.md +5 -11
  6. data/ext/byebug/byebug.c +5 -43
  7. data/ext/byebug/byebug.h +6 -1
  8. data/ext/byebug/context.c +4 -5
  9. data/lib/byebug/command.rb +64 -64
  10. data/lib/byebug/command_list.rb +32 -0
  11. data/lib/byebug/commands.rb +37 -0
  12. data/lib/byebug/commands/break.rb +45 -37
  13. data/lib/byebug/commands/catch.rb +52 -28
  14. data/lib/byebug/commands/condition.rb +19 -13
  15. data/lib/byebug/commands/continue.rb +15 -11
  16. data/lib/byebug/commands/delete.rb +18 -12
  17. data/lib/byebug/commands/disable.rb +9 -10
  18. data/lib/byebug/commands/disable/breakpoints.rb +13 -11
  19. data/lib/byebug/commands/disable/display.rb +13 -11
  20. data/lib/byebug/commands/display.rb +32 -24
  21. data/lib/byebug/commands/down.rb +18 -14
  22. data/lib/byebug/commands/edit.rb +42 -26
  23. data/lib/byebug/commands/enable.rb +9 -3
  24. data/lib/byebug/commands/enable/breakpoints.rb +13 -11
  25. data/lib/byebug/commands/enable/display.rb +13 -11
  26. data/lib/byebug/commands/finish.rb +23 -14
  27. data/lib/byebug/commands/frame.rb +21 -18
  28. data/lib/byebug/commands/help.rb +39 -16
  29. data/lib/byebug/commands/history.rb +16 -10
  30. data/lib/byebug/commands/info.rb +8 -5
  31. data/lib/byebug/commands/info/breakpoints.rb +16 -14
  32. data/lib/byebug/commands/info/display.rb +18 -18
  33. data/lib/byebug/commands/info/file.rb +22 -22
  34. data/lib/byebug/commands/info/line.rb +13 -11
  35. data/lib/byebug/commands/info/program.rb +13 -17
  36. data/lib/byebug/commands/interrupt.rb +13 -11
  37. data/lib/byebug/commands/irb.rb +16 -10
  38. data/lib/byebug/commands/kill.rb +19 -13
  39. data/lib/byebug/commands/list.rb +35 -24
  40. data/lib/byebug/commands/method.rb +25 -15
  41. data/lib/byebug/commands/next.rb +15 -13
  42. data/lib/byebug/commands/pry.rb +18 -11
  43. data/lib/byebug/commands/ps.rb +21 -23
  44. data/lib/byebug/commands/quit.rb +17 -11
  45. data/lib/byebug/commands/restart.rb +28 -24
  46. data/lib/byebug/commands/save.rb +23 -15
  47. data/lib/byebug/commands/set.rb +26 -19
  48. data/lib/byebug/commands/show.rb +20 -14
  49. data/lib/byebug/commands/source.rb +15 -14
  50. data/lib/byebug/commands/step.rb +15 -13
  51. data/lib/byebug/commands/thread.rb +8 -4
  52. data/lib/byebug/commands/thread/current.rb +11 -11
  53. data/lib/byebug/commands/thread/list.rb +14 -14
  54. data/lib/byebug/commands/thread/resume.rb +14 -14
  55. data/lib/byebug/commands/thread/stop.rb +14 -14
  56. data/lib/byebug/commands/thread/switch.rb +15 -14
  57. data/lib/byebug/commands/tracevar.rb +20 -16
  58. data/lib/byebug/commands/undisplay.rb +22 -18
  59. data/lib/byebug/commands/untracevar.rb +13 -11
  60. data/lib/byebug/commands/up.rb +18 -14
  61. data/lib/byebug/commands/var.rb +10 -3
  62. data/lib/byebug/commands/var/all.rb +15 -13
  63. data/lib/byebug/commands/var/args.rb +37 -0
  64. data/lib/byebug/commands/var/const.rb +25 -14
  65. data/lib/byebug/commands/var/global.rb +13 -11
  66. data/lib/byebug/commands/var/instance.rb +13 -11
  67. data/lib/byebug/commands/var/local.rb +13 -11
  68. data/lib/byebug/commands/where.rb +15 -11
  69. data/lib/byebug/context.rb +71 -73
  70. data/lib/byebug/core.rb +45 -26
  71. data/lib/byebug/errors.rb +27 -0
  72. data/lib/byebug/frame.rb +181 -0
  73. data/lib/byebug/helpers/eval.rb +67 -26
  74. data/lib/byebug/helpers/file.rb +18 -3
  75. data/lib/byebug/helpers/frame.rb +36 -39
  76. data/lib/byebug/helpers/parse.rb +15 -13
  77. data/lib/byebug/helpers/path.rb +21 -0
  78. data/lib/byebug/helpers/reflection.rb +17 -0
  79. data/lib/byebug/helpers/thread.rb +20 -14
  80. data/lib/byebug/helpers/toggle.rb +10 -5
  81. data/lib/byebug/helpers/var.rb +36 -15
  82. data/lib/byebug/interface.rb +27 -9
  83. data/lib/byebug/option_setter.rb +93 -0
  84. data/lib/byebug/printers/base.rb +3 -0
  85. data/lib/byebug/printers/plain.rb +4 -14
  86. data/lib/byebug/printers/texts/base.yml +2 -7
  87. data/lib/byebug/processors/command_processor.rb +101 -102
  88. data/lib/byebug/processors/control_processor.rb +20 -0
  89. data/lib/byebug/processors/post_mortem_processor.rb +16 -0
  90. data/lib/byebug/processors/script_processor.rb +49 -0
  91. data/lib/byebug/remote.rb +13 -7
  92. data/lib/byebug/runner.rb +39 -65
  93. data/lib/byebug/setting.rb +4 -1
  94. data/lib/byebug/settings/post_mortem.rb +0 -16
  95. data/lib/byebug/settings/savefile.rb +1 -4
  96. data/lib/byebug/subcommands.rb +27 -29
  97. data/lib/byebug/version.rb +4 -1
  98. metadata +14 -29
  99. data/lib/byebug/commands/eval.rb +0 -43
  100. data/lib/byebug/commands/info/args.rb +0 -39
  101. data/lib/byebug/commands/info/catch.rb +0 -39
  102. data/lib/byebug/commands/pp.rb +0 -41
  103. data/lib/byebug/commands/putl.rb +0 -43
  104. data/lib/byebug/processor.rb +0 -43
  105. data/lib/byebug/processors/control_command_processor.rb +0 -48
  106. data/lib/byebug/settings/verbose.rb +0 -20
  107. data/lib/byebug/state.rb +0 -12
  108. data/lib/byebug/states/control_state.rb +0 -26
  109. data/lib/byebug/states/regular_state.rb +0 -187
  110. data/lib/byebug/subcommand_list.rb +0 -33
@@ -1,12 +0,0 @@
1
- module Byebug
2
- #
3
- # Common parent class for all of Byebug's states
4
- #
5
- class State
6
- attr_reader :interface
7
-
8
- def initialize(interface)
9
- @interface = interface
10
- end
11
- end
12
- end
@@ -1,26 +0,0 @@
1
- require 'byebug/state'
2
-
3
- module Byebug
4
- #
5
- # Controls state of Byebug's REPL when in control mode
6
- #
7
- class ControlState < State
8
- def proceed
9
- end
10
-
11
- extend Forwardable
12
- def_delegators :@interface, :errmsg, :puts
13
-
14
- def confirm(*_args)
15
- 'y'
16
- end
17
-
18
- def context
19
- nil
20
- end
21
-
22
- def file
23
- errmsg 'No filename given.'
24
- end
25
- end
26
- end
@@ -1,187 +0,0 @@
1
- require 'byebug/state'
2
- require 'byebug/helpers/file'
3
-
4
- module Byebug
5
- #
6
- # Controls state of Byebug's REPL when in normal mode
7
- #
8
- class RegularState < State
9
- include Helpers::FileHelper
10
-
11
- attr_accessor :context, :frame, :display, :file, :line, :prev_line
12
- attr_writer :interface
13
-
14
- def initialize(context, display, file, interface, line)
15
- super(interface)
16
- @context = context
17
- @display = display
18
- @file = file
19
- @frame = 0
20
- @line = line
21
- @prev_line = nil
22
- @proceed = false
23
- end
24
-
25
- extend Forwardable
26
- def_delegators :@interface, :errmsg, :puts, :print, :confirm
27
-
28
- #
29
- # Checks whether that execution can proceed
30
- #
31
- def proceed?
32
- @proceed
33
- end
34
-
35
- #
36
- # Signals the REPL that the execution can proceed
37
- #
38
- def proceed
39
- @proceed = true
40
- end
41
-
42
- #
43
- # Current (formatted) location
44
- #
45
- def location
46
- l = "#{normalize(file)} @ #{line}\n"
47
- l += "#{get_line(file, line)}\n" unless %w((irb) -e').include?(file)
48
- l
49
- end
50
-
51
- #
52
- # Builds a string containing the class associated to frame number +pos+
53
- # or an empty string if the current +callstyle+ setting is 'short'
54
- #
55
- # @param pos [Integer] Frame position.
56
- #
57
- def frame_class(pos)
58
- return '' if Setting[:callstyle] == 'short'
59
-
60
- klass = context.frame_class(pos)
61
- return '' if klass.to_s.empty?
62
-
63
- "#{klass}."
64
- end
65
-
66
- #
67
- # Builds a formatted string containing information about block and method
68
- # of the frame in position +pos+
69
- #
70
- # @param pos [Integer] Frame position.
71
- #
72
- def frame_block_and_method(pos)
73
- deco_regexp = /((?:block(?: \(\d+ levels\))?|rescue) in )?(.+)/
74
- deco_method = "#{context.frame_method(pos)}"
75
- block_and_method = deco_regexp.match(deco_method)[1..2]
76
- block_and_method.map { |x| x.nil? ? '' : x }
77
- end
78
-
79
- #
80
- # Builds a string containing all available args in frame number +pos+, in a
81
- # verbose or non verbose way according to the value of the +callstyle+
82
- # setting
83
- #
84
- # @param pos [Integer] Frame position.
85
- #
86
- def frame_args(pos)
87
- args = context.frame_args(pos)
88
- return '' if args.empty?
89
-
90
- locals = context.frame_locals(pos) unless Setting[:callstyle] == 'short'
91
- my_args = args.map do |arg|
92
- prefix, default = prefix_and_default_from(arg[0])
93
-
94
- kls = if Setting[:callstyle] == 'short' || arg[1].nil? || locals.empty?
95
- ''
96
- else
97
- "##{locals[arg[1]].class}"
98
- end
99
-
100
- "#{prefix}#{arg[1] || default}#{kls}"
101
- end
102
-
103
- "(#{my_args.join(', ')})"
104
- end
105
-
106
- #
107
- # Builds a formatted string containing information about current method
108
- # call in frame number +pos+.
109
- #
110
- # @param pos [Integer] Frame position.
111
- #
112
- def frame_call(pos)
113
- block, method = frame_block_and_method(pos)
114
-
115
- block + frame_class(pos) + method + frame_args(pos)
116
- end
117
-
118
- #
119
- # Formatted filename in frame number +pos+
120
- #
121
- # @param pos [Integer] Frame position.
122
- #
123
- def frame_file(pos)
124
- fullpath = context.frame_file(pos)
125
- Setting[:fullpath] ? fullpath : shortpath(fullpath)
126
- end
127
-
128
- #
129
- # Line number in frame number +pos+
130
- #
131
- # @param pos [Integer] Frame position.
132
- #
133
- def frame_line(pos)
134
- context.frame_line(pos)
135
- end
136
-
137
- #
138
- # Properly formatted frame number of frame in position +pos+
139
- #
140
- # @param pos [Integer] Frame position.
141
- #
142
- def frame_pos(pos)
143
- format('%-2d', pos)
144
- end
145
-
146
- #
147
- # Formatted mark for number of frame in position +pos+. The mark can
148
- # contain the current frame symbo (-->), the c_frame symbol (ͱ--) or both
149
- #
150
- # @param pos [Integer] Frame position.
151
- #
152
- def frame_mark(pos)
153
- mark = frame == pos ? '-->' : ' '
154
-
155
- c_frame?(pos) ? mark + ' ͱ--' : mark
156
- end
157
-
158
- #
159
- # Checks whether the frame in position +pos+ is a c-frame or not
160
- #
161
- # @param pos [Integer] Frame position.
162
- #
163
- def c_frame?(pos)
164
- context.frame_binding(pos).nil?
165
- end
166
-
167
- private
168
-
169
- def shortpath(fullpath)
170
- components = Pathname(fullpath).each_filename.to_a
171
- return fullpath if components.size <= 2
172
-
173
- File.join('...', components[-3..-1])
174
- end
175
-
176
- def prefix_and_default_from(arg_type)
177
- case arg_type
178
- when :block
179
- return ['&', 'block']
180
- when :rest
181
- return ['*', 'args']
182
- else
183
- return ['', nil]
184
- end
185
- end
186
- end
187
- end
@@ -1,33 +0,0 @@
1
- module Byebug
2
- #
3
- # Holds an array of subcommands for a command
4
- #
5
- class SubcommandList
6
- def initialize(commands, parent)
7
- @commands = commands
8
- @parent = parent
9
- end
10
-
11
- def find(name)
12
- @commands.find { |cmd| cmd.match(name) }
13
- end
14
-
15
- def help(name)
16
- subcmd = find(name)
17
- return errmsg("Unknown subcommand '#{name}'") unless subcmd
18
-
19
- subcmd.help
20
- end
21
-
22
- def to_s
23
- width = @commands.map(&:to_name).max_by(&:size).size
24
-
25
- formatted_cmds = @commands.map do |subcmd|
26
- format("%s %-#{width}s -- %s\n",
27
- @parent, subcmd.to_name, subcmd.short_description)
28
- end
29
-
30
- formatted_cmds.join
31
- end
32
- end
33
- end