Class: Debugger::CommandProcessor

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-debug/processor.rb

Overview

:nodoc:

Defined Under Namespace

Classes: State

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(interface = LocalInterface.new) ⇒ CommandProcessor

Returns a new instance of CommandProcessor.



9
10
11
12
13
14
15
# File 'lib/ruby-debug/processor.rb', line 9

def initialize(interface = LocalInterface.new)
  @interface = interface
  @display = []
  @mutex = Mutex.new
  @last_cmd = nil
  @actions = []
end

Instance Attribute Details

#displayObject (readonly)

Returns the value of attribute display.



7
8
9
# File 'lib/ruby-debug/processor.rb', line 7

def display
  @display
end

#interfaceObject

Returns the value of attribute interface.



6
7
8
# File 'lib/ruby-debug/processor.rb', line 6

def interface
  @interface
end

Class Method Details

.protect(mname) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/ruby-debug/processor.rb', line 24

def self.protect(mname)
  alias_method "__#{mname}", mname
  module_eval %{
    def #{mname}(*args)
      @mutex.synchronize do
        return unless @interface
        __#{mname}(*args)
      end
    rescue IOError, Errno::EPIPE
      self.interface = nil
    rescue Exception
      print "INTERNAL ERROR!!! #\{$!\}\n" rescue nil
      print $!.backtrace.map{|l| "\t#\{l\}"}.join("\n") rescue nil
    end
  }
end

Instance Method Details

#at_breakpoint(context, breakpoint) ⇒ Object



41
42
43
44
# File 'lib/ruby-debug/processor.rb', line 41

def at_breakpoint(context, breakpoint)
  n = Debugger.breakpoints.index(breakpoint) + 1
  print "Breakpoint %d at %s:%s\n", n, breakpoint.source, breakpoint.pos
end

#at_catchpoint(context, excpt) ⇒ Object



47
48
49
50
51
52
53
54
55
56
# File 'lib/ruby-debug/processor.rb', line 47

def at_catchpoint(context, excpt)
  print "Catchpoint at %s:%d: `%s' (%s)\n", context.frame_file(1), context.frame_line(1), excpt, excpt.class
  fs = context.stack_size
  tb = caller(0)[-fs..-1]
  if tb
    for i in tb
      print "\tfrom %s\n", i
    end
  end
end

#at_line(context, file, line) ⇒ Object



64
65
66
67
# File 'lib/ruby-debug/processor.rb', line 64

def at_line(context, file, line)
  print "%s:%d: %s", file, line, Debugger.line_at(file, line)
  process_commands(context, file, line)
end

#at_tracing(context, file, line) ⇒ Object



59
60
61
# File 'lib/ruby-debug/processor.rb', line 59

def at_tracing(context, file, line)
  print "Tracing(%d):%s:%s %s", context.thnum, file, line, Debugger.line_at(file, line)
end