Sha256: e98ee8287ea1007ea8f3ff0682cad132af18ab74321d85bb3bcd219af4ff3e12

Contents?: true

Size: 1.37 KB

Versions: 2

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_ARGS     = 0
    MAX_ARGS     = 0
    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
        if @proc.frame.iseq.catch_table_size == 0
            msg "Warning: exception raised is non-local!"
        end
    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
  cmd = MockDebugger::sub_setup(Trepan::Subcommand::InfoProgram, false)
  cmd.run(cmd.prefix)
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
trepanning-1.93.35 processor/command/info_subcmd/program.rb
trepanning-1.93.32 processor/command/info_subcmd/program.rb