mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
1 changed files with 30 additions and 11 deletions
|
@ -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]
|
||||
|
|
Loading…
Reference in a new issue