byebug 1.4.1 → 1.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +5 -0
  3. data/CHANGELOG.md +10 -0
  4. data/GUIDE.md +235 -9
  5. data/bin/byebug +12 -16
  6. data/byebug.gemspec +0 -1
  7. data/ext/byebug/byebug.c +5 -6
  8. data/lib/byebug.rb +17 -8
  9. data/lib/byebug/command.rb +12 -21
  10. data/lib/byebug/commands/breakpoints.rb +5 -9
  11. data/lib/byebug/commands/catchpoint.rb +2 -4
  12. data/lib/byebug/commands/condition.rb +4 -6
  13. data/lib/byebug/commands/continue.rb +2 -4
  14. data/lib/byebug/commands/control.rb +2 -4
  15. data/lib/byebug/commands/display.rb +4 -10
  16. data/lib/byebug/commands/edit.rb +2 -4
  17. data/lib/byebug/commands/enable.rb +6 -10
  18. data/lib/byebug/commands/eval.rb +12 -13
  19. data/lib/byebug/commands/finish.rb +2 -4
  20. data/lib/byebug/commands/frame.rb +6 -15
  21. data/lib/byebug/commands/help.rb +2 -3
  22. data/lib/byebug/commands/info.rb +5 -7
  23. data/lib/byebug/commands/jump.rb +2 -4
  24. data/lib/byebug/commands/kill.rb +2 -4
  25. data/lib/byebug/commands/list.rb +2 -4
  26. data/lib/byebug/commands/method.rb +4 -10
  27. data/lib/byebug/commands/quit.rb +2 -4
  28. data/lib/byebug/commands/reload.rb +1 -3
  29. data/lib/byebug/commands/repl.rb +3 -7
  30. data/lib/byebug/commands/save.rb +2 -4
  31. data/lib/byebug/commands/set.rb +4 -8
  32. data/lib/byebug/commands/show.rb +2 -4
  33. data/lib/byebug/commands/skip.rb +2 -4
  34. data/lib/byebug/commands/source.rb +1 -3
  35. data/lib/byebug/commands/stepping.rb +2 -4
  36. data/lib/byebug/commands/trace.rb +2 -4
  37. data/lib/byebug/commands/variables.rb +6 -18
  38. data/lib/byebug/version.rb +1 -1
  39. data/old_doc/byebug.texi +1 -9
  40. data/test/breakpoints_test.rb +1 -2
  41. data/test/examples/info.rb +5 -5
  42. data/test/examples/list.rb +21 -21
  43. data/test/examples/reload.rb +5 -5
  44. data/test/examples/repl.rb +6 -0
  45. data/test/examples/save.rb +2 -2
  46. data/test/examples/set.rb +2 -2
  47. data/test/examples/source.rb +2 -2
  48. data/test/finish_test.rb +1 -1
  49. data/test/help_test.rb +31 -15
  50. data/test/list_test.rb +27 -25
  51. data/test/reload_test.rb +3 -3
  52. data/test/repl_test.rb +8 -8
  53. data/test/set_test.rb +2 -12
  54. data/test/support/test_dsl.rb +25 -39
  55. data/test/variables_test.rb +0 -2
  56. metadata +4 -18
  57. data/test/examples/irb.rb +0 -6
@@ -13,23 +13,6 @@ module Byebug
13
13
  string[Command.settings[:width]-3 .. -1] = "..."
14
14
  end
15
15
  end
16
-
17
- ##
18
- # Find param in subcmds.
19
- #
20
- # @param is downcased and can be abbreviated to the minimum length listed in
21
- # the subcommands.
22
- #
23
- def find(subcmds, param)
24
- param.downcase!
25
- for try_subcmd in subcmds do
26
- if (param.size >= try_subcmd.min) and
27
- (try_subcmd.name[0..param.size-1] == param)
28
- return try_subcmd
29
- end
30
- end
31
- return nil
32
- end
33
16
  end
34
17
 
35
18
  # Root dir for byebug
@@ -53,10 +36,7 @@ module Byebug
53
36
  need_context: false } unless defined?(DEF_OPTIONS)
54
37
 
55
38
  def help(args)
56
- output = description.split("\n").map{|l| l.gsub(/^ +/, '')}
57
- output.shift if output.first && output.first.empty?
58
- output.pop if output.last && output.last.empty?
59
- output = output.join("\n") + "\n"
39
+ output = description.gsub(/^ +/, '')
60
40
 
61
41
  if defined? self::Subcommands
62
42
  return output += format_subcmds unless args and args[1]
@@ -66,6 +46,17 @@ module Byebug
66
46
  return output
67
47
  end
68
48
 
