lib/ruby-debug/command.rb in ruby-debug-ide-0.4.11 vs lib/ruby-debug/command.rb in ruby-debug-ide-0.4.16
- old
+ new
@@ -100,12 +100,12 @@
# 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?
- if RUBY_VERSION < "1.9"
- raise ThreadError, "timeout within critical session" if Thread.critical
+ if Thread.respond_to?(:critical) and Thread.critical
+ raise ThreadError, "timeout within critical session"
end
begin
x = Thread.current
y = DebugThread.start {
sleep sec
@@ -120,10 +120,10 @@
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)
+ @printer.print_debug("Evaluating #{str} with timeout after %i sec", max_time)
timeout(max_time) do
eval(to_inspect, b)
end
rescue StandardError, ScriptError => e
@printer.print_exception(e, @state.binding)