byebug 2.2.2 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +1 -1
- data/lib/byebug/command.rb +20 -34
- data/lib/byebug/commands/breakpoints.rb +1 -1
- data/lib/byebug/commands/catchpoint.rb +1 -1
- data/lib/byebug/commands/display.rb +1 -1
- data/lib/byebug/commands/enable.rb +24 -26
- data/lib/byebug/commands/eval.rb +20 -4
- data/lib/byebug/commands/info.rb +43 -42
- data/lib/byebug/commands/method.rb +2 -2
- data/lib/byebug/commands/set.rb +42 -44
- data/lib/byebug/commands/show.rb +42 -37
- data/lib/byebug/commands/trace.rb +1 -1
- data/lib/byebug/commands/variables.rb +7 -7
- data/lib/byebug/remote.rb +4 -0
- data/lib/byebug/version.rb +1 -1
- data/{old_doc → test/examples}/gcd.rb +0 -0
- data/{old_doc → test/examples}/hanoi.rb +0 -0
- data/{old_doc → test/examples}/primes.rb +0 -0
- data/{old_doc → test/examples}/test-triangle.rb +0 -0
- data/{old_doc → test/examples}/tri3.rb +0 -0
- data/{old_doc → test/examples}/triangle.rb +0 -0
- data/test/help_test.rb +2 -5
- metadata +15 -11
- data/old_doc/byebug.1 +0 -196
- data/old_doc/byebug.texi +0 -3259
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 544a00d567861047f8cf035bf512491bb07f1fd9
|
4
|
+
data.tar.gz: e039ab4629df9d2b91e27af76678d234895bef3e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e93823cb12a8f356ebd30f481661f296c82ced481d845c140fc399d07ed4aad8af44ab7e269a7b22b41b5f6d1627ab3bb505c695d7352dc0747778544e8ced7
|
7
|
+
data.tar.gz: 2b40aaa1e2e0b7d468fc1435d077328068c4d5cbfc218f87067bf377bffc30484fd38704ab04e9970656bcacf9a0764e86df9f6ddae64fec8ca6bec68bd5fca9
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -68,7 +68,7 @@ placed at the end of a block or method call.
|
|
68
68
|
|
69
69
|
## Semantic Versioning
|
70
70
|
|
71
|
-
Byebug tries to follow [semantic versioning](semver.org). Backwards
|
71
|
+
Byebug tries to follow [semantic versioning](http://semver.org). Backwards
|
72
72
|
compatibility doesn't seem like a critic issue for a debugger because it's not
|
73
73
|
supposed to be used permanently by any program, let alone in production
|
74
74
|
environments. However, I still like the idea of giving some meaning to version
|
data/lib/byebug/command.rb
CHANGED
@@ -16,7 +16,7 @@ module Byebug
|
|
16
16
|
end
|
17
17
|
|
18
18
|
class Command
|
19
|
-
Subcmd = Struct.new(:name, :min, :
|
19
|
+
Subcmd = Struct.new(:name, :min, :help)
|
20
20
|
|
21
21
|
class << self
|
22
22
|
def commands
|
@@ -31,14 +31,13 @@ module Byebug
|
|
31
31
|
need_context: false } unless defined?(DEF_OPTIONS)
|
32
32
|
|
33
33
|
def help(args)
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
output +=
|
34
|
+
if args && args[1]
|
35
|
+
output = format_subcmd(args[1])
|
36
|
+
else
|
37
|
+
output = description.gsub(/^ +/, '') + "\n"
|
38
|
+
output += format_subcmds if defined? self::Subcommands
|
39
39
|
end
|
40
|
-
|
41
|
-
return output
|
40
|
+
output
|
42
41
|
end
|
43
42
|
|
44
43
|
def find(subcmds, param)
|
@@ -57,8 +56,7 @@ module Byebug
|
|
57
56
|
return "Invalid \"#{names.join("|")}\" " \
|
58
57
|
"subcommand \"#{args[1]}\"." unless subcmd
|
59
58
|
|
60
|
-
return "#{subcmd.
|
61
|
-
"#{subcmd.long_help || '' }"
|
59
|
+
return "#{subcmd.help}.\n"
|
62
60
|
end
|
63
61
|
|
64
62
|
def format_subcmds
|
@@ -67,10 +65,9 @@ module Byebug
|
|
67
65
|
"--\n" \
|
68
66
|
"List of \"#{cmd_name}\" subcommands:\n" \
|
69
67
|
"--\n"
|
70
|
-
|
68
|
+
w = self::Subcommands.map(&:name).max_by(&:size).size
|
71
69
|
for subcmd in self::Subcommands do
|
72
|
-
s += sprintf \
|
73
|
-
"%s %-#{width}s -- %s\n", cmd_name, subcmd.name, subcmd.short_help
|
70
|
+
s += sprintf "%s %-#{w}s -- %s\n", cmd_name, subcmd.name, subcmd.help
|
74
71
|
end
|
75
72
|
return s
|
76
73
|
end
|
@@ -91,10 +88,10 @@ module Byebug
|
|
91
88
|
|
92
89
|
def method_missing(meth, *args, &block)
|
93
90
|
if meth.to_s =~ /^(.+?)=$/
|
94
|
-
|
91
|
+
options[$1.intern] = args.first
|
95
92
|
else
|
96
|
-
if
|
97
|
-
|
93
|
+
if options.has_key?(meth)
|
94
|
+
options[meth]
|
98
95
|
else
|
99
96
|
super
|
100
97
|
end
|
@@ -192,36 +189,25 @@ module Byebug
|
|
192
189
|
@state.confirm(msg) == 'y'
|
193
190
|
end
|
194
191
|
|
195
|
-
def
|
192
|
+
def bb_eval(str, b = get_binding)
|
196
193
|
begin
|
197
194
|
eval(str, b)
|
198
195
|
rescue StandardError, ScriptError => e
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
print "\tfrom #{i}\n"
|
204
|
-
end
|
205
|
-
else
|
206
|
-
print "#{e.class} Exception: #{e.message}\n"
|
196
|
+
at = eval("Thread.current.backtrace_locations", b)
|
197
|
+
print "#{at.shift}: #{e.class} Exception(#{e.message})\n"
|
198
|
+
for i in at
|
199
|
+
print "\tfrom #{i}\n"
|
207
200
|
end
|
208
201
|
nil
|
209
202
|
end
|
210
203
|
end
|
211
204
|
|
212
|
-
def
|
213
|
-
begin
|
214
|
-
eval(str, b)
|
215
|
-
rescue StandardError, ScriptError
|
216
|
-
nil
|
217
|
-
end
|
218
|
-
end
|
219
|
-
|
220
|
-
def debug_warning_eval(str, b = get_binding)
|
205
|
+
def bb_warning_eval(str, b = get_binding)
|
221
206
|
begin
|
222
207
|
eval(str, b)
|
223
208
|
rescue StandardError, ScriptError => e
|
224
209
|
print "#{e.class} Exception: #{e.message}\n"
|
210
|
+
nil
|
225
211
|
end
|
226
212
|
end
|
227
213
|
|
@@ -17,7 +17,7 @@ module Byebug
|
|
17
17
|
confirm("Delete all catchpoints? (y or n) ")
|
18
18
|
else
|
19
19
|
print "Warning #{@match[1]} is not known to be a Class\n" unless
|
20
|
-
|
20
|
+
bb_eval "#{@match[1]}.is_a?(Class)", get_binding
|
21
21
|
Byebug.add_catchpoint @match[1]
|
22
22
|
print "Catch exception #{@match[1]}.\n"
|
23
23
|
end
|
@@ -44,19 +44,18 @@ module Byebug
|
|
44
44
|
end
|
45
45
|
|
46
46
|
class EnableCommand < Command
|
47
|
-
Subcommands =
|
48
|
-
[
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
Subcmd.new(name, min, short_help, long_help)
|
47
|
+
Subcommands = [
|
48
|
+
['breakpoints', 2, 'Enable breakpoints. This is used to cancel the ' \
|
49
|
+
'effect of the "disable" command. Give breakpoint' \
|
50
|
+
' numbers (separated by spaces) as arguments or ' \
|
51
|
+
'no argument at all if you want to reenable ' \
|
52
|
+
'every breakpoint' ],
|
53
|
+
['display' , 2, 'Enable some expressions to be displayed when ' \
|
54
|
+
'program stops. Arguments are the code numbers of' \
|
55
|
+
' the expressions to resume displaying. Do "info ' \
|
56
|
+
'display" to see the current list of code numbers' ]
|
57
|
+
].map do |name, min, help|
|
58
|
+
Subcmd.new(name, min, help)
|
60
59
|
end unless defined?(Subcommands)
|
61
60
|
|
62
61
|
def regexp
|
@@ -99,19 +98,18 @@ module Byebug
|
|
99
98
|
end
|
100
99
|
|
101
100
|
class DisableCommand < Command
|
102
|
-
Subcommands =
|
103
|
-
[
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
Subcmd.new(name, min, short_help, long_help)
|
101
|
+
Subcommands = [
|
102
|
+
['breakpoints', 1, 'Disable breakpoints. A disabled breakpoint is ' \
|
103
|
+
'not forgotten, but has no effect until ' \
|
104
|
+
'reenabled. Give breakpoint numbers (separated by' \
|
105
|
+
'spaces) as arguments or no argument at all if ' \
|
106
|
+
'you want to disable every breakpoint' ],
|
107
|
+
['display' , 1, 'Disable some display expressions when program ' \
|
108
|
+
'stops. Arguments are the code numbers of the ' \
|
109
|
+
'expressions to stop displaying. Do "info ' \
|
110
|
+
'display" to see the current list of code numbers.' ]
|
111
|
+
].map do |name, min, help|
|
112
|
+
Subcmd.new(name, min, help)
|
115
113
|
end unless defined?(Subcommands)
|
116
114
|
|
117
115
|
def regexp
|
data/lib/byebug/commands/eval.rb
CHANGED
@@ -33,7 +33,11 @@ module Byebug
|
|
33
33
|
def execute
|
34
34
|
expr = @match ? @match.post_match : @input
|
35
35
|
run_with_binding do |b|
|
36
|
-
|
36
|
+
if Command.settings[:stack_on_error]
|
37
|
+
print "#{bb_eval(expr, b).inspect}\n"
|
38
|
+
else
|
39
|
+
print "#{bb_warning_eval(expr, b).inspect}\n"
|
40
|
+
end
|
37
41
|
end
|
38
42
|
rescue
|
39
43
|
print "#{$!.class} Exception: #{$!.message}\n"
|
@@ -64,7 +68,11 @@ module Byebug
|
|
64
68
|
def execute
|
65
69
|
out = StringIO.new
|
66
70
|
run_with_binding do |b|
|
67
|
-
|
71
|
+
if Command.settings[:stack_on_error]
|
72
|
+
PP.pp(bb_eval(@match.post_match, b), out)
|
73
|
+
else
|
74
|
+
PP.pp(bb_warning_eval(@match.post_match, b), out)
|
75
|
+
end
|
68
76
|
end
|
69
77
|
print out.string
|
70
78
|
rescue
|
@@ -93,7 +101,11 @@ module Byebug
|
|
93
101
|
def execute
|
94
102
|
out = StringIO.new
|
95
103
|
run_with_binding do |b|
|
96
|
-
|
104
|
+
if Command.settings[:stack_on_error]
|
105
|
+
vals = bb_eval(@match.post_match, b)
|
106
|
+
else
|
107
|
+
vals = bb_warning_eval(@match.post_match, b)
|
108
|
+
end
|
97
109
|
if vals.is_a?(Array)
|
98
110
|
vals = vals.map{|item| item.to_s}
|
99
111
|
print "#{columnize(vals, Command.settings[:width])}\n"
|
@@ -130,7 +142,11 @@ module Byebug
|
|
130
142
|
def execute
|
131
143
|
out = StringIO.new
|
132
144
|
run_with_binding do |b|
|
133
|
-
|
145
|
+
if Command.settings[:stack_on_error]
|
146
|
+
vals = bb_eval(@match.post_match, b)
|
147
|
+
else
|
148
|
+
vals = bb_warning_eval(@match.post_match, b)
|
149
|
+
end
|
134
150
|
if vals.is_a?(Array)
|
135
151
|
vals = vals.map{|item| item.to_s}
|
136
152
|
print "#{columnize(vals.sort!, Command.settings[:width])}\n"
|
data/lib/byebug/commands/info.rb
CHANGED
@@ -19,48 +19,49 @@ module Byebug
|
|
19
19
|
include Columnize
|
20
20
|
self.allow_in_control = true
|
21
21
|
|
22
|
-
Subcommands =
|
23
|
-
|
24
|
-
['
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
['catch', 3,
|
29
|
-
|
30
|
-
['display', 2, 'Expressions to display when program stops'],
|
31
|
-
['file', 4, 'Info about a particular file read in',
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
['
|
38
|
-
|
39
|
-
['
|
40
|
-
|
41
|
-
|
42
|
-
['
|
43
|
-
['
|
44
|
-
['
|
45
|
-
|
46
|
-
|
47
|
-
|
22
|
+
Subcommands = [
|
23
|
+
['args' , 1, 'Argument variables of current stack frame' ],
|
24
|
+
['breakpoints' , 1, 'Status of user-settable breakpoints',
|
25
|
+
'Without argument, list info about all ' \
|
26
|
+
'breakpoints. With an integer argument, ' \
|
27
|
+
'list info on that breakpoint.' ],
|
28
|
+
['catch' , 3, 'Exceptions that can be caught in the ' \
|
29
|
+
'current stack frame' ],
|
30
|
+
['display' , 2, 'Expressions to display when program stops' ],
|
31
|
+
['file' , 4, 'Info about a particular file read in',
|
32
|
+
'After the file name is supplied, you can' \
|
33
|
+
'list file attributes that you wish to ' \
|
34
|
+
'see. Attributes include: "all", "basic",' \
|
35
|
+
' "breakpoint", "lines", "mtime", "path" ' \
|
36
|
+
'and "sha1".' ],
|
37
|
+
['files' , 5, 'File names and timestamps of files read in' ],
|
38
|
+
['global_variables' , 2, 'Global variables' ],
|
39
|
+
['instance_variables', 2, 'Instance variables in current stack frame' ],
|
40
|
+
['line' , 2, 'Line number and file name of current ' \
|
41
|
+
'position in source file' ],
|
42
|
+
['locals' , 2, 'Local variables of the current stack frame' ],
|
43
|
+
['program' , 2, 'Execution status of the program' ],
|
44
|
+
['stack' , 2, 'Backtrace of the stack' ],
|
45
|
+
['variables' , 1, 'Local and instance variables of the ' \
|
46
|
+
'current stack frame' ]
|
47
|
+
].map do |name, min, help|
|
48
|
+
Subcmd.new(name, min, help)
|
48
49
|
end unless defined?(Subcommands)
|
49
50
|
|
50
|
-
InfoFileSubcommands =
|
51
|
-
[
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
51
|
+
InfoFileSubcommands = [
|
52
|
+
['all' , 1, 'All file information available - breakpoints, ' \
|
53
|
+
'lines, mtime, path and sha1' ],
|
54
|
+
['basic' , 2, 'basic information - path, number of lines' ],
|
55
|
+
['breakpoints', 2, 'Show trace line numbers',
|
56
|
+
'These are the line number where a breakpoint ' \
|
57
|
+
'can be set.' ],
|
58
|
+
['lines' , 1, 'Show number of lines in the file' ],
|
59
|
+
['mtime' , 1, 'Show modification time of file' ],
|
60
|
+
['path' , 4, 'Show full file path name for file' ],
|
61
|
+
['sha1' , 1, 'Show SHA1 hash of contents of the file' ]
|
62
|
+
].map do |name, min, help|
|
63
|
+
Subcmd.new(name, min, help)
|
64
|
+
end unless defined?(InfoFileSubcommands)
|
64
65
|
|
65
66
|
def regexp
|
66
67
|
/^\s* i(?:nfo)? (?:\s+(.+))? \s*$/x
|
@@ -194,7 +195,7 @@ module Byebug
|
|
194
195
|
end
|
195
196
|
|
196
197
|
def info_instance_variables(*args)
|
197
|
-
obj =
|
198
|
+
obj = bb_eval('self')
|
198
199
|
var_list(obj.instance_variables)
|
199
200
|
end
|
200
201
|
|
@@ -260,7 +261,7 @@ module Byebug
|
|
260
261
|
locals[:self] = @state.context.frame_self(@state.frame_pos)
|
261
262
|
print_hash(locals)
|
262
263
|
|
263
|
-
obj =
|
264
|
+
obj = bb_eval('self')
|
264
265
|
var_list(obj.instance_variables, obj.instance_eval{binding()})
|
265
266
|
var_class_self
|
266
267
|
end
|
@@ -14,7 +14,7 @@ module Byebug
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def execute
|
17
|
-
obj =
|
17
|
+
obj = bb_eval('method(:%s)' % @match[1])
|
18
18
|
if obj.is_a?(Method)
|
19
19
|
begin
|
20
20
|
print "%s\n", obj.signature.to_s
|
@@ -46,7 +46,7 @@ module Byebug
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def execute
|
49
|
-
obj =
|
49
|
+
obj = bb_eval(@match.post_match)
|
50
50
|
if @match[1] == "iv"
|
51
51
|
obj.instance_variables.sort.each do |v|
|
52
52
|
print "#{v} = #{obj.instance_variable_get(v).inspect}\n"
|
data/lib/byebug/commands/set.rb
CHANGED
@@ -63,51 +63,49 @@ module Byebug
|
|
63
63
|
|
64
64
|
# Implements byebug "set" command.
|
65
65
|
class SetCommand < Command
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
SubcmdStruct2.new(name, min, is_bool, short_help, long_help)
|
66
|
+
Subcmd2 = Struct.new(:name, :min, :is_bool, :help) unless defined?(Subcmd2)
|
67
|
+
|
68
|
+
Subcommands = [
|
69
|
+
['args' , 2 , false, 'Set argument list to the program ' \
|
70
|
+
'being debugged when it is started' ],
|
71
|
+
['autoeval' , 4 , true , 'Evaluate every unrecognized command' ],
|
72
|
+
['autolist' , 4 , true , 'Execute "list" command on every ' \
|
73
|
+
'breakpoint' ],
|
74
|
+
['autoirb' , 4 , true , 'Invoke IRB on every stop' ],
|
75
|
+
['autoreload' , 4 , true , 'Reload source code when changed' ],
|
76
|
+
['basename' , 1 , true , 'Set filename display style' ],
|
77
|
+
['callstyle' , 2 , false, 'Set how you want call parameters ' \
|
78
|
+
'displayed' ],
|
79
|
+
['testing' , 2 , false, 'Used when testing byebug' ],
|
80
|
+
['forcestep' , 2 , true , 'Make sure "next/step" commands always' \
|
81
|
+
'move to a new line' ],
|
82
|
+
['fullpath' , 2 , true , 'Display full file names in frames' ],
|
83
|
+
['history' , 2 , false, 'Command for setting command history ' \
|
84
|
+
'parameters, namely, "filename", ' \
|
85
|
+
'"save" and "size"' ],
|
86
|
+
['linetrace' , 3 , true , 'Enable line execution tracing' ],
|
87
|
+
['linetrace_plus', 10, true , 'Set line execution tracing to show' \
|
88
|
+
'different lines' ],
|
89
|
+
['listsize' , 3 , false, 'Set number of source lines to list by' \
|
90
|
+
'default' ],
|
91
|
+
['post_mortem' , 2 , true , 'Enable post-mortem mode' ],
|
92
|
+
['stack_on_error', 1 , true , 'Display stack trace when "eval" ' \
|
93
|
+
'raises exception' ],
|
94
|
+
['verbose' , 1 , true , 'Enable verbose output of TracePoint ' \
|
95
|
+
'API events is enabled' ],
|
96
|
+
['width' , 1 , false, 'Number of characters per line for ' \
|
97
|
+
'byebug\'s output' ]
|
98
|
+
].map do |name, min, is_bool, help|
|
99
|
+
Subcmd2.new(name, min, is_bool, help)
|
101
100
|
end unless defined?(Subcommands)
|
102
101
|
|
103
|
-
SetHistorySubcommands =
|
104
|
-
[
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
end unless defined?(SetHistorySubcommands)
|
102
|
+
SetHistorySubcommands = [
|
103
|
+
['filename', 1, 'Set the filename in which to record command history'],
|
104
|
+
['save' , 1, 'Set saving of the history record on exit' ],
|
105
|
+
['size' , 1, 'Set the size of the command history' ]
|
106
|
+
].map do |name, min, help|
|
107
|
+
Subcmd.new(name, min, help)
|
108
|
+
end unless defined?(SetHistorySubcommands)
|
111
109
|
|
112
110
|
self.allow_in_control = true
|
113
111
|
|
@@ -152,6 +150,6 @@ module Byebug
|
|
152
150
|
or 0. You can see these environment settings with the "show" command.}
|
153
151
|
end
|
154
152
|
end
|
155
|
-
|
156
153
|
end
|
154
|
+
|
157
155
|
end
|