Class: GDB

Inherits:
NativeDebugger show all
Defined in:
lib/ruby-debug-ide/attach/gdb.rb

Instance Attribute Summary

Attributes inherited from NativeDebugger

#main_thread, #pid, #pipe, #process_threads

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from NativeDebugger

#attach_to_process, #continue, #execute, #exit, #exited?, #find_attach_lib, #get_response, #wait_line_event

Constructor Details

#initialize(executable, pid, flags, gems_to_include, debugger_loader_path, argv) ⇒ GDB

Returns a new instance of GDB.



5
6
7
# File 'lib/ruby-debug-ide/attach/gdb.rb', line 5

def initialize(executable, pid, flags, gems_to_include, debugger_loader_path, argv)
  super(executable, pid, flags, gems_to_include, debugger_loader_path, argv)
end

Class Method Details

.to_sObject



68
69
70
# File 'lib/ruby-debug-ide/attach/gdb.rb', line 68

def to_s
  'gdb'
end

Instance Method Details

#call_start_attachObject



44
45
46
47
48
49
# File 'lib/ruby-debug-ide/attach/gdb.rb', line 44

def call_start_attach
  super()
  execute "call dlopen(\"#{@path_to_attach}\", 2)"
  execute 'call debase_start_attach()'
  set_break(@tbreak)
end

#check_already_under_debugObject



31
32
33
34
# File 'lib/ruby-debug-ide/attach/gdb.rb', line 31

def check_already_under_debug
  threads = execute 'info threads'
  threads =~ /ruby-debug-ide/
end

#check_delimiter(line) ⇒ Object



55
56
57
# File 'lib/ruby-debug-ide/attach/gdb.rb', line 55

def check_delimiter(line)
  line =~ /\$\d+\s=\s"#{@delimiter}"/
end

#load_debuggerObject



59
60
61
# File 'lib/ruby-debug-ide/attach/gdb.rb', line 59

def load_debugger
  execute "call #{@eval_string}"
end


51
52
53
# File 'lib/ruby-debug-ide/attach/gdb.rb', line 51

def print_delimiter
  @pipe.puts "print \"#{@delimiter}\""
end

#set_break(str) ⇒ Object



40
41
42
# File 'lib/ruby-debug-ide/attach/gdb.rb', line 40

def set_break(str)
  execute "tbreak #{str}"
end

#set_flagsObject



9
10
11
12
# File 'lib/ruby-debug-ide/attach/gdb.rb', line 9

def set_flags
  execute 'set scheduler-locking off' # we will deadlock with it
  execute 'set unwindonsignal on'     # in case of some signal we will exit gdb
end

#switch_to_thread(thread_num) ⇒ Object



36
37
38
# File 'lib/ruby-debug-ide/attach/gdb.rb', line 36

def switch_to_thread(thread_num)
  execute "thread #{thread_num}"
end

#to_sObject



63
64
65
# File 'lib/ruby-debug-ide/attach/gdb.rb', line 63

def to_s
  GDB.to_s
end

#update_threadsObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/ruby-debug-ide/attach/gdb.rb', line 14

def update_threads
  @process_threads = []
  info_threads = (execute 'info threads').split("\n")
  info_threads.each do |thread_info|
    next unless thread_info =~ /[\s*]*\d+\s+Thread.*/
    $stdout.puts "thread_info: #{thread_info}"
    is_main = thread_info[0] == '*'
    thread_num = thread_info.sub(/[\s*]*/, '').sub(/\s.*$/, '').to_i
    thread = ProcessThread.new(thread_num, is_main, thread_info, self)
    if thread.is_main
      @main_thread = thread
    end
    @process_threads << thread
  end
  @process_threads
end