Class: Debugger::ControlCommandProcessor

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

Overview

:nodoc:

Defined Under Namespace

Classes: State

Instance Method Summary collapse

Constructor Details

#initialize(interface) ⇒ ControlCommandProcessor

Returns a new instance of ControlCommandProcessor.



175
176
177
# File 'lib/ruby-debug/processor.rb', line 175

def initialize(interface)
  @interface = interface
end

Instance Method Details



179
180
181
# File 'lib/ruby-debug/processor.rb', line 179

def print(*args)
  @interface.print(*args)
end

#process_commandsObject



183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
# File 'lib/ruby-debug/processor.rb', line 183

def process_commands
  control_cmds = Command.commands.select{|cmd| cmd.control }
  state = State.new(@interface, control_cmds)
  commands = control_cmds.map{|cmd| cmd.new(state) }
  
  while input = @interface.read_command("(rdb:ctrl) ")
    catch(:debug_error) do
      if cmd = commands.find{|c| c.match(input) }
        cmd.execute
      else
        print "Unknown command\n"
      end
    end
  end
rescue IOError, Errno::EPIPE
rescue Exception
  print "INTERNAL ERROR!!! #{$!}\n" rescue nil
  print $!.backtrace.map{|l| "\t#{l}"}.join("\n") rescue nil
ensure
  @interface.close
end