Command
Implements debugger “irb” command.
# File cli/ruby-debug/commands/irb.rb, line 171 def help(cmd) %{ irb [-d]\tstarts an Interactive Ruby (IRB) session. If -d is added you can get access to debugger state via the global variable $rdebug_state. irb is extended with methods "cont", "n", "step" and "q" which run the corresponding debugger commands. In contrast to the real debugger commands these commands do not allow command arguments. However to run any arbitrary rdebug command which does not involve execution of the debugged program (like the above "step" "cont", etc.) use method "dbgr" and give an array of string parameters. For example: dbgr ['list', '10'] # same as "list 10" inside debugger } end
# File cli/ruby-debug/commands/irb.rb, line 122 def execute unless @state.interface.kind_of?(LocalInterface) print "Command is available only in local mode.\n" throw :debug_error end save_trap = trap("SIGINT") do throw :IRB_EXIT, :cont if $rdebug_in_irb end # add_debugging = @match.is_a?(Array) && '-d' == @match[1] $rdebug_state = @state $rdebug_in_irb = true cont = IRB.start_session(get_binding) case cont when :cont @state.proceed when :step force = Command.settings[:force_stepping] @state.context.step(1, force) @state.proceed when :next force = Command.settings[:force_stepping] @state.context.step_over(1, @state.frame_pos, force) @state.proceed when :quit # FIXME: DRY with code from file/command quit. if confirm("Really quit? (y/n) ") @state.interface.finalize exit! # exit -> exit!: No graceful way to stop threads... end else file = @state.context.frame_file(0) line = @state.context.frame_line(0) CommandProcessor.print_location_and_text(file, line) @state.previous_line = nil end ensure $rdebug_in_irb = nil $rdebug_state = nil trap("SIGINT", save_trap) if save_trap end
Generated with the Darkfish Rdoc Generator 2.