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
This commit is contained in:
parent
cb7d9fe95f
commit
80aee7903d
@ -23,7 +23,13 @@ while arg = ARGV[0]
|
|||||||
# obsolete switch do nothing
|
# obsolete switch do nothing
|
||||||
when re =~ "debugger"
|
when re =~ "debugger"
|
||||||
require 'shellwords'
|
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"
|
when re =~ "precommand"
|
||||||
require 'shellwords'
|
require 'shellwords'
|
||||||
precommand.concat(Shellwords.shellwords(value))
|
precommand.concat(Shellwords.shellwords(value))
|
||||||
@ -37,19 +43,28 @@ end
|
|||||||
|
|
||||||
unless defined?(File.realpath)
|
unless defined?(File.realpath)
|
||||||
def File.realpath(*args)
|
def File.realpath(*args)
|
||||||
Dir.chdir(expand_path(*args)) do
|
path = expand_path(*args)
|
||||||
Dir.pwd
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
srcdir ||= File.realpath('..', File.dirname(__FILE__))
|
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)
|
$:.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.sub!(/^(\s*)RUBY_VERSION\b.*(\sor\s*)\n.*\n/, '')
|
||||||
config = Module.new {module_eval(config, conffile)}::RbConfig::CONFIG
|
config = Module.new {module_eval(config, conffile)}::RbConfig::CONFIG
|
||||||
|
|
||||||
@ -106,12 +121,16 @@ end
|
|||||||
|
|
||||||
ENV.update env
|
ENV.update env
|
||||||
|
|
||||||
if ENV['RUNRUBY_USE_GDB'] == 'true'
|
if debugger or ENV['RUNRUBY_USE_GDB'] == 'true'
|
||||||
if File.exist?('run.gdb')
|
if debugger == :gdb
|
||||||
precommand = %w'gdb -x run.gdb --args'
|
debugger = %w'gdb'
|
||||||
else
|
if File.exist?(gdb = 'run.gdb') or
|
||||||
precommand = %w'gdb --args'
|
File.exist?(gdb = File.join(abs_archdir, 'run.gdb'))
|
||||||
|
debugger.push('-x', gdb)
|
||||||
end
|
end
|
||||||
|
debugger << '--args'
|
||||||
|
end
|
||||||
|
precommand[precommand.index(:debugger), 1] = debugger
|
||||||
end
|
end
|
||||||
|
|
||||||
cmd = [runner || ruby]
|
cmd = [runner || ruby]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user