| Class | Debugger::IRBCommand |
| In: |
cli/ruby-debug/commands/irb.rb
|
| Parent: | Command |
Implements debugger "irb" command.
# File cli/ruby-debug/commands/irb.rb, line 172
172: def help(cmd)
173: %{
174: irb [-d]\tstarts an Interactive Ruby (IRB) session.
175:
176: If -d is added you can get access to debugger state via the global variable
177: $rdebug_state.
178:
179: irb is extended with methods "cont", "n", "step" and "q" which run the
180: corresponding debugger commands. In contrast to the real debugger
181: commands these commands do not allow command arguments.
182:
183: However to run any arbitrary rdebug command which does not involve
184: execution of the debugged program (like the above "step" "cont", etc.)
185: use method "dbgr" and give an array of string parameters. For example:
186:
187: dbgr ['list', '10'] # same as "list 10" inside debugger
188: }
189: end
# File cli/ruby-debug/commands/irb.rb, line 123
123: def execute
124: unless @state.interface.kind_of?(LocalInterface)
125: print "Command is available only in local mode.\n"
126: throw :debug_error
127: end
128:
129: save_trap = trap("SIGINT") do
130: throw :IRB_EXIT, :cont if $rdebug_in_irb
131: end
132:
133: # add_debugging = @match.is_a?(Array) && '-d' == @match[1]
134: $rdebug_state = @state
135: $rdebug_in_irb = true
136: cont = IRB.start_session(get_binding)
137: case cont
138: when :cont
139: @state.proceed
140: when :step
141: force = Command.settings[:force_stepping]
142: @state.context.step(1, force)
143: @state.proceed
144: when :next
145: force = Command.settings[:force_stepping]
146: @state.context.step_over(1, @state.frame_pos, force)
147: @state.proceed
148: when :quit
149: # FIXME: DRY with code from file/command quit.
150: if confirm("Really quit? (y/n) ")
151: @state.interface.finalize
152: exit! # exit -> exit!: No graceful way to stop threads...
153: end
154: else
155: file = @state.context.frame_file(0)
156: line = @state.context.frame_line(0)
157: CommandProcessor.print_location_and_text(file, line)
158: @state.previous_line = nil
159: end
160:
161: ensure
162: $rdebug_in_irb = nil
163: $rdebug_state = nil
164: trap("SIGINT", save_trap) if save_trap
165: end