Class: Byebug::TraceCommand
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Command
commands, find, format_subcmd, format_subcmds, help, inherited, #initialize, load_commands, #match
Class Method Details
.description ⇒ Object
32
33
34
|
# File 'lib/byebug/commands/trace.rb', line 32
def description
%{tr[acevar] VARNAME [stop|nostop]\tset trace variable on VARNAME}
end
|
.names ⇒ Object
28
29
30
|
# File 'lib/byebug/commands/trace.rb', line 28
def names
%w(trace)
end
|
Instance Method Details
#execute ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/byebug/commands/trace.rb', line 9
def execute
varname = @match[1]
if global_variables.include?("$#{varname}".to_sym)
if @match[2] && @match[2] !~ /(:?no)?stop/
errmsg "expecting \"stop\" or \"nostop\"; got \"#{@match[2]}\"\n"
else
dbg_cmd = (@match[2] && @match[2] !~ /nostop/) ? 'byebug(1, false)' : ''
end
eval("trace_var(:\"\$#{varname}\") do |val|
print \"traced global variable '#{varname}' has value '\#{val}'\"\n
#{dbg_cmd}
end")
print "Tracing global variable \"#{varname}\".\n"
else
errmsg "'#{varname}' is not a global variable.\n"
end
end
|
#regexp ⇒ Object
3
4
5
6
7
|
# File 'lib/byebug/commands/trace.rb', line 3
def regexp
/^\s* tr(?:acevar)? (?: \s+ (\S+))? # (variable-name)?
(?: \s+ (\S+))? # (stop | nostop)?
\s*$/x
end
|