aboutsummaryrefslogtreecommitdiffstats
path: root/tool
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-11-05 05:11:04 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-11-05 05:11:04 +0000
commitab9aa6eb18d734873148129bb43bd46c7b641652 (patch)
treea8f45f1694dafd0a158368f8f85adb6bd66c8a59 /tool
parent9dff1e90f9c4970b6ab12a8f7c25755819b07db6 (diff)
downloadruby-ab9aa6eb18d734873148129bb43bd46c7b641652.tar.gz
runruby.rb: support run.gdb by --debugger option
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60661 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'tool')
-rwxr-xr-xtool/runruby.rb41
1 files changed, 30 insertions, 11 deletions
diff --git a/tool/runruby.rb b/tool/runruby.rb
index d91f6e3bf8..dc2cced1d0 100755
--- a/tool/runruby.rb
+++ b/tool/runruby.rb
@@ -23,7 +23,13 @@ while arg = ARGV[0]
# obsolete switch do nothing
when re =~ "debugger"
require 'shellwords'
- precommand.concat(value ? (Shellwords.shellwords(value) unless value == "no") : %w"gdb --args")
+ case value
+ when nil
+ debugger = :gdb
+ when "no"
+ else
+ debugger = Shellwords.shellwords(value)
+ end and precommand |= [:debugger]
when re =~ "precommand"
require 'shellwords'
precommand.concat(Shellwords.shellwords(value))
@@ -37,19 +43,28 @@ end
unless defined?(File.realpath)
def File.realpath(*args)
- Dir.chdir(expand_path(*args)) do
- Dir.pwd
+ path = expand_path(*args)
+ if File.stat(path).directory?
+ Dir.chdir(path) {Dir.pwd}
+ else
+ dir, base = File.split(path)
+ File.join(Dir.chdir(dir) {Dir.pwd}, base)
end
end
end
srcdir ||= File.realpath('..', File.dirname(__FILE__))
-archdir ||= '.'
+begin
+ conffile = File.realpath('rbconfig.rb', archdir)
+rescue Errno::ENOENT => e
+ abort "#$0: rbconfig.rb not found, use --archdir option"
+end
-abs_archdir = File.expand_path(archdir)
+abs_archdir = File.dirname(conffile)
+archdir ||= abs_archdir
$:.unshift(abs_archdir)
-config = File.read(conffile = File.join(abs_archdir, 'rbconfig.rb'))
+config = File.read(conffile)
config.sub!(/^(\s*)RUBY_VERSION\b.*(\sor\s*)\n.*\n/, '')
config = Module.new {module_eval(config, conffile)}::RbConfig::CONFIG
@@ -106,12 +121,16 @@ end
ENV.update env
-if ENV['RUNRUBY_USE_GDB'] == 'true'
- if File.exist?('run.gdb')
- precommand = %w'gdb -x run.gdb --args'
- else
- precommand = %w'gdb --args'
+if debugger or ENV['RUNRUBY_USE_GDB'] == 'true'
+ if debugger == :gdb
+ debugger = %w'gdb'
+ if File.exist?(gdb = 'run.gdb') or
+ File.exist?(gdb = File.join(abs_archdir, 'run.gdb'))
+ debugger.push('-x', gdb)
+ end
+ debugger << '--args'
end
+ precommand[precommand.index(:debugger), 1] = debugger
end
cmd = [runner || ruby]