Sha256: d7ce12b06c49e299d7edcb05c08af44c33c49b0d29df3d65526de93d345d21a8
Contents?: true
Size: 1.93 KB
Versions: 4
Compression:
Stored size: 1.93 KB
Contents
# Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net> require 'tmpdir' require_relative 'base/cmd' class Trepan::Command::SaveCommand < Trepan::Command unless defined?(HELP) NAME = File.basename(__FILE__, '.rb') HELP = <<-HELP #{NAME} [filename] Save settings to file FILENAME. If FILENAME not given one will be made selected. HELP CATEGORY = 'running' MAX_ARGS = 1 # Need at most this many SHORT_HELP = 'Send debugger state to a file' end # This method runs the command def run(args) save_filename = if args.size > 1 args[1] else @proc.settings[:save_cmdfile] || File.join(Dir.tmpdir, Dir::Tmpname.make_tmpname(['trepanning-save', '.txt'], nil)) end begin save_file = File.open(save_filename, 'w') rescue => exc errmsg("Can't open #{save_filename} for writing.") errmsg("System reports: #{exc.inspect}") return end save_file.puts "#\n# Commands to restore trepanning environment\n#\n" @proc.commands.each do |cmd_name, cmd_obj| cmd_obj.save_command if cmd_obj.respond_to?(:save_command) next unless cmd_obj.is_a?(Trepan::SubcommandMgr) cmd_obj.subcmds.subcmds.each do |subcmd_name, subcmd_obj| save_file.puts subcmd_obj.save_command if subcmd_obj.respond_to?(:save_command) next unless subcmd_obj.is_a?(Trepan::SubSubcommandMgr) subcmd_obj.subcmds.subcmds.each do |subsubcmd_name, subsubcmd_obj| save_file.puts subsubcmd_obj.save_command if subsubcmd_obj.respond_to?(:save_command) end end end save_file.close msg "Debugger commands written to file: #{save_file.to_path}" end end if __FILE__ == $0 require_relative '../mock' dbgr, cmd = MockDebugger::setup require 'tmpdir' cmd.run([cmd.name, Dir.tmpdir]) cmd.run([cmd.name]) cmd.run([cmd.name, File.join(Dir.tmpdir, 'save_file.txt')]) end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
trepanning-0.1.0 | processor/command/save.rb |
trepanning-0.0.9 | processor/command/save.rb |
trepanning-0.0.8 | processor/command/save.rb |
trepanning-0.0.6 | processor/command/save.rb |