lib/ruby-debug/command.rb in ruby-debug-ide-0.4.6 vs lib/ruby-debug/command.rb in ruby-debug-ide-0.4.7

- old
+ new

@@ -1,7 +1,12 @@ -require 'ruby-debug/helper' +if RUBY_VERSION < "1.9" + require 'ruby-debug/helper' +else + require_relative 'helper' +end + module Debugger class Command # :nodoc: SubcmdStruct=Struct.new(:name, :min, :short_help, :long_help) unless defined?(SubcmdStruct) @@ -95,11 +100,13 @@ # see Timeout::timeout, the difference is that we must use a DebugThread # because every other thread would be halted when the event hook is reached # in ruby-debug.c def timeout(sec) return yield if sec == nil or sec.zero? - raise ThreadError, "timeout within critical session" if Thread.critical + if RUBY_VERSION < "1.9" + raise ThreadError, "timeout within critical session" if Thread.critical + end begin x = Thread.current y = DebugThread.start { sleep sec x.raise StandardError, "Timeout: evaluation took longer than #{sec} seconds." if x.alive? @@ -110,10 +117,11 @@ end end def debug_eval(str, b = get_binding) begin + str = str.to_s max_time = 10 to_inspect = str.gsub(/\\n/, "\n") @printer.print_debug("Evaluating with timeout after %i sec", max_time) timeout(max_time) do eval(to_inspect, b) @@ -124,9 +132,10 @@ end end def debug_silent_eval(str) begin + str = str.to_s eval(str, get_binding) rescue StandardError, ScriptError nil end end