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.



159
160
161
# File 'lib/ruby-debug/processor.rb', line 159

def initialize(interface)
  @interface = interface
end

Instance Method Details



163
164
165
# File 'lib/ruby-debug/processor.rb', line 163

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

#process_commandsObject



167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
# File 'lib/ruby-debug/processor.rb', line 167

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