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 +4 -4
- data/CHANGELOG.md +8 -0
- data/CONTRIBUTING.md +9 -1
- data/README.md +16 -19
- data/lib/byebug/commands/breakpoints.rb +1 -6
- data/lib/byebug/commands/catchpoint.rb +4 -8
- data/lib/byebug/commands/condition.rb +5 -9
- data/lib/byebug/commands/continue.rb +1 -1
- data/lib/byebug/commands/control.rb +1 -5
- data/lib/byebug/commands/display.rb +3 -3
- data/lib/byebug/commands/edit.rb +1 -1
- data/lib/byebug/commands/enable.rb +9 -6
- data/lib/byebug/commands/eval.rb +1 -1
- data/lib/byebug/commands/finish.rb +1 -1
- data/lib/byebug/commands/frame.rb +7 -9
- data/lib/byebug/commands/help.rb +2 -2
- data/lib/byebug/commands/info.rb +1 -1
- data/lib/byebug/commands/jump.rb +3 -10
- data/lib/byebug/commands/list.rb +1 -1
- data/lib/byebug/commands/method.rb +2 -2
- data/lib/byebug/commands/quit.rb +2 -7
- data/lib/byebug/commands/reload.rb +1 -1
- data/lib/byebug/commands/repl.rb +1 -1
- data/lib/byebug/commands/save.rb +2 -4
- data/lib/byebug/commands/set.rb +1 -1
- data/lib/byebug/commands/show.rb +1 -1
- data/lib/byebug/commands/skip.rb +1 -4
- data/lib/byebug/commands/source.rb +1 -1
- data/lib/byebug/commands/stepping.rb +2 -6
- data/lib/byebug/commands/trace.rb +4 -4
- data/lib/byebug/commands/variables.rb +6 -6
- data/lib/byebug/interface.rb +14 -11
- data/lib/byebug/processor.rb +34 -55
- data/lib/byebug/version.rb +1 -1
- data/test/save_test.rb +3 -6
- data/test/support/test_interface.rb +4 -16
- data/test/variables_test.rb +1 -1
- metadata +2 -4
- data/test/support/processor.rb +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e50f515a828a79ec3a73e802a9b480b44d4aedb
|
4
|
+
data.tar.gz: 3a613a22f8a9a5e6805899f646efbd8e5f29c5eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b1dea64be0bf3f4aa95986f80e4d468c810ce5ed6a3322a5a672d8db772548109a3c390d5a442bf0b91b6f934c2d6b18797b5782730b2b6f9a544f47ddb337f1
|
7
|
+
data.tar.gz: 7962816e1385499dce322487b27be5ec25e71f8134f65c8d6b2970ab19257ee998c9f34c2f3208fa64e8349a20ea3b0b050406be1806222b24b8ce6f9af95f1b
|
data/CHANGELOG.md
CHANGED
data/CONTRIBUTING.md
CHANGED
@@ -1 +1,9 @@
|
|
1
|
-
Thanks for
|
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
|
-
|
51
|
-
|
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
|
-
|
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
|
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
|
85
|
-
|
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
|
@@ -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\
|
43
|
-
cat[ch]
|
44
|
-
|
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+)
|
6
|
+
/^\s* cond(?:ition)? (?:\s+(\d+)(?:\s+(.*))?)? \s*$/ix
|
7
7
|
end
|
8
8
|
|
9
9
|
def execute
|
10
|
-
return
|
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
|
-
|
21
|
-
|
22
|
-
|
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
|
@@ -23,7 +23,7 @@ module Byebug
|
|
23
23
|
|
24
24
|
class AddDisplayCommand < Command
|
25
25
|
def regexp
|
26
|
-
/^\s*disp(?:lay)
|
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)?
|
78
|
+
/^\s* undisp(?:lay)? (?:\s+(\S+))? \s*$/x
|
79
79
|
end
|
80
80
|
|
81
81
|
def execute
|
data/lib/byebug/commands/edit.rb
CHANGED
@@ -60,7 +60,7 @@ module Byebug
|
|
60
60
|
end unless defined?(Subcommands)
|
61
61
|
|
62
62
|
def regexp
|
63
|
-
/^\s* en(?:able)? (?:\s+(
|
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
|
95
|
-
|
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+(
|
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
|
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
|
data/lib/byebug/commands/eval.rb
CHANGED
@@ -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 =
|
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+(
|
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+(
|
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
|
-
|
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
|
data/lib/byebug/commands/help.rb
CHANGED
@@ -7,7 +7,7 @@ module Byebug
|
|
7
7
|
self.allow_in_control = true
|
8
8
|
|
9
9
|
def regexp
|
10
|
-
/^\s* h(?:elp)? (?:\s+(.+))?
|
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?
|
data/lib/byebug/commands/info.rb
CHANGED
data/lib/byebug/commands/jump.rb
CHANGED
@@ -9,12 +9,7 @@ module Byebug
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def regexp
|
12
|
-
|
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
|
-
|
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
|
data/lib/byebug/commands/list.rb
CHANGED
@@ -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)
|
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)
|
45
|
+
/^\s* m(?:ethod)? \s+ ((iv)|(i(:?nstance)?)\s+)?/x
|
46
46
|
end
|
47
47
|
|
48
48
|
def execute
|
data/lib/byebug/commands/quit.rb
CHANGED
@@ -5,11 +5,7 @@ module Byebug
|
|
5
5
|
self.allow_in_control = true
|
6
6
|
|
7
7
|
def regexp
|
8
|
-
|
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][
|
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
|
data/lib/byebug/commands/repl.rb
CHANGED
data/lib/byebug/commands/save.rb
CHANGED
@@ -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
|
-
|
63
|
+
save_displays(file)
|
66
64
|
save_settings(file)
|
67
65
|
print "Saved to '#{file.path}'\n"
|
68
66
|
if @state and @state.interface
|
data/lib/byebug/commands/set.rb
CHANGED
data/lib/byebug/commands/show.rb
CHANGED
data/lib/byebug/commands/skip.rb
CHANGED
@@ -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+))
|
6
|
-
(?: \s+ (\S+))?
|
7
|
-
(?: \s+ (\S+))?
|
8
|
-
|
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)
|
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)
|
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)
|
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)
|
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)
|
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)
|
161
|
+
/^\s* v(?:ar)? \s+ ct \s*$/x
|
162
162
|
end
|
163
163
|
|
164
164
|
def execute
|
data/lib/byebug/interface.rb
CHANGED
@@ -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
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
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
|
data/lib/byebug/processor.rb
CHANGED
@@ -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
|
-
|
15
|
-
|
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
|
-
|
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 #
|
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 =
|
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'
|
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
|
-
|
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'
|
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
|
-
|
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
|
-
@
|
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
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
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") +
|
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
|
|
data/lib/byebug/version.rb
CHANGED
data/test/save_test.rb
CHANGED
@@ -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',
|
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
|
-
|
31
|
-
|
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 :
|
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
|
data/test/variables_test.rb
CHANGED
@@ -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
|
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.
|
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-
|
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
|