Permalink
Browse files

Merge pull request #16 from farleyknight/patch-1

Test for ggdb, which is provided on Mac ports.
  • Loading branch information...
2 parents 06ff782 + 8c29f80 commit d2bc6ff939af67c746391e77d9d437d85e56e741 @ileitch committed Dec 5, 2013
Showing with 25 additions and 10 deletions.
  1. +15 −3 lib/hijack/gdb.rb
  2. +10 −7 tasks/gem.rake
View
18 lib/hijack/gdb.rb
@@ -10,7 +10,8 @@ def initialize(pid)
end
def eval(cmd)
- call("(void)rb_eval_string(#{cmd.strip.gsub(/"/, '\"').inspect})")
+ evaled_cmd = cmd.strip.gsub(/"/, '\"').inspect
+ call("(void)rb_eval_string(#{evaled_cmd})")
end
def quit
@@ -22,14 +23,25 @@ def quit
@gdb = nil
end
- protected
+ protected
def previous_frame_inner_to_this_frame?
backtrace.last =~ /previous frame inner to this frame/i
end
+ def gdb_path
+ # Check for gdb
+ if File.exists?(`which gdb`.strip)
+ `which gdb`.strip
+ elsif File.exists?(`which ggdb`.strip)
+ `which ggdb`.strip
+ else
+ raise "Cannot find suitable gdb!"
+ end
+ end
+
def attach_outside_gc
- @gdb = IO.popen("gdb -q #{@exec_path} #{@pid} 2>&1", 'r+')
+ @gdb = IO.popen("#{gdb_path} -q #{@exec_path} #{@pid} 2>&1", 'r+')
wait
ensure_attached_to_ruby_process
attached = false
View
17 tasks/gem.rake
@@ -1,14 +1,16 @@
-require 'rake/gempackagetask'
+# require 'rake/packagetask'
+require 'rubygems'
+require 'rubygems/package_task'
require 'yaml'
require './lib/hijack'
task :clean => :clobber_package
-spec = Gem::Specification.new do |s|
+spec = Gem::Specification.new do |s|
s.name = 'hijack'
s.version = Hijack.version
s.platform = Gem::Platform::RUBY
- s.summary =
+ s.summary =
s.description = 'Provides an irb session to a running ruby process.'
s.author = "Ian Leitch"
s.email = 'port001@gmail.com'
@@ -20,15 +22,16 @@ spec = Gem::Specification.new do |s|
s.require_path = "lib"
end
-Rake::GemPackageTask.new(spec) do |p|
- p.gem_spec = spec
+Gem::PackageTask.new(spec) do |pkg|
+ pkg.need_zip = true
+ pkg.need_tar = true
end
namespace :gem do
desc "Update the gemspec"
task :spec do
File.open("hijack.gemspec", 'w') { |f| f << YAML.dump(spec) }
- end
+ end
end
task :install => [:clean, :clobber, :package] do
@@ -37,4 +40,4 @@ end
task :uninstall => :clean do
sh "sudo gem uninstall -v #{HIJACK_VERSION} -x hijack"
-end
+end

0 comments on commit d2bc6ff

Please sign in to comment.