ruby-changes:69854
From: Hiroshi <ko1@a...>
Date: Mon, 22 Nov 2021 10:52:12 +0900 (JST)
Subject: [ruby-changes:69854] 8ddad13dcd (ruby_3_0): Bump debug version to 0.2.1
https://git.ruby-lang.org/ruby.git/commit/?id=8ddad13dcd From 8ddad13dcdf60f495fed13bef83016b2db597734 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA <hsbt@r...> Date: Thu, 11 Nov 2021 16:28:34 +0900 Subject: Bump debug version to 0.2.1 --- lib/debug.gemspec | 2 +- lib/debug.rb | 28 +++++++++++++++++++++------- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/lib/debug.gemspec b/lib/debug.gemspec index ccd7b776949..0c414d48276 100644 --- a/lib/debug.gemspec +++ b/lib/debug.gemspec @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/lib/debug.gemspec#L1 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@r..."] diff --git a/lib/debug.rb b/lib/debug.rb index bf53eb80a47..bf63ccf34d6 100644 --- a/lib/debug.rb +++ b/lib/debug.rb @@ -3,7 +3,10 @@ https://github.com/ruby/ruby/blob/trunk/lib/debug.rb#L3 # Copyright (C) 2000 Information-technology Promotion Agency, Japan # Copyright (C) 2000-2003 NAKAMURA, Hiroshi <nahi@r...> -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: https://github.com/ruby/ruby/blob/trunk/lib/debug.rb#L181 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__ https://github.com/ruby/ruby/blob/trunk/lib/debug.rb#L381 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__ https://github.com/ruby/ruby/blob/trunk/lib/debug.rb#L656 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 https://github.com/ruby/ruby/blob/trunk/lib/debug.rb#L1109 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 } -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/