diff --git a/lib/debug/session.rb b/lib/debug/session.rb index 3db2f45da..0a3174473 100644 --- a/lib/debug/session.rb +++ b/lib/debug/session.rb @@ -82,7 +82,7 @@ def last_line def first_line self.to_a[4][:code_location][0] end unless method_defined?(:first_line) -end +end if defined?(RubyVM::InstructionSequence) module DEBUGGER__ PresetCommands = Struct.new(:commands, :source, :auto_continue) @@ -133,7 +133,7 @@ def initialize @commands = {} @unsafe_context = false - @has_keep_script_lines = RubyVM.respond_to? :keep_script_lines + @has_keep_script_lines = defined?(RubyVM.keep_script_lines) @tp_load_script = TracePoint.new(:script_compiled){|tp| eval_script = tp.eval_script unless @has_keep_script_lines diff --git a/lib/debug/source_repository.rb b/lib/debug/source_repository.rb index ddcfd6e93..52e43cf7d 100644 --- a/lib/debug/source_repository.rb +++ b/lib/debug/source_repository.rb @@ -22,7 +22,7 @@ def get iseq end end - if RubyVM.respond_to? :keep_script_lines + if defined?(RubyVM.keep_script_lines) # Ruby 3.1 and later RubyVM.keep_script_lines = true require 'objspace'