byebug 1.8.1 → 1.8.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: acd8920a83d1fedf0cbd9d0be440d9f91787a7d2
4
- data.tar.gz: 314f0f812d551b821dd2e359395913f892b658c9
3
+ metadata.gz: 6e50f515a828a79ec3a73e802a9b480b44d4aedb
4
+ data.tar.gz: 3a613a22f8a9a5e6805899f646efbd8e5f29c5eb
5
5
  SHA512:
6
- metadata.gz: 5d876b60bd98e99b26d56f4eab6a755e128d898e21495fe0a3068f28b69cd3650813033ece544e8ed3f3cba5f01d40e9bc359f16437c44f891a0f294dc10287d
7
- data.tar.gz: 94a65649be23ce095d340a6cbb358c217fb4151649183df73c652efd8e5efddf9d40d58a3f5deaa45eb7963e88b008879408a129f444a39bc74fbec0aa285d24
6
+ metadata.gz: b1dea64be0bf3f4aa95986f80e4d468c810ce5ed6a3322a5a672d8db772548109a3c390d5a442bf0b91b6f934c2d6b18797b5782730b2b6f9a544f47ddb337f1
7
+ data.tar.gz: 7962816e1385499dce322487b27be5ec25e71f8134f65c8d6b2970ab19257ee998c9f34c2f3208fa64e8349a20ea3b0b050406be1806222b24b8ce6f9af95f1b
@@ -1,3 +1,11 @@
1
+ ## 1.8.2
2
+
3
+ * More user friendly regexps for commands
4
+ * Better help for some commands
5
+ * `save` command now saves the list of "displays"
6
+ * Fixes bug in calculating stacksize
7
+
8
+
1
9
  ## 1.8.1
2
10
 
3
11
  * Bugfix release
