Class: Debugger::RestartCommand
- Inherits:
-
Command
- Object
- Command
- Debugger::RestartCommand
show all
- Defined in:
- lib/ruby-debug/commands/control.rb
Overview
Constant Summary
Constants inherited
from Command
Command::DEF_OPTIONS
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Command
commands, #find, inherited, #initialize, load_commands, #match, method_missing, options, register_setting_get, register_setting_set, register_setting_var, settings, settings_map
Class Method Details
.help(cmd) ⇒ Object
68
69
70
71
72
73
74
|
# File 'lib/ruby-debug/commands/control.rb', line 68
def help(cmd)
%{
restart|R [args]
Restart the program. This is a re-exec - all debugger state
is lost. If command arguments are passed those are used.
}
end
|
.help_command ⇒ Object
64
65
66
|
# File 'lib/ruby-debug/commands/control.rb', line 64
def help_command
'restart'
end
|
Instance Method Details
#execute ⇒ Object
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/ruby-debug/commands/control.rb', line 13
def execute
if not defined? Debugger::PROG_SCRIPT
errmsg "Don't know name of debugged program\n"
return
end
prog_script = Debugger::PROG_SCRIPT
if not defined? Debugger::RDEBUG_SCRIPT
print "Debugger was not called from the outset...\n"
rdebug_script = prog_script
else
rdebug_script = Debugger::RDEBUG_SCRIPT
end
begin
Dir.chdir(Debugger::INITIAL_DIR)
rescue
print "Failed to change initial directory #{Debugger::INITIAL_DIR}"
end
if not File.exist?(File.expand_path(prog_script))
errmsg "Ruby program #{prog_script} doesn't exist\n"
return
end
if not File.executable?(prog_script) and rdebug_script == prog_script
print "Ruby program #{prog_script} doesn't seem to be executable...\n"
print "We'll add a call to Ruby.\n"
ruby = begin defined?(Gem) ? Gem.ruby : "ruby" rescue "ruby" end
rdebug_script = "#{ruby} -I#{$:.join(' -I')} #{prog_script}"
else
rdebug_script += ' '
end
if @match[1]
argv = [prog_script] + @match[1].split(/[ \t]+/)
else
if not defined? Command.settings[:argv]
errmsg "Arguments have not been set. Use 'set args' to set them.\n"
return
else
argv = Command.settings[:argv]
end
end
args = argv.join(' ')
cmd = rdebug_script + args
print "Re exec'ing:\n\t#{cmd}\n"
exec cmd
rescue Errno::EOPNOTSUPP
print "Restart command is not available at this time.\n"
end
|
#regexp ⇒ Object
5
6
7
8
9
10
11
|
# File 'lib/ruby-debug/commands/control.rb', line 5
def regexp
/ ^\s*
(?:restart|R)
(?:\s+ (\S?.*\S))? \s*
$
/ix
end
|