49
+ def find(subcmds, param)
50
+ param.downcase!
51
+ for try_subcmd in subcmds do
52
+ if (param.size >= try_subcmd.min) and
53
+ (try_subcmd.name[0..param.size-1] == param)
54
+ return try_subcmd
55
+ end
56
+ end
57
+ return nil
58
+ end
59
+
69
60
  def format_subcmd(subcmd_name)
70
61
  subcmd = find(self::Subcommands, subcmd_name)
71
62
  return "Invalid \"#{names.join("|")}\" " \
@@ -14,7 +14,7 @@ module Byebug
14
14
  end
15
15
 
16
16
  def execute
17
- return print self.class.help(nil) if self.class.names.include?(@match[0])
17
+ return print BreakCommand.help(nil) if BreakCommand.names.include?(@match[0])
18
18
 
19
19
  if @match[1]
20
20
  line, _, _, expr = @match.captures
@@ -95,12 +95,10 @@ module Byebug
95
95
  end
96
96
 
97
97
  def description
98
- %{
99
- b[reak] file:line [if expr]
98
+ %{b[reak] file:line [if expr]
100
99
  b[reak] class(.|#)method [if expr]
101
100
 
102
- Set breakpoint to some position, (optionally) if expr == true
103
- }
101
+ Set breakpoint to some position, (optionally) if expr == true}
104
102
  end
105
103
  end
106
104
  end
@@ -134,12 +132,10 @@ module Byebug
134
132
  end
135
133
 
136
134
  def description
137
- %{
138
- del[ete][ nnn...]
135
+ %{del[ete][ nnn...]
139
136
 
140
137
  Without and argument, deletes all breakpoints. With integer arguments,
141
- it deletes specific breakpoints.
142
- }
138
+ it deletes specific breakpoints.}
143
139
  end
144
140
  end
145
141
  end
@@ -39,13 +39,11 @@ module Byebug
39
39
  end
40
40
 
41
41
  def description
42
- %{
43
- cat[ch]\t\tsame as "info catch"
42
+ %{cat[ch]\t\tsame as "info catch"
44
43
  cat[ch] <exception-name> [on|off]
45
44
  \tIntercept <exception-name> when there would otherwise be no handler.
46
45
  \tWith an "on" or "off", turn handling the exception on or off.
47
- cat[ch] off\tdelete all catchpoints
48
- }
46
+ cat[ch] off\tdelete all catchpoints}
49
47
  end
50
48
  end
51
49
  end
@@ -1,6 +1,6 @@
1
1
  module Byebug
2
2
 
3
- class ConditionCommand < Command # :nodoc:
3
+ class ConditionCommand < Command
4
4
 
5
5
  def regexp
6
6
  /^\s* cond(?:ition)? (?:\s+(\d+)\s*(.*))?$/ix
@@ -31,16 +31,14 @@ module Byebug
31
31
  end
32
32
 
33
33
  def description
34
- %{
35
- cond[ition] nnn[ expr]
34
+ %{cond[ition] nnn[ expr]
36
35
 
37
36
  Specify breakpoint number nnn to break only if expr is true. nnn is an
38
37
  integer and expr is an expression to be evaluated whenever breakpoint
39
38
  nnn is reached. If no expression is specified, the condition is
40
- removed.
41
- }
39
+ removed.}
42
40
  end
43
41
  end
44
42
  end
45
43
 
46
- end # module Byebug
44
+ end
@@ -28,11 +28,9 @@ module Byebug
28
28
  end
29
29
 
30
30
  def description
31
- %{
32
- c[ont[inue]][ nnn]
31
+ %{c[ont[inue]][ nnn]
33
32
 
34
- Run until program ends, hits a breakpoint or reaches line nnn
35
- }
33
+ Run until program ends, hits a breakpoint or reaches line nnn}
36
34
  end
37
35
  end
38
36
  end
@@ -60,12 +60,10 @@ module Byebug
60
60
  end
61
61
 
62
62
  def description
63
- %{
64
- restart|R [args]
63
+ %{restart|R [args]
65
64
 
66
65
  Restart the program. This is a re-exec - all byebug state
67
- is lost. If command arguments are passed those are used.
68
- }
66
+ is lost. If command arguments are passed those are used.}
69
67
  end
70
68
  end
71
69
  end
@@ -39,9 +39,7 @@ module Byebug
39
39
  end
40
40
 
41
41
  def description
42
- %{
43
- disp[lay] <expression>\tadd expression into display expression list
44
- }
42
+ %{disp[lay] <expression>\tadd expression into display expression list}
45
43
  end
46
44
  end
47
45
  end
@@ -70,9 +68,7 @@ module Byebug
70
68
  end
71
69
 
72
70
  def description
73
- %{
74
- disp[lay]\t\tdisplay expression list
75
- }
71
+ %{disp[lay]\t\tdisplay expression list}
76
72
  end
77
73
  end
78
74
  end
@@ -106,15 +102,13 @@ module Byebug
106
102
  end
107
103
 
108
104
  def description
109
- %{
110
- undisp[lay][ nnn]
105
+ %{undisp[lay][ nnn]
111
106
 
112
107
  Cancel some expressions to be displayed when program stops. Arguments
113
108
  are the code numbers of the expressions to stop displaying. No
114
109
  argument means cancel all automatic-display expressions. "delete
115
110
  display" has the same effect as this command. Do "info display" to see
116
- the current list of code numbers.
117
- }
111
+ the current list of code numbers.}
118
112
  end
119
113
  end
120
114
  end
@@ -35,13 +35,11 @@ module Byebug
35
35
  end
36
36
 
37
37
  def description
38
- %{
39
- edit[ file:lineno]\tEdit specified file.
38
+ %{edit[ file:lineno]\tEdit specified file.
40
39
 
41
40
  With no argument, edits file containing most recent line listed.
42
41
  Editing targets can also be specified to start editing at a specific
43
- line in a specific file.
44
- }
42
+ line in a specific file.}
45
43
  end
46
44
  end
47
45
  end
@@ -69,7 +69,7 @@ module Byebug
69
69
 
70
70
  args = @match[1].split(/[ \t]+/)
71
71
  param = args.shift
72
- subcmd = find(Subcommands, param)
72
+ subcmd = Command.find(Subcommands, param)
73
73
  if subcmd
74
74
  send("enable_#{subcmd.name}", args)
75
75
  else
@@ -91,10 +91,8 @@ module Byebug
91
91
  end
92
92
 
93
93
  def description
94
- %{
95
- Enable some things.
96
- This is used to cancel the effect of the "disable" command.
97
- }
94
+ %{Enable some things.
95
+ This is used to cancel the effect of the "disable" command.}
98
96
  end
99
97
  end
100
98
  end
@@ -123,7 +121,7 @@ module Byebug
123
121
 
124
122
  args = @match[1].split(/[ \t]+/)
125
123
  param = args.shift
126
- subcmd = find(Subcommands, param)
124
+ subcmd = Command.find(Subcommands, param)
127
125
  if subcmd
128
126
  send("disable_#{subcmd.name}", args)
129
127
  else
@@ -145,12 +143,10 @@ module Byebug
145
143
  end
146
144
 
147
145
  def description
148
- %{
149
- Disable some things.
146
+ %{Disable some things.
150
147
 
151
148
  A disabled item is not forgotten, but has no effect until reenabled.
152
- Use the "enable" command to have it take effect again.
153
- }
149
+ Use the "enable" command to have it take effect again.}
154
150
  end
155
151
  end
156
152
  end
@@ -58,10 +58,11 @@ module Byebug
58
58
  end
59
59
 
60
60
  def description
61
- %{
62
- (p|e[val]) expression\tevaluate expression and print its value
63
- * NOTE - to turn on autoeval, use 'set autoeval'
64
- }
61
+ %{(p|e[val]) expression
62
+
63
+ Evaluate expression and print its value
64
+ * NOTE - unknown input is automatically evaluated, to turn this off
65
+ use 'set noautoeval'}
65
66
  end
66
67
  end
67
68
  end
@@ -89,9 +90,7 @@ module Byebug
89
90
  end
90
91
 
91
92
  def description
92
- %{
93
- pp expression\tevaluate expression and pretty-print its value
94
- }
93
+ %{pp expression\tevaluate expression and pretty-print its value}
95
94
  end
96
95
  end
97
96
  end
@@ -126,9 +125,9 @@ module Byebug
126
125
  end
127
126
 
128
127
  def description
129
- %{
130
- putl expression\tevaluate expression, an array, and columnize its value
131
- }
128
+ %{putl expression
129
+
130
+ Evaluate expression, an array, and columnize its value}
132
131
  end
133
132
  end
134
133
  end
@@ -165,9 +164,9 @@ module Byebug
165
164
  end
166
165
 
167
166
  def description
168
- %{
169
- ps expression\tevaluate expression, an array, sort and columnize its value
170
- }
167
+ %{ps expression
168
+
169
+ Evaluate expression, an array, sort and columnize its value}
171
170
  end
172
171
  end
173
172
  end
@@ -28,16 +28,14 @@ module Byebug
28
28
  end
29
29
 
30
30
  def description
31
- %{
32
- fin[ish][ frame-number]\tExecute until selected stack frame returns.
31
+ %{fin[ish][ frame-number]\tExecute until selected stack frame returns.
33
32
 
34
33
  If no frame number is given, we run until the currently selected frame
35
34
  returns. The currently selected frame starts out the most-recent frame
36
35
  or 0 if no frame positioning (e.g "up", "down" or "frame") has been
37
36
  performed.
38
37
 
39
- If a frame number is given we run until that frame returns.
40
- }
38
+ If a frame number is given we run until that frame returns.}
41
39
  end
42
40
  end
43
41
  end
@@ -157,7 +157,6 @@ module Byebug
157
157
  end
158
158
  return nil
159
159
  end
160
-
161
160
  end
162
161
 
163
162
  # Implements byebug "where" or "backtrace" command.
@@ -180,14 +179,12 @@ module Byebug
180
179
  end
181
180
 
182
181
  def description
183
- %{
184
- w[here]|bt|backtrace\tdisplay stack frames
182
+ %{w[here]|bt|backtrace\tdisplay stack frames
185
183
 
186
184
  Print the entire stack frame. Each frame is numbered, the most recent
187
185
  frame is 0. frame number can be referred to in the "frame" command;
188
186
  "up" and "down" add or subtract respectively to frame numbers shown.
189
- The position of the current frame is marked with -->.
190
- }
187
+ The position of the current frame is marked with -->.}
191
188
  end
192
189
  end
193
190
  end
@@ -209,9 +206,7 @@ module Byebug
209
206
  end
210
207
 
211
208
  def description
212
- %{
213
- up[ count]\tmove to higher frame
214
- }
209
+ %{up[ count]\tmove to higher frame}
215
210
  end
216
211
  end
217
212
  end
@@ -233,9 +228,7 @@ module Byebug
233
228
  end
234
229
 
235
230
  def description
236
- %{
237
- down[ count]\tmove to lower frame
238
- }
231
+ %{down[ count]\tmove to lower frame}
239
232
  end
240
233
  end
241
234
  end
@@ -264,8 +257,7 @@ module Byebug
264
257
  end
265
258
 
266
259
  def description
267
- %{
268
- f[rame][ frame-number]
260
+ %{f[rame][ frame-number]
269
261
 
270
262
  Move the current frame to the specified frame number, or the 0 if no
271
263
  frame-number has been given.
@@ -275,8 +267,7 @@ module Byebug
275
267
 
276
268
  Without an argument, the command prints the current stack frame. Since
277
269
  the current position is redisplayed, it may trigger a resyncronization
278
- if there is a front end also watching over things.
279
- }
270
+ if there is a front end also watching over things.}
280
271
  end
281
272
  end
282
273
  end
@@ -41,10 +41,9 @@ module Byebug
41
41
  end
42
42
 
43
43
  def description
44
- %{
45
- h[elp]\t\tprint this help
44
+ %{h[elp]\t\tprint this help
46
45
  h[elp] command\tprint help on command
47
- }
46
+ h[elp] command subcommand\tprint help on subcommand}
48
47
  end
49
48
  end
50
49
  end
@@ -71,7 +71,7 @@ module Byebug
71
71
 
72
72
  args = @match[1].split(/[ \t]+/)
73
73
  param = args.shift
74
- subcmd = find(Subcommands, param)
74
+ subcmd = Command.find(Subcommands, param)
75
75
  if subcmd
76
76
  send("info_#{subcmd.name}", *args)
77
77
  else
@@ -174,7 +174,7 @@ module Byebug
174
174
 
175
175
  param = args[1] || 'basic'
176
176
 
177
- subcmd = find(InfoFileSubcommands, param)
177
+ subcmd = Command.find(InfoFileSubcommands, param)
178
178
  return errmsg "Invalid parameter #{param}\n" unless subcmd
179
179
 
180
180
  unless LineCache::cached?(args[0])
@@ -309,11 +309,9 @@ module Byebug
309
309
  end
310
310
 
311
311
  def description
312
- %{
313
- info[ subcommand]
312
+ %{info[ subcommand]
314
313
 
315
- Generic command for showing things about the program being debugged.
316
- }
314
+ Generic command for showing things about the program being debugged.}
317
315
  end
318
316
 
319
317
  def help(args)
@@ -322,7 +320,7 @@ module Byebug
322
320
  return format_subcmd(args[1]) unless 'file' == args[1] and args[2]
323
321
 
324
322
  str = subcmd.short_help + '.'
325
- subsubcmd = find(InfoFileSubcommands, args[2])
323
+ subsubcmd = Command.find(InfoFileSubcommands, args[2])
326
324
  if subsubcmd
327
325
  str += "\nInvalid \"file\" attribute \"#{args[2]}\"."
328
326
  else