processor/command/restart.rb in trepanning-0.1.0 vs processor/command/restart.rb in trepanning-0.1.1

- old
+ new

@@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- -# Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net> +# Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net> require_relative 'base/cmd' require_relative '../../app/run' class Trepan::Command::RestartCommand < Trepan::Command unless defined?(HELP) @@ -23,22 +23,22 @@ def run(args) dbgr = @proc.dbgr argv = dbgr.restart_argv if argv and argv.size > 0 - # unless File.executable?(argv[0]) - # msg(["File #{argv[0]} not executable.", - # "Adding Ruby interpreter."]) - # argv.unshift Trepanning::ruby_path - # end @proc.run_cmd(%w(show args)) if not confirm('Restart (exec)?', false) msg "Restart not confirmed" else - msg 'Restarting...' - @proc.run_cmd(%w(save)) - # FIXME: Run atexit finalize routines? + if defined?(Trepan::PROG_UNRESOLVED_SCRIPT) && + position = argv.index(Trepan::PROG_UNRESOLVED_SCRIPT) + save_filename = @proc.save_commands(:erase =>true) + argv.insert(position, '--command', save_filename) if save_filename + end Dir.chdir(RubyVM::OS_STARTUP_DIR) + msg 'Restarting using...' + msg "\t #{argv.inspect}" + @proc.finalize exec(*argv) end else errmsg("No executable file and command options recorded.") end