Sha256: d49f5ade7a6c63b662186bc586f5acf096fbc6ee01f9c08ca6dc73241ff650c7
Contents?: true
Size: 1.58 KB
Versions: 2
Compression:
Stored size: 1.58 KB
Contents
# -*- coding: utf-8 -*- # Copyright (C) 2012 Rocky Bernstein <rockyb@rubyforge.net> require_relative '../base/subcmd' class Trepan::Subcommand::SetPc < Trepan::Subcommand unless defined?(HELP) Trepanning::Subcommand.set_name_prefix(__FILE__, self) HELP = 'set PC INTEGER-EXPRESSION Set VM program-counter register (PC) to INTEGER-EXPRESSION. Warning: this is potentially dangerous. ' SHORT_HELP = 'Set VM program counter (PC)' IN_LIST = true MIN_ABBREV = 'pc'.size end def run(args) # FIXME handle c-return # unless %w(return c-return).member?(@proc.event) if args.size < 3 errmsg "Too few arguments - the 'pc' command requires a value" return end new_val_str = args[2..-1].join(' ') begin new_val = @proc.debug_eval(new_val_str) rescue StandardError, ScriptError => e return end msg("Old value was: %s" % @proc.frame.pc_offset.inspect) @proc.frame.pc_offset = new_val msg("New value is: %s" % new_val.inspect) end end if __FILE__ == $0 # Demo it. require_relative %w(.. .. mock) require_relative %w(.. .. subcmd) name = File.basename(__FILE__, '.rb') # FIXME: DRY the below code dbgr, cmd = MockDebugger::setup('set') subcommand = Debugger::Subcommand::SetPc.new(cmd) testcmdMgr = Debugger::Subcmd.new(subcommand) def subcommand.msg(message) puts message end def subcommand.msg_nocr(message) print message end def subcommand.errmsg(message) puts message end subcommand.run(%w(20)) name = File.basename(__FILE__, '.rb') subcommand.summary_help(name) end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
trepanning-1.93.35 | processor/command/set_subcmd/pc.rb |
trepanning-1.93.32 | processor/command/set_subcmd/pc.rb |