Class: Hijack::GDB

Inherits:
Object
  • Object
show all
Defined in:
lib/hijack/gdb.rb

Instance Method Summary collapse

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.options[: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

Returns:

  • (Boolean)


12
13
14
15
# File 'lib/hijack/gdb.rb', line 12

def attached_to_ruby_process?
  # TODO: Implement me
  true
end

#detachObject



21
22
23
24
25
26
# File 'lib/hijack/gdb.rb', line 21

def detach
  @gdb.puts('detach')
  wait
  @gdb.puts('quit')
  @gdb.close
end

#eval(cmd) ⇒ Object



17
18
19
# File 'lib/hijack/gdb.rb', line 17

def eval(cmd)
  call("(void)rb_eval_string(#{cmd.strip.gsub(/"/, '\"').inspect})")
end