diff options
author | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2021-11-11 16:28:34 +0900 |
---|---|---|
committer | nagachika <nagachika@ruby-lang.org> | 2021-11-22 10:51:35 +0900 |
commit | 8ddad13dcdf60f495fed13bef83016b2db597734 (patch) | |
tree | 3eb05850fc725cbf4108aacb63c48e4679034ee9 /lib | |
parent | c6d9bd75ee4a757618a23eacc6853fa34b091fc5 (diff) |
Bump debug version to 0.2.1
Diffstat (limited to 'lib')
-rw-r--r-- | lib/debug.gemspec | 2 | ||||
-rw-r--r-- | lib/debug.rb | 28 |
2 files changed, 22 insertions, 8 deletions
diff --git a/lib/debug.gemspec b/lib/debug.gemspec index ccd7b77694..0c414d4827 100644 --- a/lib/debug.gemspec +++ b/lib/debug.gemspec @@ -1,6 +1,6 @@ Gem::Specification.new do |spec| spec.name = "debug" - spec.version = "0.2.0" + spec.version = "0.2.1" spec.authors = ["Yukihiro Matsumoto"] spec.email = ["matz@ruby-lang.org"] diff --git a/lib/debug.rb b/lib/debug.rb index bf53eb80a4..bf63ccf34d 100644 --- a/lib/debug.rb +++ b/lib/debug.rb @@ -3,7 +3,10 @@ # Copyright (C) 2000 Information-technology Promotion Agency, Japan # Copyright (C) 2000-2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org> -require 'continuation' +if $SAFE > 0 + STDERR.print "-r debug.rb is not available in safe mode\n" + exit 1 +end require 'tracer' require 'pp' @@ -178,6 +181,9 @@ SCRIPT_LINES__ = {} unless defined? SCRIPT_LINES__ # :nodoc: class DEBUGGER__ MUTEX = Thread::Mutex.new # :nodoc: + CONTINUATIONS_SUPPORTED = RUBY_ENGINE == 'ruby' + + require 'continuation' if CONTINUATIONS_SUPPORTED class Context # :nodoc: DEBUG_LAST_CMD = [] @@ -375,8 +381,10 @@ class DEBUGGER__ def debug_command(file, line, id, binding) MUTEX.lock - unless defined?($debugger_restart) and $debugger_restart - callcc{|c| $debugger_restart = c} + if CONTINUATIONS_SUPPORTED + unless defined?($debugger_restart) and $debugger_restart + callcc{|c| $debugger_restart = c} + end end set_last_thread(Thread.current) frame_pos = 0 @@ -648,7 +656,11 @@ class DEBUGGER__ stdout.printf "%s\n", debug_eval($', binding).inspect when /^\s*r(?:estart)?$/ - $debugger_restart.call + if CONTINUATIONS_SUPPORTED + $debugger_restart.call + else + stdout.print "Restart requires continuations.\n" + end when /^\s*h(?:elp)?$/ debug_print_help() @@ -1097,9 +1109,11 @@ EOHELP stdout.printf "Debug.rb\n" stdout.printf "Emacs support available.\n\n" - RubyVM::InstructionSequence.compile_option = { - trace_instruction: true - } + if defined?(RubyVM::InstructionSequence) + RubyVM::InstructionSequence.compile_option = { + trace_instruction: true + } + end set_trace_func proc { |event, file, line, id, binding, klass, *rest| DEBUGGER__.context.trace_func event, file, line, id, binding, klass } |