@@ -1 +1,9 @@
1
- Thanks for trying out this project! [See here for contribution guidelines.](http://tagaholic.me/contributing.html)
1
+ Thanks for your interest in contributing to ByeBug!
2
+
3
+ To make your changes, follow this steps:
4
+
5
+ * [Fork the project](https://help.github.com/fork-a-repo)
6
+ * Create a topic branch - `git checkout -b my_branch`
7
+ * Insert awesome code
8
+ * Push your branch to your forked repo - `git push origin my_branch`
9
+ * [Make a pull request](https://help.github.com/articles/using-pull-requests)
data/README.md CHANGED
@@ -37,6 +37,7 @@ directly affecting byebug and a fix for it has been released with this
37
37
  patchlevel (see [#5](https://github.com/deivid-rodriguez/byebug/issues/5) for
38
38
  more information)
39
39
 
40
+
40
41
  ## Usage
41
42
 
42
43
  Simply drop
@@ -47,23 +48,17 @@ wherever you want to start debugging and the execution will stop there. If you
47
48
  are debugging rails, start the server and once the execution get to your
48
49
  `byebug` command you will get a debugging prompt.
49
50
 
50
- _If you are coming from debugger, notice that stopping execution using the word
51
- `debugger` doesn't work anymore unless you explicitly alias it._
52
-
53
- ### Configuration
54
-
55
- You can automatically load some configurations at startup by dropping them in
56
- the startup file `.byebugrc`. For example, you can change the number of lines
57
- listed whenever byebug stops like this:
58
-
59
- set listsize 20
60
-
61
- If you are coming from [debugger](https://github.com/cldwalker/debugger), notice
62
- however that you no longer need
63
-
64
- set autoreload
51
+ Former [debugger](https://github.com/cldwalker/debugger) or
52
+ [ruby-debug](https://github.com/mark-moseley/ruby-debug) users, notice:
65
53
 
66
- because it is a default option in byebug.
54
+ * Some gems (rails, rspec) implement debugging flags (-d, --debugger) that early
55
+ require and start the debugger. This flags are a performance penalty and Byebug
56
+ doesn't need them anymore so my recommendation is not to use them.
57
+ * Stopping execution using the word `debugger` doesn't work anymore unless you
58
+ explicitly alias it. Similarly, the startup configuration file is now called
59
+ `.byebugrc` instead of `.rdebugrc`.
60
+ * `autoreload`, `autoeval` and `autolist` are default options in Byebug so you
61
+ no longer need to set them in the startup file.
67
62
 
68
63
 
69
64
  ## What's different from debugger
@@ -75,14 +70,14 @@ because it is a default option in byebug.
75
70
  - Line number wrongly shown as zero in backtrace.
76
71
  - Line tracing.
77
72
  - Colon delimited include paths.
78
- - Nice markdow guide.
73
+ - Nice markdown guide.
79
74
  - Ruby 2.0 support.
80
75
  - where/bt does not in fact give a backtrace.
81
76
  - `byebug` can now be placed at the end of a block or method call.
82
77
  * Very actively mantained.
83
78
  * Editor agnostic: no external editor built-in support.
84
- * No thread support as not supported by the new API yet (I hope it will come
85
- soon!).
79
+ * No thread support. Haven't had time to look at it and I don't know whether
80
+ the new debugging API supports it yet.
86
81
  * Pry command is built-in. No need of external gem like debugger-pry.
87
82
 
88
83
 
@@ -244,6 +239,8 @@ quit without being prompted, suffix the command with an exclamation mark, e.g.,
244
239
 
245
240
  * [pry-byebug](https://github.com/deivid-rodriguez/pry-byebug) adds `next`,
246
241
  `step`, `finish`, `continue` and `break` commands to pry using byebug.
242
+ * [ruby-debug-passenger](https://github.com/davejamesmiller/ruby-debug-passenger)
243
+ adds a rake task that restarts Passenger with byebug connected.
247
244
 
248
245
 
249
246
  ## Credits
@@ -5,12 +5,7 @@ module Byebug
5
5
  self.allow_in_control = true
6
6
 
7
7
  def regexp
8
- / ^\s*
9
- b(?:reak)?
10
- (?: \s+ #{Position_regexp})? \s*
11
- (?: \s+ (.*))? \s*
12
- $
13
- /x
8
+ /^\s* b(?:reak)? (?:\s+#{Position_regexp})? (?:\s+(.+))? \s*$/x
14
9
  end
15
10
 
16
11
  def execute
@@ -4,9 +4,7 @@ module Byebug
4
4
  self.allow_in_control = true
5
5
 
6
6
  def regexp
7
- /^\s* cat(?:ch)?
8
- (?:\s+ (\S+))?
9
- (?:\s+ (off))? \s* $/ix
7
+ /^\s* cat(?:ch)? (?:\s+(\S+))? (?:\s+(off))? \s*$/ix
10
8
  end
11
9
 
12
10
  def execute
@@ -39,11 +37,9 @@ module Byebug
39
37
  end
40
38
 
41
39
  def description
42
- %{cat[ch]\t\tsame as "info catch"
43
- cat[ch] <exception-name> [on|off]
44
- \tIntercept <exception-name> when there would otherwise be no handler.
45
- \tWith an "on" or "off", turn handling the exception on or off.
46
- cat[ch] off\tdelete all catchpoints}
40
+ %{cat[ch]\t\t\t\tLists catchpoints
41
+ cat[ch] off\t\t\tDeletes all catchpoints
42
+ cat[ch] <exception> [off]\tEnable/disable handling <exception>.}
47
43
  end
48
44
  end
49
45
  end
@@ -3,12 +3,11 @@ module Byebug
3
3
  class ConditionCommand < Command
4
4
 
5
5
  def regexp
6
- /^\s* cond(?:ition)? (?:\s+(\d+)\s*(.*))?$/ix
6
+ /^\s* cond(?:ition)? (?:\s+(\d+)(?:\s+(.*))?)? \s*$/ix
7
7
  end
8
8
 
9
9
  def execute
10
- return errmsg "\"condition\" must be followed by " \
11
- "breakpoint number and expression\n" unless @match[1]
10
+ return print ConditionCommand.help(nil) unless @match[1]
12
11
 
13
12
  breakpoints = Byebug.breakpoints.sort_by{|b| b.id }
14
13
  largest = breakpoints.inject(0) do |tally, b|
@@ -17,12 +16,9 @@ module Byebug
17
16
 
18
17
  return print "No breakpoints have been set.\n" if 0 == largest
19
18
  return unless pos = get_int(@match[1], "Condition", 1, largest)
20
- breakpoints.each do |b|
21
- if b.id == pos
22
- b.expr = @match[2].empty? ? nil : @match[2]
23
- break
24
- end
25
- end
19
+
20
+ b = breakpoints.select{ |b| b.id == pos }.first
21
+ b.expr = @match[2] if b
26
22
  end
27
23
 
28
24
  class << self
@@ -6,7 +6,7 @@ module Byebug
6
6
  self.need_context = false
7
7
 
8
8
  def regexp
9
- /^\s* c(?:ont(?:inue)?)? (?:\s+(.*))? $/x
9
+ /^\s* c(?:ont(?:inue)?)? (?:\s+(\S+))? \s*$/x
10
10
  end
11
11
 
12
12
  def execute
@@ -4,11 +4,7 @@ module Byebug
4
4
  self.allow_in_control = true
5
5
 
6
6
  def regexp
7
- / ^\s*
8
- (?:restart|R)
9
- (?:\s+ (\S?.*\S))? \s*
10
- $
11
- /ix
7
+ /^\s* (?:restart|R) (?:\s+(.+))? \s*$/ix
12
8
  end
13
9
 
14
10
  def execute
@@ -23,7 +23,7 @@ module Byebug
23
23
 
24
24
  class AddDisplayCommand < Command
25
25
  def regexp
26
- /^\s*disp(?:lay)?\s+(.+)$/
26
+ /^\s* disp(?:lay)? \s+ (.+) \s*$/x
27
27
  end
28
28
 
29
29
  def execute
@@ -55,7 +55,7 @@ module Byebug
55
55
  end
56
56
 
57
57
  def regexp
58
- /^\s*disp(?:lay)?$/
58
+ /^\s* disp(?:lay)? \s*$/x
59
59
  end
60
60
 
61
61
  def execute
@@ -75,7 +75,7 @@ module Byebug
75
75
 
76
76
  class DeleteDisplayCommand < Command
77
77
  def regexp
78
- /^\s* undisp(?:lay)? \s* (?:(\S+))?$/x
78
+ /^\s* undisp(?:lay)? (?:\s+(\S+))? \s*$/x
79
79
  end
80
80
 
81
81
  def execute
@@ -4,7 +4,7 @@ module Byebug
4
4
  self.allow_in_control = true
5
5
 
6
6
  def regexp
7
- /^\s* ed(?:it)? (?:\s+(.*))?$/ix
7
+ /^\s* ed(?:it)? (?:\s+(\S+))? \s*$/ix
8
8
  end
9
9
 
10
10
  def execute
@@ -60,7 +60,7 @@ module Byebug
60
60
  end unless defined?(Subcommands)
61
61
 
62
62
  def regexp
63
- /^\s* en(?:able)? (?:\s+(.*))?$/ix
63
+ /^\s* en(?:able)? (?:\s+(.+))? \s*$/ix
64
64
  end
65
65
 
66
66
  def execute
@@ -91,8 +91,10 @@ module Byebug
91
91
  end
92
92
 
93
93
  def description
94
- %{Enable some things.
95
- This is used to cancel the effect of the "disable" command.}
94
+ %{Enable breakpoints or displays.
95
+
96
+ This is used to cancel the effect of the "disable" command.
97
+ }
96
98
  end
97
99
  end
98
100
  end
@@ -112,7 +114,7 @@ module Byebug
112
114
  end unless defined?(Subcommands)
113
115
 
114
116
  def regexp
115
- /^\s* dis(?:able)? (?:\s+(.*))?$/ix
117
+ /^\s* dis(?:able)? (?:\s+(.+))? \s*$/ix
116
118
  end
117
119
 
118
120
  def execute
@@ -143,10 +145,11 @@ module Byebug
143
145
  end
144
146
 
145
147
  def description
146
- %{Disable some things.
148
+ %{Disable breakpoints or displays.
147
149
 
148
150
  A disabled item is not forgotten, but has no effect until reenabled.
149
- Use the "enable" command to have it take effect again.}
151
+ Use the "enable" command to have it take effect again.
152
+ }
150
153
  end
151
154
  end
152
155
  end
@@ -43,7 +43,7 @@ module Byebug
43
43
  end
44
44
 
45
45
  def regexp
46
- /^\s*(p|e(?:val)?)\s+/
46
+ /^\s*(p|e(?:val)?)\s+/x
47
47
  end
48
48
 
49
49
  def execute
@@ -6,7 +6,7 @@ module Byebug
6
6
  self.need_context = true
7
7
 
8
8
  def regexp
9
- /^\s*fin(?:ish)? (?:\s+(.*))?$/x
9
+ /^\s* fin(?:ish)? (?:\s+(\S+))? \s*$/x
10
10
  end
11
11
 
12
12
  def execute
@@ -2,7 +2,6 @@ module Byebug
2
2
 
3
3
  # Mix-in module to assist in command parsing.
4
4
  module FrameFunctions
5
-
6
5
  def c_frame?(frame_no)
7
6
  @state.context.frame_binding(frame_no).nil?
8
7
  end
@@ -104,7 +103,9 @@ module Byebug
104
103
  end
105
104
 
106
105
  def print_backtrace
107
- realsize = caller.drop_while {|e| e[/\(eval\)|byebug/] }.size
106
+ realsize = caller_locations.
107
+ drop_while{ |l| IGNORED_FILES.include?(l.path) || l.path == '(eval)' }.
108
+ take_while{ |l| !IGNORED_FILES.include?(l.path) }.size
108
109
  if @state.context.stack_size != realsize
109
110
  errmsg "Warning, Byebug's stacksize (#{@state.context.stack_size}) is" \
110
111
  " incorrect (must be #{realsize}). This might be a bug in " \
@@ -150,7 +151,7 @@ module Byebug
150
151
  # Implements byebug "where" or "backtrace" command.
151
152
  class WhereCommand < Command
152
153
  def regexp
153
- /^\s*(?:w(?:here)?|bt|backtrace)$/
154
+ /^\s* (?:w(?:here)?|bt|backtrace) \s*$/x
154
155
  end
155
156
 
156
157
  def execute
@@ -177,7 +178,7 @@ module Byebug
177
178
 
178
179
  class UpCommand < Command
179
180
  def regexp
180
- /^\s* u(?:p)? (?:\s+(.*))?$/x
181
+ /^\s* u(?:p)? (?:\s+(\S+))? \s*$/x
181
182
  end
182
183
 
183
184
  def execute
@@ -199,7 +200,7 @@ module Byebug
199
200
 
200
201
  class DownCommand < Command
201
202
  def regexp
202
- /^\s* down (?:\s+(.*))? .*$/x
203
+ /^\s* down (?:\s+(\S+))? \s*$/x
203
204
  end
204
205
 
205
206
  def execute
@@ -221,10 +222,7 @@ module Byebug
221
222
 
222
223
  class FrameCommand < Command
223
224
  def regexp
224
- / ^\s*
225
- f(?:rame)?
226
- (?: \s+ (\S+))? \s*
227
- $/x
225
+ /^\s* f(?:rame)? (?:\s+(\S+))? \s*$/x
228
226
  end
229
227
 
230
228
  def execute
@@ -7,7 +7,7 @@ module Byebug
7
7
  self.allow_in_control = true
8
8
 
9
9
  def regexp
10
- /^\s* h(?:elp)? (?:\s+(.+))? $/x
10
+ /^\s* h(?:elp)? (?:\s+(.+))? \s*$/x
11
11
  end
12
12
 
13
13
  def execute
@@ -15,7 +15,7 @@ module Byebug
15
15
  args = @match[1].split
16
16
  cmds = @state.commands.select { |cmd| cmd.names.include?(args[0]) }
17
17
  unless cmds.empty?
18
- help = cmds.map{ |cmd| cmd.help(args) }.join
18
+ help = cmds.map{ |cmd| cmd.help(args) }.join("\n")
19
19
  help = help.split("\n").map{|l| l.gsub(/^ +/, '')}
20
20
  help.shift if help.first && help.first.empty?
21
21
  help.pop if help.last && help.last.empty?
@@ -63,7 +63,7 @@ module Byebug
63
63
  end unless defined?(InfoFileSubcommands)
64
64
 
65
65
  def regexp
66
- /^\s* i(?:nfo)? (?:\s+(.*))?$/ix
66
+ /^\s* i(?:nfo)? (?:\s+(.+))? \s*$/ix
67
67
  end
68
68
 
69
69
  def execute
@@ -9,12 +9,7 @@ module Byebug
9
9
  end
10
10
 
11
11
  def regexp
12
- / ^\s*
13
- j(?:ump)? \s*
14
- (?:\s+(\S+))?\s*
15
- (?:\s+(\S+))?\s*
16
- $
17
- /ix
12
+ /^\s* j(?:ump)? (?:\s+(\S+))? \s* (?:\s+(\S+))? \s*$/ix
18
13
  end
19
14
 
20
15
  def execute
@@ -23,10 +18,8 @@ module Byebug
23
18
 
24
19
  line = @match[1].to_i
25
20
  line = @state.context.frame_line(0) + line if @match[1][0] == '+' or @match[1][0] == '-'
26
- if line == @state.context.frame_line(0)
27
- CommandProcessor.print_location_and_text(@state.context.frame_file(0), line)
28
- return
29
- end
21
+ return aprint @state.location if line == @state.context.frame_line(0)
22
+
30
23
  file = @match[2]
31
24
  file = @state.context.frame_file(file.to_i) if numeric?(file)
32
25
  file = @state.context.frame_file(0) if !file
@@ -14,7 +14,7 @@ module Byebug
14
14
  Command.settings[:autolist] = 1
15
15
 
16
16
  def regexp
17
- /^\s* l(?:ist)? (?:\s*([-=])|\s+(.+))? $/x
17
+ /^\s* l(?:ist)? (?:\s*([-=])|\s+(\S+))? \s*$/x
18
18
  end
19
19
 
20
20
  def execute
@@ -10,7 +10,7 @@ module Byebug
10
10
  # Implements byebug's 'method sig' command.
11
11
  class MethodSigCommand < Command
12
12
  def regexp
13
- /^\s*m(?:ethod)?\s+sig(?:nature)?\s+(\S+)\s*$/
13
+ /^\s* m(?:ethod)? \s+ sig(?:nature)? \s+ (\S+) \s*$/x
14
14
  end
15
15
 
16
16
  def execute
@@ -42,7 +42,7 @@ module Byebug
42
42
  include Columnize
43
43
 
44
44
  def regexp
45
- /^\s*m(?:ethod)?\s+((iv)|(i(:?nstance)?)\s+)?/
45
+ /^\s* m(?:ethod)? \s+ ((iv)|(i(:?nstance)?)\s+)?/x
46
46
  end
47
47
 
48
48
  def execute
@@ -5,11 +5,7 @@ module Byebug
5
5
  self.allow_in_control = true
6
6
 
7
7
  def regexp
8
- / ^\s*
9
- (?:q(?:uit)?|exit) \s*
10
- (!|\s+unconditionally)? \s*
11
- $
12
- /ix
8
+ /^\s* (?:q(?:uit)?|exit) \s* (!|\s+unconditionally)? \s*$/ix
13
9
  end
14
10
 
15
11
  def execute
@@ -25,8 +21,7 @@ module Byebug
25
21
  end
26
22
 
27
23
  def description
28
- %{q[uit][ !| unconditionally]\texit from byebug.
29
- exit[!]\talias to quit
24
+ %{q[uit]|exit [!|unconditionally]\tExits from byebug.
30
25
 
31
26
  Normally we prompt before exiting. However if the parameter
32
27
  "unconditionally" is given or command is suffixed with !, we exit
@@ -14,7 +14,7 @@ module Byebug
14
14
  Command.settings[:autoreload] = true
15
15
 
16
16
  def regexp
17
- /^\s*r(?:eload)?$/
17
+ /^\s* r(?:eload)? \s*$/x
18
18
  end
19
19
 
20
20
  def execute
@@ -84,7 +84,7 @@ module Byebug
84
84
  else
85
85
  file = @state.context.frame_file(0)
86
86
  line = @state.context.frame_line(0)
87
- CommandProcessor.print_location_and_text(file, line)
87
+ print @state.location
88
88
  @state.previous_line = nil
89
89
  end
90
90
  end
@@ -49,9 +49,7 @@ module Byebug
49
49
  end
50
50
 
51
51
  def regexp
52
- /^\s* sa(?:ve)?
53
- (?:\s+(.+))?
54
- \s*$/ix
52
+ /^\s* sa(?:ve)? (?:\s+(\S+))? \s*$/ix
55
53
  end
56
54
 
57
55
  def execute
@@ -62,7 +60,7 @@ module Byebug
62
60
  end
63
61
  save_breakpoints(file)
64
62
  save_catchpoints(file)
65
- # save_displays(file)
63
+ save_displays(file)
66
64
  save_settings(file)
67
65
  print "Saved to '#{file.path}'\n"
68
66
  if @state and @state.interface
@@ -46,7 +46,7 @@ module Byebug
46
46
  self.allow_in_control = true
47
47
 
48
48
  def regexp
49
- /^set (?: \s+ (.*) )?$/ix
49
+ /^\s* set (?:\s+(.*))? \s*$/ix
50
50
  end
51
51
 
52
52
  def execute
@@ -193,7 +193,7 @@ module Byebug
193
193
  self.allow_in_control = true
194
194
 
195
195
  def regexp
196
- /^show (?: \s+ (.+) )?$/xi
196
+ /^\s* show (?:\s+(.+))? \s*$/xi
197
197
  end
198
198
 
199
199
  def execute
@@ -5,10 +5,7 @@ module Byebug
5
5
  self.allow_in_control = true
6
6
 
7
7
  def regexp
8
- / ^\s*
9
- sk(?:ip)? \s*
10
- $
11
- /ix
8
+ /^\s* sk(?:ip)? \s*$/ix
12
9
  end
13
10
 
14
11
  def execute
@@ -5,7 +5,7 @@ module Byebug
5
5
  self.allow_in_control = true
6
6
 
7
7
  def regexp
8
- /^\s* so(?:urce)? (?:\s+ (.+))? $/x
8
+ /^\s* so(?:urce)? (?:\s+(\S+))? \s*$/x
9
9
  end
10
10
 
11
11
  def execute
@@ -21,9 +21,7 @@ module Byebug
21
21
  self.need_context = true
22
22
 
23
23
  def regexp
24
- /^\s* n(?:ext)?
25
- ([+-])?(?:\s+(\S+))?
26
- \s*$/x
24
+ /^\s* n(?:ext)?([+-])? (?:\s+(\S+))? \s*$/x
27
25
  end
28
26
 
29
27
  def execute
@@ -52,9 +50,7 @@ module Byebug
52
50
  self.need_context = true
53
51
 
54
52
  def regexp
55
- /^\s* s(?:tep)?
56
- ([+-])?(?:\s+(\S+))?
57
- \s*$/x
53
+ /^\s* s(?:tep)?([+-]) ?(?:\s+(\S+))? \s*$/x
58
54
  end
59
55
 
60
56
  def execute
@@ -2,10 +2,10 @@ module Byebug
2
2
 
3
3
  class TraceCommand < Command
4
4
  def regexp
5
- /^\s* tr(?:ace)? (?: \s+ (\S+)) # on | off | var(iable)
6
- (?: \s+ (\S+))? # (variable-name)?
7
- (?: \s+ (\S+))? \s* # (stop | nostop)?
8
- $/ix
5
+ /^\s* tr(?:ace)? (?: \s+ (\S+)) # on | off | var(iable)
6
+ (?: \s+ (\S+))? # (variable-name)?
7
+ (?: \s+ (\S+))? # (stop | nostop)?
8
+ \s*$/ix
9
9
  end
10
10
 
11
11
  def execute
@@ -29,7 +29,7 @@ module Byebug
29
29
  # Implements byebug's 'var class' command
30
30
  class VarClassVarCommand < Command
31
31
  def regexp
32
- /^\s*v(?:ar)?\s+cl(?:ass)?/
32
+ /^\s* v(?:ar)? \s+ cl(?:ass)? \s*/x
33
33
  end
34
34
 
35
35
  def execute
@@ -53,7 +53,7 @@ module Byebug
53
53
 
54
54
  class VarConstantCommand < Command
55
55
  def regexp
56
- /^\s*v(?:ar)?\s+co(?:nst(?:ant)?)?\s+/
56
+ /^\s* v(?:ar)? \s+ co(?:nst(?:ant)?)? \s+/x
57
57
  end
58
58
 
59
59
  def execute
@@ -84,7 +84,7 @@ module Byebug
84
84
 
85
85
  class VarGlobalCommand < Command
86
86
  def regexp
87
- /^\s*v(?:ar)?\s+g(?:lobal)?\s*$/
87
+ /^\s* v(?:ar)? \s+ g(?:lobal)? \s*$/x
88
88
  end
89
89
 
90
90
  def execute
@@ -104,7 +104,7 @@ module Byebug
104
104
 
105
105
  class VarInstanceCommand < Command
106
106
  def regexp
107
- /^\s*v(?:ar)?\s+ins(?:tance)?\s*/
107
+ /^\s* v(?:ar)? \s+ ins(?:tance)? \s*/x
108
108
  end
109
109
 
110
110
  def execute
@@ -126,7 +126,7 @@ module Byebug
126
126
  # Implements byebug's 'var local' command
127
127
  class VarLocalCommand < Command
128
128
  def regexp
129
- /^\s*v(?:ar)?\s+l(?:ocal)?\s*$/
129
+ /^\s* v(?:ar)? \s+ l(?:ocal)? \s*$/x
130
130
  end
131
131
 
132
132
  def execute
@@ -158,7 +158,7 @@ module Byebug
158
158
  # Implements byebug's 'var inherit' command
159
159
  class VarInheritCommand < Command
160
160
  def regexp
161
- /^\s*v(?:ar)?\s+ct\s*/
161
+ /^\s* v(?:ar)? \s+ ct \s*$/x
162
162
  end
163
163
 
164
164
  def execute
@@ -26,19 +26,22 @@ module Byebug
26
26
  end
27
27
 
28
28
  def aprint(msg)
29
- print afmt(msg)
29
+ print afmt(msg) if Byebug.annotate.to_i > 2
30
30
  end
31
31
 
32
- protected
33
- def format(*args)
34
- if args.is_a?(Array)
35
- new_args = args.first
36
- new_args = new_args % args[1..-1] unless args[1..-1].empty?
37
- else
38
- new_args = args
39
- end
40
- new_args.gsub('%', '%%')
32
+ def format(*args)
33
+ if args.is_a?(Array)
34
+ new_args = args.first
35
+ new_args = new_args % args[1..-1] unless args[1..-1].empty?
36
+ else
37
+ new_args = args
41
38
  end
39
+ new_args
40
+ end
41
+
42
+ def escape(msg)
43
+ msg.gsub('%', '%%')
44
+ end
42
45
  end
43
46
 
44
47
  class LocalInterface < Interface
@@ -72,7 +75,7 @@ module Byebug
72
75
  end
73
76
 
74
77
  def print(*args)
75
- STDOUT.printf(format(*args))
78
+ STDOUT.printf(escape(format(*args)))
76
79
  end
77
80
 
78
81
  def close
@@ -9,17 +9,11 @@ module Byebug
9
9
  attr_accessor :interface
10
10
 
11
11
  extend Forwardable
12
- def_delegators :@interface, :errmsg, :print
12
+ def_delegators :@interface, :errmsg, :print, :aprint, :afmt
13
13
 
14
- # Format msg with gdb-style annotation header
15
- def afmt(msg, newline="\n")
16
- "\032\032#{msg}#{newline}"
17
- end
18
-
19
- def aprint(msg)
20
- print afmt(msg) if Byebug.annotate.to_i > 2
14
+ def initialize(interface)
15
+ @interface = interface
21
16
  end
22
-
23
17
  end
24
18
 
25
19
  class CommandProcessor < Processor
@@ -42,16 +36,16 @@ module Byebug
42
36
  ]
43
37
 
44
38
  def initialize(interface = LocalInterface.new)
45
- @interface = interface
46
- @display = []
39
+ super(interface)
47
40
 
41
+ @display = []
48
42
  @mutex = Mutex.new
49
43
  @last_cmd = nil # To allow empty (just <RET>) commands
50
44
  @last_file = nil # Filename the last time we stopped
51
- @last_line = nil # line number the last time we stopped
45
+ @last_line = nil # Line number the last time we stopped
52
46
  @breakpoints_were_empty = false # Show breakpoints 1st time
53
47
  @displays_were_empty = true # No display 1st time
54
- @context_was_dead = true # Assume we haven't started.
48
+ @context_was_dead = false # Assume we haven't started.
55
49
  end
56
50
 
57
51
  def interface=(interface)
@@ -81,21 +75,6 @@ module Byebug
81
75
  end
82
76
  end
83
77
 
84
- def self.print_location_and_text(file, line)
85
- if file == '(irb)' || file == '-e'
86
- file_line = "#{canonic_file(file)} @ #{line}\n"
87
- else
88
- file_line = "#{canonic_file(file)} @ #{line}\n" \
89
- "#{Byebug.line_at(file, line)}\n"
90
- end
91
-
92
- # FIXME: use annotations routines
93
- if Byebug.annotate.to_i > 2
94
- file_line = "\032\032source #{file_line}"
95
- end
96
- print file_line
97
- end
98
-
99
78
  def self.protect(mname)
100
79
  alias_method "__#{mname}", mname
101
80
  module_eval %{
@@ -116,19 +95,17 @@ module Byebug
116
95
  end
117
96
 
118
97
  def at_breakpoint(context, breakpoint)
119
- aprint 'stopped' if Byebug.annotate.to_i > 2
98
+ aprint 'stopped'
120
99
  n = Byebug.breakpoints.index(breakpoint) + 1
121
100
  file = CommandProcessor.canonic_file(breakpoint.source)
122
101
  line = breakpoint.pos
123
- if Byebug.annotate.to_i > 2
124
- print afmt("source #{file}:#{line}")
125
- end
102
+ aprint "source #{file}:#{line}"
126
103
  print "Stopped by breakpoint #{n} at #{file}:#{line}\n"
127
104
  end
128
105
  protect :at_breakpoint
129
106
 
130
107
  def at_catchpoint(context, excpt)
131
- aprint 'stopped' if Byebug.annotate.to_i > 2
108
+ aprint 'stopped'
132
109
  file = CommandProcessor.canonic_file(context.frame_file(0))
133
110
  line = context.frame_line(0)
134
111
  print "Catchpoint at %s:%d: `%s' (%s)\n", file, line, excpt, excpt.class
@@ -190,7 +167,7 @@ module Byebug
190
167
  cmd.allow_in_post_mortem
191
168
  end if context.dead?
192
169
 
193
- state = State.new(event_cmds, context, display, file, interface, line)
170
+ state = State.new(event_cmds, context, @display, file, @interface, line)
194
171
 
195
172
  # Change default when in irb or code included in command line
196
173
  Command.settings[:autolist] = 0 if file == '(irb)' or file == '-e'
@@ -232,9 +209,7 @@ module Byebug
232
209
  $state = Command.settings[:testing] ? state : nil
233
210
 
234
211
  preloop(commands, context)
235
- if Command.settings[:autolist] == 0
236
- CommandProcessor.print_location_and_text(file, line)
237
- end
212
+ aprint state.location if Command.settings[:autolist] == 0
238
213
 
239
214
  while !state.proceed?
240
215
  input = @interface.command_queue.empty? ?
@@ -280,12 +255,14 @@ module Byebug
280
255
  def preloop(commands, context)
281
256
  @context_was_dead = true if context.dead? and not @context_was_dead
282
257
 
258
+ aprint 'stopped'
259
+ if @context_was_dead
260
+ aprint 'exited'
261
+ print "The program finished.\n"
262
+ @context_was_dead = false
263
+ end
264
+
283
265
  if Byebug.annotate.to_i > 2
284
- aprint('stopped')
285
- if @context_was_dead
286
- aprint('exited')
287
- print "The program finished.\n"
288
- end
289
266
  breakpoint_annotations(commands, context)
290
267
  display_annotations(commands, context)
291
268
  annotation('stack', commands, context, "where")
@@ -307,7 +284,7 @@ module Byebug
307
284
  context.dead?
308
285
  end
309
286
  if not context.dead? and @@Show_annotations_run.find{|pat| cmd =~ pat}
310
- aprint 'starting'
287
+ afmt 'starting'
311
288
  @context_was_dead = false
312
289
  end
313
290
  end
@@ -347,7 +324,7 @@ module Byebug
347
324
  end
348
325
 
349
326
  extend Forwardable
350
- def_delegators :@interface, :errmsg, :print, :confirm
327
+ def_delegators :@interface, :aprint, :errmsg, :print, :confirm
351
328
 
352
329
  def proceed?
353
330
  @proceed
@@ -356,6 +333,12 @@ module Byebug
356
333
  def proceed
357
334
  @proceed = true
358
335
  end
336
+
337
+ def location
338
+ loc = "#{CommandProcessor.canonic_file(@file)} @ #{@line}\n"
339
+ loc += "#{Byebug.line_at(@file, @line)}\n" unless
340
+ ['(irb)', '-e'].include? @file
341
+ end
359
342
  end
360
343
 
361
344
  end # class CommandProcessor
@@ -364,9 +347,8 @@ module Byebug
364
347
  class ControlCommandProcessor < Processor
365
348
 
366
349
  def initialize(interface)
367
- super()
368
- @interface = interface
369
- @context_was_dead = true # Assume we haven't started.
350
+ super(interface)
351
+ @context_was_dead = false # Assume we haven't started.
370
352
  end
371
353
 
372
354
  def process_commands(verbose=false)
@@ -376,12 +358,10 @@ module Byebug
376
358
  state = State.new(@interface, control_cmds)
377
359
  commands = control_cmds.map{|cmd| cmd.new(state) }
378
360
 
379
- unless @context_was_dead
380
- if Byebug.annotate.to_i > 2
381
- aprint 'exited'
382
- print "The program finished.\n"
383
- end
384
- @context_was_dead = true
361
+ if @context_was_dead
362
+ aprint 'exited'
363
+ print "The program finished.\n"
364
+ @context_was_dead = false
385
365
  end
386
366
 
387
367
  while input = @interface.read_command(prompt(nil))
@@ -406,8 +386,7 @@ module Byebug
406
386
  # Note: have an unused 'context' parameter to match the local interface.
407
387
  def prompt(context)
408
388
  p = '(byebug:ctrl) '
409
- p = afmt("pre-prompt") + p + "\n" + afmt("prompt") if
410
- Byebug.annotate.to_i > 2
389
+ p = afmt("pre-prompt") +p+"\n"+ afmt("prompt") if Byebug.annotate.to_i > 2
411
390
  return p
412
391
  end
413
392
 
@@ -1,3 +1,3 @@
1
1
  module Byebug
2
- VERSION = '1.8.1'
2
+ VERSION = '1.8.2'
3
3
  end
@@ -1,14 +1,12 @@
1
1
  require_relative 'test_helper'
2
2
 
3
3
  class TestSave < TestDsl::TestCase
4
-
5
4
  describe 'successful saving' do
6
5
  let(:file_name) { 'save_output.txt' }
7
6
  let(:file_contents) { File.read(file_name) }
8
7
  before do
9
8
  enter 'break 2', 'break 3 if true', 'catch NoMethodError',
10
- 'display 2 + 3', 'display 5 + 6', 'set autoeval', 'set autolist',
11
- "save #{file_name}"
9
+ 'display 2 + 3', 'display 5 + 6', "save #{file_name}"
12
10
  debug_file 'save'
13
11
  end
14
12
  after do
@@ -27,9 +25,8 @@ class TestSave < TestDsl::TestCase
27
25
  file_contents.must_include 'catch NoMethodError'
28
26
  end
29
27
 
30
- # Not sure why it is suppressed, but this is like it is now.
31
- it 'must not save displays' do
32
- file_contents.wont_include 'display 2 + 3'
28
+ it 'must save displays' do
29
+ file_contents.must_include 'display 2 + 3'
33
30
  end
34
31
 
35
32
  describe 'saving settings' do
@@ -2,7 +2,7 @@ class TestInterface < Byebug::Interface
2
2
  attr_reader :input_queue, :output_queue, :error_queue, :confirm_queue
3
3
 
4
4
  attr_accessor :command_queue, :histfile, :history_length, :history_save
5
- attr_accessor :print_queue, :readline_support, :restart_file, :test_block
5
+ attr_accessor :readline_support, :restart_file, :test_block
6
6
 
7
7
  def initialize
8
8
  @input_queue = []
@@ -10,12 +10,11 @@ class TestInterface < Byebug::Interface
10
10
  @error_queue = []
11
11
  @confirm_queue = []
12
12
  @command_queue = []
13
- @print_queue = []
14
13
  @readline_support = false
15
14
  end
16
15
 
17
16
  def errmsg(*args)
18
- @error_queue << format(args)
17
+ @error_queue << format(*args)
19
18
  end
20
19
 
21
20
  def read_command(*args)
@@ -31,7 +30,7 @@ class TestInterface < Byebug::Interface
31
30
  end
32
31
 
33
32
  def print(*args)
34
- @output_queue << format(args)
33
+ @output_queue << format(*args)
35
34
  end
36
35
 
37
36
  def confirm(message)
@@ -54,18 +53,7 @@ class TestInterface < Byebug::Interface
54
53
  "input_queue: #{input_queue.inspect}",
55
54
  "output_queue: #{output_queue.inspect}",
56
55
  "error_queue: #{error_queue.inspect}",
57
- "confirm_queue: #{confirm_queue.inspect}",
58
- "print_queue: #{print_queue.inspect}"
56
+ "confirm_queue: #{confirm_queue.inspect}"
59
57
  ].join("\n")
60
58
  end
61
-
62
- private
63
-
64
- def format(args)
65
- if args.size > 1
66
- args.first % args[1..-1]
67
- else
68
- args.first
69
- end
70
- end
71
59
  end
@@ -29,7 +29,7 @@ class TestVariables < TestDsl::TestCase
29
29
  check_output_includes 'SOMECONST => "foo"'
30
30
  end
31
31
 
32
- it 'must show error message if given object is not a Class or a Module' do
32
+ it 'must show error message if given object is not a class or a module' do
33
33
  enter 'break 25', 'cont', 'var const v'
34
34
  debug_file 'variables'
35
35
  check_output_includes 'Should be Class/Module: v'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: byebug
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.1
4
+ version: 1.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Rodriguez
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-08-12 00:00:00.000000000 Z
13
+ date: 2013-08-16 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: columnize
@@ -218,7 +218,6 @@ files:
218
218
  - test/support/breakpoint.rb
219
219
  - test/support/context.rb
220
220
  - test/support/matchers.rb
221
- - test/support/processor.rb
222
221
  - test/support/test_dsl.rb
223
222
  - test/support/test_interface.rb
224
223
  - test/test_helper.rb
@@ -309,7 +308,6 @@ test_files:
309
308
  - test/support/breakpoint.rb
310
309
  - test/support/context.rb
311
310
  - test/support/matchers.rb
312
- - test/support/processor.rb
313
311
  - test/support/test_dsl.rb
314
312
  - test/support/test_interface.rb
315
313
  - test/test_helper.rb
@@ -1,13 +0,0 @@
1
- module Byebug
2
-
3
- class Processor
4
-
5
- class << self
6
- def print(message)
7
- Byebug.handler.interface.print_queue << message
8
- end
9
- end
10
-
11
- end
12
-
13
- end