lib/debug/session.rb in debug-1.0.0.beta2 vs lib/debug/session.rb in debug-1.0.0.beta3

- old
+ new

@@ -2,11 +2,15 @@ # used in thread_client.c FrameInfo = Struct.new(:location, :self, :binding, :iseq, :class, :frame_depth, :has_return_value, :return_value, :show_line) end -require "debug/debug" +if File.exist? File.join(__dir__, 'debug.so') + require_relative 'debug.so' +else + require "debug/debug" +end require_relative 'source_repository' require_relative 'breakpoint' require_relative 'thread_client' require_relative 'config' @@ -131,10 +135,13 @@ end wait_command_loop tc end end + ensure + @bps.each{|k, bp| bp.disable} + @th_clients.each{|th, thc| thc.close} end @management_threads = [@session_server] @management_threads << @ui.reader_thread if @ui.respond_to? :reader_thread @@ -222,29 +229,40 @@ # * `c[ontinue]` # * Resume the program. when 'c', 'continue' @tc << :continue - # * `q[uit]` or exit or `Ctrl-D` + # * `q[uit]` or `Ctrl-D` # * Finish debugger (with the debuggee process on non-remote debugging). - when 'q', 'quit', 'exit' + when 'q', 'quit' if ask 'Really quit?' @ui.quit arg.to_i @tc << :continue else return :retry end - # * `kill` or `q[uit]!` - # * Stop the debuggee process. - when 'kill', 'quit!', 'q!' + # * `q[uit]!` + # * Same as q[uit] but without the confirmation prompt. + when 'q!', 'quit!' + @ui.quit arg.to_i + @tc << :continue + + # * `kill` + # * Stop the debuggee process with `Kernal#exit!`. + when 'kill' if ask 'Really kill?' exit! (arg || 1).to_i else return :retry end + # * `kill!` + # * Same as kill but without the confirmation prompt. + when 'kill!' + exit! (arg || 1).to_i + ### Breakpoint # * `b[reak]` # * Show all breakpoints. # * `b[reak] <line>` @@ -310,11 +328,11 @@ show_bps end return :retry # * `watch <expr>` - # * Stop the execution when the result of <expr> is changed. + # * Stop the execution when the result of `<expr>` is changed. # * Note that this feature is super slow. when 'wat', 'watch' if arg @tc << [:eval, :watch, arg] else @@ -408,11 +426,11 @@ # * Show display setting. # * `display <expr>` # * Show the result of `<expr>` at every suspended timing. when 'display' if arg && !arg.empty? - @displays << arg + @displays << arg @tc << [:eval, :try_display, @displays] else @tc << [:eval, :display, @displays] end @@ -457,23 +475,23 @@ return :retry ### Frame control # * `f[rame]` - # * Show current frame. + # * Show the current frame. # * `f[rame] <framenum>` - # * Specify frame. Evaluation are run on this frame environment. + # * Specify a current frame. Evaluation are run on specified frame. when 'frame', 'f' @tc << [:frame, :set, arg] # * `up` - # * Specify upper frame. + # * Specify the upper frame. when 'up' @tc << [:frame, :up] # * `down` - # * Specify down frame. + # * Specify the lower frame. when 'down' @tc << [:frame, :down] ### Evaluate @@ -799,11 +817,11 @@ else yield end end - ## event + ## event def on_load iseq, src @sr.add iseq, src pending_line_breakpoints do |bp| @@ -847,9 +865,16 @@ def resolve_path file File.realpath(File.expand_path(file)) rescue Errno::ENOENT return file if file == '-e' + $LOAD_PATH.each do |lp| + libpath = File.join(lp, file) + return File.realpath(libpath) + rescue Errno::ENOENT + # next + end + raise end def add_line_breakpoint file, line, **kw file = resolve_path(file)