Sha256: 3b49c543c9fafd904eac14227bb929ef862b24834d657dc0dc016b64774094c4

Contents?: true

Size: 1.37 KB

Versions: 1

Compression:

Stored size: 1.37 KB

Contents

# -*- coding: utf-8 -*-
# Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
require_relative '../base/subcmd'

class Trepan::Subcommand::InfoProgram < Trepan::Subcommand
  unless defined?(HELP)
    Trepanning::Subcommand.set_name_prefix(__FILE__, self)
    HELP         = 'Information about debugged program and its environment'
    MIN_ABBREV   = 'pr'.size
    NEED_STACK   = true
  end

  def run(args)
    frame = @proc.frame
    m = 'Program stop event: %s' % @proc.event
    m += 
      if frame.iseq
        '; PC offset %d of instruction sequence: %s' % 
          [frame.pc_offset, frame.iseq.name]
      else
        '.'
      end
    msg m
    if 'return' == @proc.event 
      msg 'R=> %s' % @proc.frame.sp(1).inspect 
    elsif 'raise' == @proc.event
      msg @proc.core.hook_arg.inspect if @proc.core.hook_arg
    end

    if @proc.brkpt
      msg('It is stopped at %sbreakpoint %d.' %
          [@proc.brkpt.temp? ? 'temporary ' : '',
           @proc.brkpt.id])
    end
  end

end

if __FILE__ == $0
  # Demo it.
  require_relative '../../mock'
  name = File.basename(__FILE__, '.rb')

  # FIXME: DRY the below code
  dbgr, cmd = MockDebugger::setup('info')
  subcommand = Trepan::Subcommand::InfoProgram.new(cmd)
  testcmdMgr = Trepan::Subcmd.new(subcommand)

  name = File.basename(__FILE__, '.rb')
  subcommand.run([name])
  subcommand.summary_help(name)
  puts
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
trepanning-0.1.0 processor/command/info_subcmd/program.rb