Skip to content

Commit e7c3748

Browse files
nobuko1
authored andcommitted
Set path to debug.so
1 parent 92f65e7 commit e7c3748

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

exe/rdbg

+16-1
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,24 @@ when :start
1313
start_mode = config[:remote] ? "open" : 'start'
1414
cmd = config[:command] ? ARGV.shift : (ENV['RUBY'] || RbConfig.ruby)
1515

16+
if defined?($:.resolve_feature_path)
17+
begin
18+
_, sopath = $:.resolve_feature_path('debug/debug.so')
19+
rescue LoadError
20+
# raises LoadError before 3.1 (2.7 and 3.0)
21+
else
22+
sopath = File.dirname(File.dirname(sopath)) if sopath
23+
end
24+
else
25+
# `$:.resolve_feature_path` is not defined in 2.6 or earlier.
26+
so = "debug/debug.#{RbConfig::CONFIG['DLEXT']}"
27+
sopath = $:.find {|dir| File.exist?(File.join(dir, so))}
28+
end
29+
added = "-r #{libpath}/#{start_mode}"
30+
added = "-I #{sopath} #{added}" if sopath
1631
rubyopt = ENV['RUBYOPT']
1732
env = ::DEBUGGER__::Config.config_to_env_hash(config)
18-
env['RUBY_DEBUG_ADDED_RUBYOPT'] = added = "-r #{libpath}/#{start_mode}"
33+
env['RUBY_DEBUG_ADDED_RUBYOPT'] = added
1934
env['RUBYOPT'] = "#{rubyopt} #{added}"
2035

2136
exec(env, cmd, *ARGV)

0 commit comments

Comments
 (0)