class Byebug::CommandProcessor
@see PostMortemProcessor for a example
example, whitelists only certain commands to be executed.
You can override this class to create your own command processor that, for
Processes commands in regular mode.
def after_repl
def after_repl interface.autosave end
def at_breakpoint(brkpt)
def at_breakpoint(brkpt) number = Byebug.breakpoints.index(brkpt) + 1 puts "Stopped by breakpoint #{number} at #{frame.file}:#{frame.line}" end
def at_catchpoint(exception)
def at_catchpoint(exception) puts "Catchpoint at #{context.location}: `#{exception}'" end
def at_end
def at_end process_commands end
def at_line
def at_line process_commands end
def at_return(return_value)
def at_return(return_value) puts "Return value is: #{safe_inspect(return_value)}" process_commands end
def at_tracing
def at_tracing puts "Tracing: #{context.full_location}" run_auto_cmds(2) end
def auto_cmds_for(run_level)
def auto_cmds_for(run_level) command_list.select { |cmd| cmd.always_run >= run_level } end
def before_repl
def before_repl @proceed = false @prev_line = nil run_auto_cmds(1) interface.autorestore end
def command_list
Available commands
def command_list @command_list ||= CommandList.new(commands) end
def initialize(context)
def initialize(context) @context = context @proceed = false @prev_line = nil end
def interface
def interface @interface ||= Context.interface end
def printer
def printer @printer ||= Printers::Plain.new end
def proceed!
Let the execution continue
def proceed! @proceed = true end
def process_commands
Handle byebug commands.
def process_commands before_repl repl ensure after_repl end
def prompt
Prompt shown before reading a command.
def prompt '(byebug) ' end
def repl
Main byebug's REPL
def repl until @proceed cmd = interface.read_command(prompt) return if cmd.nil? next if cmd == '' run_cmd(cmd) end end
def run_auto_cmds(run_level)
Run permanent commands.
def run_auto_cmds(run_level) safely do auto_cmds_for(run_level).each { |cmd| cmd.new(self).execute } end end
def run_cmd(input)
command is not found, it evaluates the unknown input.
Instantiates a command matching the input and runs it. If a matching
Executes the received input
def run_cmd(input) safely do command = command_list.match(input) return command.new(self, input).execute if command puts safe_inspect(multiple_thread_eval(input)) end end
def safely
def safely yield rescue => e errmsg(e.message) end