Class: Hijack::GDB
- Inherits:
-
Object
- Object
- Hijack::GDB
- Defined in:
- lib/hijack/gdb.rb
Instance Method Summary collapse
- #attached_to_ruby_process? ⇒ Boolean
- #detach ⇒ Object
- #eval(cmd) ⇒ Object
-
#initialize(pid) ⇒ GDB
constructor
A new instance of GDB.
- #main_thread_blocked_by_join? ⇒ Boolean
Constructor Details
#initialize(pid) ⇒ GDB
Returns a new instance of GDB.
5 6 7 8 9 10 |
# File 'lib/hijack/gdb.rb', line 5 def initialize(pid) @verbose = Hijack.[:gdb_debug] exec_path = File.join(Config::CONFIG['bindir'], Config::CONFIG['RUBY_INSTALL_NAME'] + Config::CONFIG['EXEEXT']) @gdb = IO.popen("gdb -q #{exec_path} #{pid} 2>&1", 'r+') wait end |
Instance Method Details
#attached_to_ruby_process? ⇒ Boolean
12 13 14 |
# File 'lib/hijack/gdb.rb', line 12 def attached_to_ruby_process? backtrace.any? {|line| line =~ /ruby_run/} end |
#detach ⇒ Object
28 29 30 31 32 |
# File 'lib/hijack/gdb.rb', line 28 def detach exec('detach') exec('quit') @gdb.close end |
#eval(cmd) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/hijack/gdb.rb', line 20 def eval(cmd) set_trap_pending set_breakpoint continue clear_breakpoint call("(void)rb_eval_string(#{cmd.strip.gsub(/"/, '\"').inspect})") end |
#main_thread_blocked_by_join? ⇒ Boolean
16 17 18 |
# File 'lib/hijack/gdb.rb', line 16 def main_thread_blocked_by_join? backtrace.any? {|line| line =~ /rb_thread_join/} end |