Class | Debugger::ControlCommandProcessor |
In: |
cli/ruby-debug/processor.rb
|
Parent: | Processor |
A Debugger::ControlCommandProcessor is the kind of Debugger::Processor used the debugged program is running remotely. It is also entered after the debugged program has terminated.
# File cli/ruby-debug/processor.rb, line 458 458: def initialize(interface) 459: super() 460: @interface = interface 461: @debugger_context_was_dead = true # Assume we haven't started. 462: end
This the main debugger command-line loop. Here we read a debugger command, perform it, and ask for another one unless we are told to continue execution or terminate.
# File cli/ruby-debug/processor.rb, line 467 467: def process_commands(verbose=false) 468: control_cmds = Command.commands.select do |cmd| 469: cmd.allow_in_control 470: end 471: state = State.new(@interface, control_cmds) 472: @commands = control_cmds.map{|cmd| cmd.new(state) } 473: 474: unless @debugger_context_was_dead 475: if Debugger.annotate.to_i > 2 476: aprint 'exited' 477: print "The program finished.\n" 478: end 479: @debugger_context_was_dead = true 480: end 481: 482: while input = @interface.read_command(prompt(nil)) 483: print "+#{input}" if verbose 484: catch(:debug_error) do 485: if cmd = @commands.find{|c| c.match(input) } 486: cmd.execute 487: else 488: errmsg "Unknown command\n" 489: end 490: end 491: end 492: rescue IOError, Errno::EPIPE 493: rescue Exception 494: print "INTERNAL ERROR!!! #{$!}\n" rescue nil 495: print $!.backtrace.map{|l| "\t#{l}"}.join("\n") rescue nil 496: ensure 497: @interface.close 498: end
Return a prompt string to show before reading a command. Note: The context parameter is not used. It must be provided so that the interface matches Debugger::CommandProcessor#prompt.
# File cli/ruby-debug/processor.rb, line 503 503: def prompt(context) 504: p = '(rdb:ctrl) ' 505: p = afmt("pre-prompt")+p+"\n"+afmt("prompt") if 506: Debugger.annotate.to_i > 2 507: return p 508: end