Class: Hijack::GDB
- Inherits:
-
Object
- Object
- Hijack::GDB
- Defined in:
- lib/hijack/gdb.rb
Instance Method Summary collapse
- #detach ⇒ Object
- #ensure_attached_to_ruby_process ⇒ Object
- #ensure_main_thread_not_blocked_by_join ⇒ Object
- #eval(cmd) ⇒ Object
-
#initialize(pid) ⇒ GDB
constructor
A new instance of GDB.
Constructor Details
Instance Method Details
#detach ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/hijack/gdb.rb', line 33 def detach return unless @gdb exec('detach') exec('quit') @backtrace = nil @gdb.close @gdb = nil end |
#ensure_attached_to_ruby_process ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/hijack/gdb.rb', line 12 def ensure_attached_to_ruby_process unless backtrace.any? {|line| line =~ /rb_/} puts "\n=> #{@pid} doesn't appear to be a Ruby process!" detach exit 1 end end |
#ensure_main_thread_not_blocked_by_join ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/hijack/gdb.rb', line 20 def ensure_main_thread_not_blocked_by_join if backtrace.any? {|line| line =~ /rb_thread_join/} puts "\n=> Unable to hijack #{@pid} because the main thread is blocked waiting for another thread to join." puts "=> Check that you are using the most recent version of hijack, a newer version may have solved this shortcoming." detach exit 1 end end |
#eval(cmd) ⇒ Object
29 30 31 |
# File 'lib/hijack/gdb.rb', line 29 def eval(cmd) call("(void)rb_eval_string(#{cmd.strip.gsub(/"/, '\"').inspect})") end |