byebug 3.0.0 → 3.1.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 +15 -0
- data/GUIDE.md +2 -2
- data/LICENSE +3 -3
- data/README.md +5 -4
- data/byebug.gemspec +1 -1
- data/ext/byebug/byebug.c +20 -19
- data/lib/byebug.rb +2 -53
- data/lib/byebug/command.rb +9 -109
- data/lib/byebug/commands/breakpoints.rb +1 -1
- data/lib/byebug/commands/control.rb +20 -21
- data/lib/byebug/commands/display.rb +2 -3
- data/lib/byebug/commands/eval.rb +6 -16
- data/lib/byebug/commands/finish.rb +1 -1
- data/lib/byebug/commands/frame.rb +9 -9
- data/lib/byebug/commands/help.rb +2 -3
- data/lib/byebug/commands/history.rb +28 -0
- data/lib/byebug/commands/info.rb +3 -3
- data/lib/byebug/commands/list.rb +2 -13
- data/lib/byebug/commands/method.rb +5 -45
- data/lib/byebug/commands/reload.rb +1 -12
- data/lib/byebug/commands/repl.rb +6 -15
- data/lib/byebug/commands/save.rb +2 -7
- data/lib/byebug/commands/set.rb +45 -116
- data/lib/byebug/commands/show.rb +22 -126
- data/lib/byebug/commands/stepping.rb +1 -1
- data/lib/byebug/commands/trace.rb +14 -25
- data/lib/byebug/commands/variables.rb +3 -41
- data/lib/byebug/helper.rb +11 -42
- data/lib/byebug/history.rb +5 -13
- data/lib/byebug/processors/command_processor.rb +6 -6
- data/lib/byebug/setting.rb +82 -0
- data/lib/byebug/settings/autoeval.rb +20 -0
- data/lib/byebug/settings/autoirb.rb +19 -0
- data/lib/byebug/settings/autolist.rb +19 -0
- data/lib/byebug/settings/autoreload.rb +11 -0
- data/lib/byebug/settings/autosave.rb +11 -0
- data/lib/byebug/settings/basename.rb +7 -0
- data/lib/byebug/settings/callstyle.rb +15 -0
- data/lib/byebug/settings/forcestep.rb +11 -0
- data/lib/byebug/settings/fullpath.rb +11 -0
- data/lib/byebug/settings/histfile.rb +16 -0
- data/lib/byebug/settings/histsize.rb +18 -0
- data/lib/byebug/settings/linetrace.rb +15 -0
- data/lib/byebug/settings/listsize.rb +15 -0
- data/lib/byebug/settings/post_mortem.rb +15 -0
- data/lib/byebug/settings/stack_on_error.rb +7 -0
- data/lib/byebug/settings/testing.rb +7 -0
- data/lib/byebug/settings/tracing_plus.rb +7 -0
- data/lib/byebug/settings/verbose.rb +7 -0
- data/lib/byebug/settings/width.rb +29 -0
- data/lib/byebug/version.rb +1 -1
- data/test/breakpoints_test.rb +345 -324
- data/test/conditions_test.rb +61 -48
- data/test/continue_test.rb +38 -27
- data/test/debugger_alias_test.rb +5 -3
- data/test/display_test.rb +103 -92
- data/test/edit_test.rb +42 -34
- data/test/eval_test.rb +91 -75
- data/test/finish_test.rb +51 -40
- data/test/frame_test.rb +197 -184
- data/test/help_test.rb +47 -38
- data/test/history_test.rb +54 -0
- data/test/info_test.rb +306 -293
- data/test/interrupt_test.rb +44 -38
- data/test/kill_test.rb +40 -31
- data/test/list_test.rb +166 -133
- data/test/method_test.rb +67 -60
- data/test/post_mortem_test.rb +56 -48
- data/test/quit_test.rb +44 -35
- data/test/reload_test.rb +36 -24
- data/test/repl_test.rb +57 -47
- data/test/restart_test.rb +56 -69
- data/test/save_test.rb +62 -53
- data/test/set_test.rb +140 -118
- data/test/show_test.rb +68 -201
- data/test/source_test.rb +39 -29
- data/test/stepping_test.rb +163 -136
- data/test/support/test_dsl.rb +9 -11
- data/test/test_helper.rb +2 -7
- data/test/thread_test.rb +121 -107
- data/test/trace_test.rb +86 -83
- data/test/variables_test.rb +104 -98
- metadata +27 -86
- data/test/examples/breakpoint.rb +0 -6
- data/test/examples/breakpoint_deep.rb +0 -4
- data/test/examples/conditions.rb +0 -4
- data/test/examples/continue.rb +0 -5
- data/test/examples/display.rb +0 -5
- data/test/examples/edit.rb +0 -4
- data/test/examples/eval.rb +0 -4
- data/test/examples/finish.rb +0 -3
- data/test/examples/frame.rb +0 -4
- data/test/examples/frame_deep.rb +0 -1
- data/test/examples/gcd.rb +0 -15
- data/test/examples/hanoi.rb +0 -34
- data/test/examples/help.rb +0 -1
- data/test/examples/info.rb +0 -6
- data/test/examples/info2.rb +0 -3
- data/test/examples/interrupt.rb +0 -8
- data/test/examples/kill.rb +0 -2
- data/test/examples/list.rb +0 -23
- data/test/examples/method.rb +0 -4
- data/test/examples/post_mortem.rb +0 -4
- data/test/examples/primes.rb +0 -25
- data/test/examples/quit.rb +0 -2
- data/test/examples/reload.rb +0 -6
- data/test/examples/repl.rb +0 -6
- data/test/examples/restart.rb +0 -6
- data/test/examples/save.rb +0 -3
- data/test/examples/set.rb +0 -3
- data/test/examples/settings.rb +0 -1
- data/test/examples/show.rb +0 -1
- data/test/examples/source.rb +0 -3
- data/test/examples/stepping.rb +0 -8
- data/test/examples/stepping_raise_from_c_method.rb +0 -3
- data/test/examples/stepping_raise_from_ruby_method.rb +0 -3
- data/test/examples/test-triangle.rb +0 -14
- data/test/examples/thread.rb +0 -5
- data/test/examples/tmate.rb +0 -10
- data/test/examples/trace.rb +0 -8
- data/test/examples/tri3.rb +0 -6
- data/test/examples/triangle.rb +0 -13
- data/test/examples/variables.rb +0 -4
- data/test/timeout_test.rb +0 -9
data/lib/byebug/commands/set.rb
CHANGED
@@ -1,132 +1,44 @@
|
|
1
1
|
module Byebug
|
2
2
|
|
3
|
-
# Mix-in module to setting settings
|
4
|
-
module SetFunctions
|
5
|
-
|
6
|
-
def set_setting(setting_name, setting_value, setting_args)
|
7
|
-
case setting_name
|
8
|
-
when /^args$/
|
9
|
-
if defined?(Byebug::BYEBUG_SCRIPT)
|
10
|
-
Command.settings[:argv][1..-1] = setting_args
|
11
|
-
else
|
12
|
-
Command.settings[:argv] = setting_args
|
13
|
-
end
|
14
|
-
when /^autoirb$/
|
15
|
-
Command.settings[:autoirb] = (setting_value ? 1 : 0)
|
16
|
-
when /^autolist$/
|
17
|
-
Command.settings[:autolist] = (setting_value ? 1 : 0)
|
18
|
-
when /^callstyle$/
|
19
|
-
if setting_args[0] and ['short', 'long'].include?(setting_args[0])
|
20
|
-
Command.settings[:callstyle] = setting_args[0].to_sym
|
21
|
-
else
|
22
|
-
print "Invalid callstyle. Should be one of: \"short\" or \"long\"\n"
|
23
|
-
end
|
24
|
-
when /^verbose$/
|
25
|
-
Byebug.verbose = setting_value
|
26
|
-
when /^histfile$/
|
27
|
-
return print 'You need to specify a filename' unless setting_args[0]
|
28
|
-
Byebug::History.file = File.expand_path(setting_args[0])
|
29
|
-
when /^histsize$/
|
30
|
-
return print 'You need to specify the history size' unless setting_args[0]
|
31
|
-
Byebug::History.max_size = get_int(setting_args[0], "Set histsize")
|
32
|
-
when /^linetrace$/
|
33
|
-
Byebug.tracing = setting_value
|
34
|
-
when /^listsize$/
|
35
|
-
listsize = get_int(setting_args[0], 'Set listsize', 1, nil, 10)
|
36
|
-
return unless listsize
|
37
|
-
Command.settings[:listsize] = listsize
|
38
|
-
when /^width$/
|
39
|
-
return unless width = get_int(setting_args[0], 'Set width', 10, nil, 80)
|
40
|
-
Command.settings[:width] = width
|
41
|
-
when /^post_mortem$/
|
42
|
-
if setting_value == true
|
43
|
-
Byebug.post_mortem
|
44
|
-
else
|
45
|
-
Byebug.post_mortem = false
|
46
|
-
end
|
47
|
-
when /^autoeval|autoreload|autosave|basename|forcestep|fullpath|
|
48
|
-
linetrace_plus|testing|stack_on_error$/x
|
49
|
-
Command.settings[setting_name.to_sym] = setting_value
|
50
|
-
else
|
51
|
-
return print "Unknown setting #{@match[1]}.\n"
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
3
|
# Implements byebug "set" command.
|
57
4
|
class SetCommand < Command
|
58
|
-
Subcmd2 = Struct.new(:name, :min, :is_bool, :help) unless defined?(Subcmd2)
|
59
|
-
|
60
|
-
Subcommands = [
|
61
|
-
['args' , 2 , false, 'Set argument list to the program ' \
|
62
|
-
'being debugged when it is started' ],
|
63
|
-
['autoeval' , 5 , true , 'Evaluate every unrecognized command' ],
|
64
|
-
['autolist' , 5 , true , 'Execute "list" command on every ' \
|
65
|
-
'breakpoint' ],
|
66
|
-
['autoirb' , 5 , true , 'Invoke IRB on every stop' ],
|
67
|
-
['autoreload' , 5 , true , 'Reload source code when changed' ],
|
68
|
-
['autosave' , 5 , true , 'Automatically save command history ' \
|
69
|
-
'record on exit' ],
|
70
|
-
['basename' , 1 , true , 'Set filename display style' ],
|
71
|
-
['callstyle' , 2 , false, 'Set how you want call parameters ' \
|
72
|
-
'displayed' ],
|
73
|
-
['forcestep' , 2 , true , 'Make sure "next/step" commands always' \
|
74
|
-
'move to a new line' ],
|
75
|
-
['fullpath' , 2 , true , 'Display full file names in frames' ],
|
76
|
-
['histfile' , 5 , false, 'Customize file where history is ' \
|
77
|
-
'loaded from and saved to. By ' \
|
78
|
-
'default, .byebug_hist' ],
|
79
|
-
['histsize' , 5 , false, 'Customize maximum number of commands ' \
|
80
|
-
'that are stored in byebug history ' \
|
81
|
-
'record. By default, 256' ],
|
82
|
-
['linetrace' , 3 , true , 'Enable line execution tracing' ],
|
83
|
-
['linetrace_plus', 10, true , 'Set line execution tracing to show' \
|
84
|
-
'different lines' ],
|
85
|
-
['listsize' , 3 , false, 'Set number of source lines to list by' \
|
86
|
-
'default' ],
|
87
|
-
['post_mortem' , 2 , true , 'Enable post-mortem mode' ],
|
88
|
-
['stack_on_error', 1 , true , 'Display stack trace when "eval" ' \
|
89
|
-
'raises exception' ],
|
90
|
-
['testing' , 2 , false, 'Used when testing byebug' ],
|
91
|
-
['verbose' , 1 , true , 'Enable verbose output of TracePoint ' \
|
92
|
-
'API events is enabled' ],
|
93
|
-
['width' , 1 , false, 'Number of characters per line for ' \
|
94
|
-
'byebug\'s output' ]
|
95
|
-
].map do |name, min, is_bool, help|
|
96
|
-
Subcmd2.new(name, min, is_bool, help)
|
97
|
-
end unless defined?(Subcommands)
|
98
|
-
|
99
5
|
self.allow_in_control = true
|
100
6
|
|
101
7
|
def regexp
|
102
|
-
/^\s* set (?:\s+(
|
8
|
+
/^\s* set (?:\s+(?<setting>\w+))? (?:\s+(?<value>\S+))? \s*$/x
|
103
9
|
end
|
104
10
|
|
105
11
|
def execute
|
106
|
-
|
107
|
-
|
108
|
-
args = @match[1].split(/[ \t]+/)
|
109
|
-
try_subcmd = args.shift
|
110
|
-
try_subcmd.downcase!
|
111
|
-
if try_subcmd =~ /^no/i
|
112
|
-
set_on = false
|
113
|
-
try_subcmd = try_subcmd[2..-1]
|
114
|
-
else
|
115
|
-
set_on = true
|
116
|
-
end
|
12
|
+
key, value = @match[:setting], @match[:value]
|
13
|
+
return print SetCommand.help if key.nil? && value.nil?
|
117
14
|
|
118
|
-
|
119
|
-
return print "Unknown
|
15
|
+
full_key = Setting.find(key)
|
16
|
+
return print "Unknown setting :#{key}\n" unless full_key
|
120
17
|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
18
|
+
if !Setting.boolean?(full_key) && value.nil?
|
19
|
+
return print "You must specify a value for setting :#{key}\n"
|
20
|
+
elsif Setting.boolean?(full_key)
|
21
|
+
value = get_onoff(value, key =~ /^no/ ? false : true)
|
22
|
+
elsif Setting.integer?(full_key)
|
23
|
+
return unless value = get_int(value, full_key, 1, 300)
|
125
24
|
end
|
126
25
|
|
127
|
-
|
26
|
+
Setting[full_key.to_sym] = value
|
27
|
+
|
28
|
+
return print Setting.settings[full_key.to_sym].to_s
|
29
|
+
end
|
128
30
|
|
129
|
-
|
31
|
+
def get_onoff(arg, default)
|
32
|
+
return default if arg.nil?
|
33
|
+
case arg
|
34
|
+
when '1', 'on'
|
35
|
+
return true
|
36
|
+
when '0', 'off'
|
37
|
+
return false
|
38
|
+
else
|
39
|
+
print "Expecting 'on', 1, 'off', or 0. Got: #{arg}.\n"
|
40
|
+
raise RuntimeError
|
41
|
+
end
|
130
42
|
end
|
131
43
|
|
132
44
|
class << self
|
@@ -135,8 +47,25 @@ module Byebug
|
|
135
47
|
end
|
136
48
|
|
137
49
|
def description
|
138
|
-
|
139
|
-
|
50
|
+
<<-EOD.gsub(/^ /, '')
|
51
|
+
|
52
|
+
set <setting> <value>
|
53
|
+
|
54
|
+
Modifies parts of byebug environment.
|
55
|
+
|
56
|
+
Boolean values take "on", "off", "true", "false", "1" or "0". If you
|
57
|
+
don't specify a value, the boolean setting will be enabled.
|
58
|
+
Conversely, you can use "set no<setting> to disable them.
|
59
|
+
|
60
|
+
You can see these environment settings with the "show" command.
|
61
|
+
|
62
|
+
EOD
|
63
|
+
end
|
64
|
+
|
65
|
+
def help(setting = nil)
|
66
|
+
return "set #{setting.to_sym} <value>\n\n#{setting.help}" if setting
|
67
|
+
|
68
|
+
description + Setting.format()
|
140
69
|
end
|
141
70
|
end
|
142
71
|
end
|
data/lib/byebug/commands/show.rb
CHANGED
@@ -1,139 +1,22 @@
|
|
1
1
|
module Byebug
|
2
2
|
|
3
|
-
# Mix-in module to showing settings
|
4
|
-
module ShowFunctions
|
5
|
-
|
6
|
-
def show_setting(setting_name)
|
7
|
-
case setting_name
|
8
|
-
when /^args$/
|
9
|
-
if Command.settings[:argv] and Command.settings[:argv].size > 0
|
10
|
-
if defined?(Byebug::BYEBUG_SCRIPT)
|
11
|
-
# byebug was called initially. 1st arg is script name.
|
12
|
-
args = Command.settings[:argv][1..-1].join(' ')
|
13
|
-
else
|
14
|
-
# byebug wasn't called initially. 1st arg is not script name.
|
15
|
-
args = Command.settings[:argv].join(' ')
|
16
|
-
end
|
17
|
-
else
|
18
|
-
args = ''
|
19
|
-
end
|
20
|
-
"Argument list to give program being debugged when it is started is \"#{args}\"."
|
21
|
-
when /^autolist$/
|
22
|
-
"autolist is #{show_onoff(Command.settings[:autolist] > 0)}."
|
23
|
-
when /^autoirb$/
|
24
|
-
"autoirb is #{show_onoff(Command.settings[:autoirb] > 0)}."
|
25
|
-
when /^autosave$/
|
26
|
-
"Saving history is #{show_onoff(Command.settings[:autosave])}."
|
27
|
-
when /^callstyle$/
|
28
|
-
"Frame call-display style is #{Command.settings[:callstyle]}."
|
29
|
-
when /^commands(:?\s+(\d+))?$/
|
30
|
-
if Command.settings[:autosave]
|
31
|
-
history = Byebug::History
|
32
|
-
args = @match[1].split
|
33
|
-
if args[1]
|
34
|
-
size = get_int(args[1], 'show commands', 1, history.max_size)
|
35
|
-
end
|
36
|
-
size ? history.to_s(size) : history.to_s
|
37
|
-
else
|
38
|
-
'Not currently saving history. Enable it with "set autosave"'
|
39
|
-
end
|
40
|
-
when /^testing$/
|
41
|
-
"Currently testing byebug is #{show_onoff(Command.settings[:testing])}."
|
42
|
-
when /^forcestep$/
|
43
|
-
"force-stepping is #{show_onoff(Command.settings[:forcestep])}."
|
44
|
-
when /^fullpath$/
|
45
|
-
"Displaying frame's full file names is #{show_onoff(Command.settings[:fullpath])}."
|
46
|
-
when /^histfile$/
|
47
|
-
"The command history file is \"#{Byebug::History.file}\""
|
48
|
-
when /^histsize$/
|
49
|
-
"Byebug history's maximum size is #{Byebug::History.max_size}"
|
50
|
-
when /^linetrace$/
|
51
|
-
"line tracing is #{show_onoff(Byebug.tracing?)}."
|
52
|
-
when /^linetrace_plus$/
|
53
|
-
if Command.settings[:linetrace_plus]
|
54
|
-
'line tracing style is every line.'
|
55
|
-
else
|
56
|
-
'line tracing style is different consecutive lines.'
|
57
|
-
end
|
58
|
-
when /^listsize$/
|
59
|
-
"Number of source lines to list is #{Command.settings[:listsize]}."
|
60
|
-
when /^post_mortem$/
|
61
|
-
"Post-mortem mode is #{show_onoff(Byebug.post_mortem?)}"
|
62
|
-
when /^stack_on_error$/
|
63
|
-
"Displaying stack trace is #{show_onoff(Command.settings[:stack_on_error])}."
|
64
|
-
when /^verbose$/
|
65
|
-
"Verbose output of TracePoint API events is #{show_onoff(Byebug.verbose)}."
|
66
|
-
when /^version$/
|
67
|
-
"Byebug #{Byebug::VERSION}"
|
68
|
-
when /^width$/
|
69
|
-
"Width is #{Command.settings[:width]}."
|
70
|
-
when /^autoeval|autoreload|basename$/x
|
71
|
-
"#{setting_name} is #{show_onoff(Command.settings[setting_name.to_sym])}."
|
72
|
-
else
|
73
|
-
"Unknown show subcommand #{setting_name}."
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
3
|
# Implements byebug "show" command.
|
79
4
|
class ShowCommand < Command
|
80
|
-
|
81
|
-
Subcommands = [
|
82
|
-
['args' , 2 , 'Show argument list to the program being ' \
|
83
|
-
'debugged when it is started' ],
|
84
|
-
['autoeval' , 5 , 'Show whether unrecognized commands are ' \
|
85
|
-
'evaluated' ],
|
86
|
-
['autolist' , 5 , 'Show whether "list" command is run on stopping' ],
|
87
|
-
['autoirb' , 5 , 'Show whether IRB is invoked on stopping' ],
|
88
|
-
['autoreload' , 5 , 'Show whether source code is reloaded when ' \
|
89
|
-
'changed' ],
|
90
|
-
['autosave' , 5 , 'Show whether command history is ' \
|
91
|
-
'automatically saved on exit' ],
|
92
|
-
['basename' , 1 , 'Show whether basename is used when reporting' \
|
93
|
-
' files' ],
|
94
|
-
['callstyle' , 2 , 'Show parameter style used when showing call' \
|
95
|
-
' frames' ],
|
96
|
-
['commands' , 2 , 'Show the history of commands you typed. You ' \
|
97
|
-
'can supply a command number to start with' ],
|
98
|
-
['forcestep' , 1 , 'Show whether "next/step" commands are set to' \
|
99
|
-
' always move to a line' ],
|
100
|
-
['fullpath' , 2 , 'Show whether full paths are displayed in frames'],
|
101
|
-
['histfile' , 5 , 'File where byebug save history of commands' ],
|
102
|
-
['histsize' , 5 , 'Maximum number of commands stored in ' \
|
103
|
-
'byebug\'s history' ],
|
104
|
-
['linetrace' , 3 , 'Show line execution tracing status' ],
|
105
|
-
['linetrace_plus', 10, 'Show whether different consecutive lines are' \
|
106
|
-
' shown in tracing' ],
|
107
|
-
['listsize' , 3 , 'Show number of source lines to list by default' ],
|
108
|
-
['post_mortem' , 3 , 'Show whether we should go into post-mortem ' \
|
109
|
-
'debugging on an uncaught exception' ],
|
110
|
-
['stack_on_error', 1 , 'Show whether a stack trace is displayed when' \
|
111
|
-
' "eval" raises an exception' ],
|
112
|
-
['verbose' , 4 , 'Show whether verbose output for debugging ' \
|
113
|
-
'byebug itself is enabled' ],
|
114
|
-
['version' , 1 , 'Show byebug\'s version' ],
|
115
|
-
['width' , 1 , 'Show the number of characters per line for ' \
|
116
|
-
'byebug' ]
|
117
|
-
].map do |name, min, help|
|
118
|
-
Subcmd.new(name, min, help)
|
119
|
-
end unless defined?(Subcommands)
|
120
|
-
|
121
5
|
self.allow_in_control = true
|
122
6
|
|
123
7
|
def regexp
|
124
|
-
/^\s* show (?:\s+(
|
8
|
+
/^\s* show (?:\s+(?<setting>\w+))? \s*$/x
|
125
9
|
end
|
126
10
|
|
127
11
|
def execute
|
128
|
-
|
12
|
+
key = @match[:setting]
|
13
|
+
return print ShowCommand.help if key.nil?
|
129
14
|
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
if subcmd
|
134
|
-
print "%s\n" % show_setting(subcmd.name)
|
15
|
+
full_key = Setting.find(key)
|
16
|
+
if full_key
|
17
|
+
print Setting.settings[full_key.to_sym].to_s
|
135
18
|
else
|
136
|
-
print "Unknown
|
19
|
+
print "Unknown setting :#{key}\n"
|
137
20
|
end
|
138
21
|
end
|
139
22
|
|
@@ -143,9 +26,22 @@ module Byebug
|
|
143
26
|
end
|
144
27
|
|
145
28
|
def description
|
146
|
-
|
29
|
+
<<-EOD.gsub(/^ /, '')
|
30
|
+
|
31
|
+
show <setting> <value>
|
32
|
+
|
33
|
+
Generic command for showing byebug settings. You can change them with
|
34
|
+
the "set" command.
|
35
|
+
|
36
|
+
EOD
|
147
37
|
end
|
148
|
-
end
|
149
38
|
|
39
|
+
def help(setting = nil)
|
40
|
+
return "show #{setting.to_sym} <value>\n\n#{setting.help}" if setting
|
41
|
+
|
42
|
+
description + Setting.format()
|
43
|
+
end
|
44
|
+
end
|
150
45
|
end
|
46
|
+
|
151
47
|
end
|
@@ -2,36 +2,26 @@ module Byebug
|
|
2
2
|
|
3
3
|
class TraceCommand < Command
|
4
4
|
def regexp
|
5
|
-
/^\s* tr(?:
|
6
|
-
|
7
|
-
(?: \s+ (\S+))? # (stop | nostop)?
|
5
|
+
/^\s* tr(?:acevar)? (?: \s+ (\S+))? # (variable-name)?
|
6
|
+
(?: \s+ (\S+))? # (stop | nostop)?
|
8
7
|
\s*$/x
|
9
8
|
end
|
10
9
|
|
11
10
|
def execute
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
elsif @match[1] =~ /var(?:iable)?/
|
17
|
-
varname = @match[2]
|
18
|
-
if global_variables.include?("$#{varname}".to_sym)
|
19
|
-
if @match[3] && @match[3] !~ /(:?no)?stop/
|
20
|
-
errmsg "expecting \"stop\" or \"nostop\"; got \"#{@match[3]}\"\n"
|
21
|
-
else
|
22
|
-
dbg_cmd = (@match[3] && @match[3] !~ /nostop/) ? 'byebug(1, false)' : ''
|
23
|
-
end
|
24
|
-
eval("trace_var(:\"\$#{varname}\") do |val|
|
25
|
-
print \"traced global variable '#{varname}' has value '\#{val}'\"\n
|
26
|
-
#{dbg_cmd}
|
27
|
-
end")
|
28
|
-
print "Tracing global variable \"#{varname}\".\n"
|
11
|
+
varname = @match[1]
|
12
|
+
if global_variables.include?("$#{varname}".to_sym)
|
13
|
+
if @match[2] && @match[2] !~ /(:?no)?stop/
|
14
|
+
errmsg "expecting \"stop\" or \"nostop\"; got \"#{@match[2]}\"\n"
|
29
15
|
else
|
30
|
-
|
16
|
+
dbg_cmd = (@match[2] && @match[2] !~ /nostop/) ? 'byebug(1, false)' : ''
|
31
17
|
end
|
18
|
+
eval("trace_var(:\"\$#{varname}\") do |val|
|
19
|
+
print \"traced global variable '#{varname}' has value '\#{val}'\"\n
|
20
|
+
#{dbg_cmd}
|
21
|
+
end")
|
22
|
+
print "Tracing global variable \"#{varname}\".\n"
|
32
23
|
else
|
33
|
-
errmsg "
|
34
|
-
"\"#{@match[1]}\"\n"
|
24
|
+
errmsg "'#{varname}' is not a global variable.\n"
|
35
25
|
end
|
36
26
|
end
|
37
27
|
|
@@ -41,8 +31,7 @@ module Byebug
|
|
41
31
|
end
|
42
32
|
|
43
33
|
def description
|
44
|
-
%{tr[
|
45
|
-
tr[ace] var(iable) VARNAME [stop|nostop]\tset trace variable on VARNAME}
|
34
|
+
%{tr[acevar] VARNAME [stop|nostop]\tset trace variable on VARNAME}
|
46
35
|
end
|
47
36
|
end
|
48
37
|
end
|
@@ -1,5 +1,4 @@
|
|
1
1
|
module Byebug
|
2
|
-
|
3
2
|
module VarFunctions
|
4
3
|
def var_list(ary, b = get_binding)
|
5
4
|
ary.sort!
|
@@ -13,14 +12,16 @@ module Byebug
|
|
13
12
|
s = "*Error in evaluation*"
|
14
13
|
end
|
15
14
|
end
|
16
|
-
|
15
|
+
s[Setting[:width]-3..-1] = "..." if s.size > Setting[:width]
|
17
16
|
print "#{v} = #{s}\n"
|
18
17
|
end
|
19
18
|
end
|
19
|
+
|
20
20
|
def var_class_self
|
21
21
|
obj = bb_eval('self')
|
22
22
|
var_list(obj.class.class_variables, get_binding)
|
23
23
|
end
|
24
|
+
|
24
25
|
def var_global
|
25
26
|
var_list(global_variables.reject { |v| [:$=, :$KCODE, :$-K].include?(v) })
|
26
27
|
end
|
@@ -147,43 +148,4 @@ module Byebug
|
|
147
148
|
end
|
148
149
|
end
|
149
150
|
end
|
150
|
-
|
151
|
-
begin
|
152
|
-
require 'classtree'
|
153
|
-
have_classtree = true
|
154
|
-
rescue LoadError
|
155
|
-
have_classtree = false
|
156
|
-
end
|
157
|
-
|
158
|
-
# Implements byebug's 'var inherit' command
|
159
|
-
class VarInheritCommand < Command
|
160
|
-
def regexp
|
161
|
-
/^\s* v(?:ar)? \s+ ct \s*$/x
|
162
|
-
end
|
163
|
-
|
164
|
-
def execute
|
165
|
-
unless @state.context
|
166
|
-
errmsg "can't get object inheritance.\n"
|
167
|
-
return
|
168
|
-
end
|
169
|
-
puts @match.post_match
|
170
|
-
obj = bb_eval("#{@match.post_match}.classtree")
|
171
|
-
if obj
|
172
|
-
print obj
|
173
|
-
else
|
174
|
-
errmsg "Trouble getting object #{@match.post_match}\n"
|
175
|
-
end
|
176
|
-
end
|
177
|
-
|
178
|
-
class << self
|
179
|
-
def names
|
180
|
-
%w(var)
|
181
|
-
end
|
182
|
-
|
183
|
-
def description
|
184
|
-
%{v[ar] ct\t\t\tshow class heirarchy of object}
|
185
|
-
end
|
186
|
-
end
|
187
|
-
end if have_classtree
|
188
|
-
|
189
151
|
end
|