Class: Byebug::RestartCommand
Overview
Restart debugged program from within byebug.
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
54
55
56
57
58
59
|
# File 'lib/byebug/commands/restart.rb', line 54
def description
%(restart|R [args]
Restart the program. This is a re-exec - all byebug state
is lost. If command arguments are passed those are used.)
end
|
.names ⇒ Object
50
51
52
|
# File 'lib/byebug/commands/restart.rb', line 50
def names
%w(restart)
end
|
Instance Method Details
#execute ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/byebug/commands/restart.rb', line 12
def execute
prog = PROG_SCRIPT if defined?(PROG_SCRIPT)
byebug_script = BYEBUG_SCRIPT if defined?(BYEBUG_SCRIPT)
return errmsg("Don't know name of debugged program") unless prog
unless File.exist?(File.expand_path(prog))
return errmsg("Ruby program #{prog} doesn't exist")
end
if byebug_script
cmd = "#{byebug_script} #{prog}"
else
puts 'Byebug was not called from the outset...'
if File.executable?(prog)
cmd = prog
else
puts "Ruby program #{prog} not executable... " \
"We'll wrap it in a ruby call"
cmd = "ruby -rbyebug -I#{$LOAD_PATH.join(' -I')} #{prog}"
end
end
if @match[:args]
cmd += " #{@match[:args]}"
else
require 'shellwords'
cmd += " #{ARGV.compact.shelljoin}"
end
puts "Re exec'ing:\n\t#{cmd}"
exec cmd
rescue Errno::EOPNOTSUPP
puts 'Restart command is not available at this time.'
end
|
#regexp ⇒ Object
8
9
10
|
# File 'lib/byebug/commands/restart.rb', line 8
def regexp
/^\s* (?:restart|R) (?:\s+(?<args>.+))? \s*$/x
end
|