ruby-debug-ide22 0.7.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGES +75 -0
  3. data/ChangeLog.archive +1073 -0
  4. data/ChangeLog.md +594 -0
  5. data/Gemfile +38 -0
  6. data/MIT-LICENSE +24 -0
  7. data/Rakefile +93 -0
  8. data/bin/gdb_wrapper +96 -0
  9. data/bin/rdebug-ide +200 -0
  10. data/ext/mkrf_conf.rb +44 -0
  11. data/lib/ruby-debug-ide/attach/debugger_loader.rb +20 -0
  12. data/lib/ruby-debug-ide/attach/gdb.rb +73 -0
  13. data/lib/ruby-debug-ide/attach/lldb.rb +71 -0
  14. data/lib/ruby-debug-ide/attach/native_debugger.rb +133 -0
  15. data/lib/ruby-debug-ide/attach/process_thread.rb +54 -0
  16. data/lib/ruby-debug-ide/attach/util.rb +115 -0
  17. data/lib/ruby-debug-ide/command.rb +187 -0
  18. data/lib/ruby-debug-ide/commands/breakpoints.rb +128 -0
  19. data/lib/ruby-debug-ide/commands/catchpoint.rb +64 -0
  20. data/lib/ruby-debug-ide/commands/condition.rb +51 -0
  21. data/lib/ruby-debug-ide/commands/control.rb +158 -0
  22. data/lib/ruby-debug-ide/commands/enable.rb +203 -0
  23. data/lib/ruby-debug-ide/commands/eval.rb +64 -0
  24. data/lib/ruby-debug-ide/commands/expression_info.rb +71 -0
  25. data/lib/ruby-debug-ide/commands/file_filtering.rb +107 -0
  26. data/lib/ruby-debug-ide/commands/frame.rb +155 -0
  27. data/lib/ruby-debug-ide/commands/inspect.rb +25 -0
  28. data/lib/ruby-debug-ide/commands/jump.rb +73 -0
  29. data/lib/ruby-debug-ide/commands/load.rb +18 -0
  30. data/lib/ruby-debug-ide/commands/pause.rb +33 -0
  31. data/lib/ruby-debug-ide/commands/set_type.rb +47 -0
  32. data/lib/ruby-debug-ide/commands/stepping.rb +108 -0
  33. data/lib/ruby-debug-ide/commands/threads.rb +178 -0
  34. data/lib/ruby-debug-ide/commands/variables.rb +154 -0
  35. data/lib/ruby-debug-ide/event_processor.rb +71 -0
  36. data/lib/ruby-debug-ide/greeter.rb +42 -0
  37. data/lib/ruby-debug-ide/helper.rb +33 -0
  38. data/lib/ruby-debug-ide/ide_processor.rb +155 -0
  39. data/lib/ruby-debug-ide/interface.rb +45 -0
  40. data/lib/ruby-debug-ide/multiprocess/monkey.rb +47 -0
  41. data/lib/ruby-debug-ide/multiprocess/pre_child.rb +59 -0
  42. data/lib/ruby-debug-ide/multiprocess/starter.rb +11 -0
  43. data/lib/ruby-debug-ide/multiprocess/unmonkey.rb +31 -0
  44. data/lib/ruby-debug-ide/multiprocess.rb +23 -0
  45. data/lib/ruby-debug-ide/thread_alias.rb +27 -0
  46. data/lib/ruby-debug-ide/version.rb +3 -0
  47. data/lib/ruby-debug-ide/xml_printer.rb +571 -0
  48. data/lib/ruby-debug-ide.rb +228 -0
  49. data/ruby-debug-ide.gemspec +47 -0
  50. metadata +110 -0
data/Rakefile ADDED
@@ -0,0 +1,93 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+
4
+ desc 'Default: run unit tests.'
5
+ task :default => [:test]
6
+
7
+ # Unit tests
8
+ Rake::TestTask.new do |t|
9
+ t.libs << "test"
10
+ t.libs << "test-base"
11
+ t.pattern = 'test/**/*_test.rb'
12
+ t.verbose = true
13
+ t.warning = false
14
+ end
15
+
16
+ desc "Create a ChangeLog"
17
+ # simple rake task to output a changelog between two commits, tags ...
18
+ # output is formatted simply, commits are grouped under each author name
19
+ desc "generate changelog with nice clean output"
20
+ task :changelog, :since_c, :until_c do |t,args|
21
+ since_c = args[:since_c] || `git tag | head -1`.chomp
22
+ until_c = args[:until_c]
23
+ cmd=`git log --pretty='format:%ci::%an <%ae>::%s::%H' #{since_c}..#{until_c}`
24
+
25
+ entries = Hash.new
26
+ changelog_content = String.new
27
+
28
+ cmd.split("\n").each do |entry|
29
+ date, author, subject, hash = entry.chomp.split("::")
30
+ entries[author] = Array.new unless entries[author]
31
+ day = date.split(" ").first
32
+ entries[author] << "#{subject} (#{hash})" unless subject =~ /Merge/
33
+ end
34
+
35
+ # generate clean output
36
+ entries.keys.each do |author|
37
+ changelog_content += author + "\n"
38
+ entries[author].reverse.each { |entry| changelog_content += " * #{entry}\n" }
39
+ end
40
+
41
+ puts changelog_content
42
+ end
43
+
44
+ desc "Generates travis.yaml"
45
+ task :gen_travis do
46
+ versions = []
47
+
48
+ def versions.add(major:, minor:, include_macos: true)
49
+ self << { major: major, minor: [minor], include_macos: include_macos }
50
+ end
51
+
52
+ versions.add major: '3.0', minor: 1
53
+ versions.add major: '2.7', minor: 3
54
+ versions.add major: '2.6', minor: 7
55
+ versions.add major: '2.5', minor: 9
56
+ versions.add major: '2.4', minor: 10
57
+ versions.add major: '2.3', minor: 8, include_macos: false
58
+ versions.add major: '2.2', minor: 10, include_macos: false
59
+ versions.add major: '2.1', minor: 10, include_macos: false
60
+ versions.add major: '2.0', minor: 0, include_macos: false
61
+ versions.add major: '1.9', minor: 3, include_macos: false
62
+ versions.add major: '1.8', minor: 7, include_macos: false
63
+
64
+ puts <<EOM
65
+ language: ruby
66
+ dist: trusty
67
+ matrix:
68
+ fast_finish: true
69
+ include:
70
+ EOM
71
+
72
+ loop do
73
+ found_some = false
74
+
75
+ versions.each do |version|
76
+ minor = version[:minor].pop
77
+ if minor
78
+ found_some = true
79
+ full_version = "#{version[:major]}.#{minor}"
80
+ puts <<EOM
81
+ - os: linux
82
+ rvm: #{full_version}
83
+ EOM
84
+ puts <<EOM if version[:include_macos]
85
+ - os: osx
86
+ rvm: #{full_version}
87
+ EOM
88
+ end
89
+ end
90
+
91
+ break unless found_some
92
+ end
93
+ end
data/bin/gdb_wrapper ADDED
@@ -0,0 +1,96 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'optparse'
4
+ require 'thread'
5
+ require 'ostruct'
6
+
7
+ $stdout.sync = true
8
+ $stderr.sync = true
9
+
10
+ options = OpenStruct.new(
11
+ 'pid' => nil,
12
+ 'sdk_path' => nil,
13
+ 'uid' => nil,
14
+ 'gems_to_include' => []
15
+ )
16
+
17
+ module DebugPrinter
18
+
19
+ class << self
20
+ attr_accessor :cli_debug
21
+
22
+ def print_debug(msg)
23
+ if DebugPrinter.cli_debug
24
+ $stderr.puts msg
25
+ end
26
+ end
27
+ end
28
+
29
+ end
30
+
31
+ DebugPrinter.cli_debug = ARGV.include? '--debug'
32
+
33
+ opts = OptionParser.new do |opts|
34
+ # TODO need some banner
35
+ opts.banner = <<EOB
36
+ Some useful banner.
37
+ EOB
38
+
39
+ opts.on('--pid PID', 'pid of process you want to attach to for debugging') do |pid|
40
+ options.pid = pid
41
+ end
42
+
43
+ opts.on('--ruby-path RUBY_PATH', 'path to ruby interpreter') do |ruby_path|
44
+ options.ruby_path = ruby_path
45
+ end
46
+
47
+ opts.on('--uid UID', 'uid which this process should set after executing gdb attach') do |uid|
48
+ options.uid = uid
49
+ end
50
+
51
+ opts.on('--include-gem GEM_LIB_PATH', 'lib of gem to include') do |gem_lib_path|
52
+ options.gems_to_include << gem_lib_path
53
+ end
54
+ end
55
+
56
+ opts.parse! ARGV
57
+
58
+ unless options.pid
59
+ $stderr.puts 'You should specify PID of process you want to attach to'
60
+ exit 1
61
+ end
62
+
63
+ unless options.ruby_path
64
+ $stderr.puts 'You should specify path to the ruby interpreter'
65
+ exit 1
66
+ end
67
+
68
+ argv = '["' + ARGV * '", "' + '"]'
69
+ child_argv = '["' + ARGV * '", "' + "', '--ignore-port" + '"]'
70
+ debugger_loader_path = File.expand_path(File.dirname(__FILE__)) + '/../lib/ruby-debug-ide/attach/debugger_loader'
71
+
72
+ options.gems_to_include.each do |gem_path|
73
+ $LOAD_PATH.unshift(gem_path) unless $LOAD_PATH.include?(gem_path)
74
+ end
75
+
76
+ require 'ruby-debug-ide/greeter'
77
+ Debugger::print_greeting_msg($stdout, nil, nil)
78
+
79
+ require 'ruby-debug-ide/attach/util'
80
+ require 'ruby-debug-ide/attach/native_debugger'
81
+ require 'ruby-debug-ide/attach/process_thread'
82
+
83
+
84
+ child_pids = get_child_pids(options.pid.to_s)
85
+ attach_threads = Array.new
86
+ attach_threads << attach_and_return_thread(options, options.pid, debugger_loader_path, argv)
87
+
88
+ attach_threads << child_pids.map {|pid| attach_and_return_thread(options, pid, debugger_loader_path, child_argv)}
89
+
90
+
91
+ attach_threads.each {|thread| thread.join}
92
+ if options.uid
93
+ DebugPrinter.print_debug("changing current uid from #{Process.uid} to #{options.uid}")
94
+ Process::Sys.setuid(options.uid.to_i)
95
+ end
96
+ sleep
data/bin/rdebug-ide ADDED
@@ -0,0 +1,200 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'
3
+ require 'optparse'
4
+ require "ostruct"
5
+ if RUBY_VERSION < "1.9"
6
+ require 'ruby-debug-ide'
7
+ else
8
+ require_relative '../lib/ruby-debug-ide'
9
+ end
10
+
11
+ $stdout.sync=true
12
+
13
+ options = OpenStruct.new(
14
+ 'frame_bind' => false,
15
+ 'host' => nil,
16
+ 'load_mode' => false,
17
+ 'port' => 1234,
18
+ 'stop' => false,
19
+ 'tracing' => false,
20
+ 'skip_wait_for_start' => false,
21
+ 'keep_process_alive' => false,
22
+ 'int_handler' => true,
23
+ 'dispatcher_port' => -1,
24
+ 'evaluation_timeout' => 10,
25
+ 'trace_to_s' => false,
26
+ 'debugger_memory_limit' => 10,
27
+ 'inspect_time_limit' => 100,
28
+ 'rm_protocol_extensions' => false,
29
+ 'catchpoint_deleted_event' => false,
30
+ 'value_as_nested_element' => false,
31
+ 'attach_mode' => false,
32
+ 'cli_debug' => false,
33
+ 'key_value_mode' => false,
34
+ 'socket_path' => nil
35
+ )
36
+
37
+ opts = OptionParser.new do |opts|
38
+ opts.banner = <<EOB
39
+ Using ruby-debug-base #{Debugger::VERSION}
40
+ Usage: rdebug-ide is supposed to be called from RDT, NetBeans, RubyMine, or
41
+ the IntelliJ IDEA Ruby plugin. The command line interface to
42
+ ruby-debug is rdebug.
43
+ EOB
44
+ opts.separator ""
45
+ opts.separator "Options:"
46
+
47
+ opts.on("-h", "--host HOST", "Host name used for remote debugging") {|host| options.host = host}
48
+ opts.on("-p", "--port PORT", Integer, "Port used for remote debugging") {|port| options.port = port}
49
+ opts.on("--dispatcher-port PORT", Integer, "Port used for multi-process debugging dispatcher") do |dp|
50
+ options.dispatcher_port = dp
51
+ end
52
+ opts.on('--evaluation-timeout TIMEOUT', Integer,'evaluation timeout in seconds (default: 10)') do |timeout|
53
+ options.evaluation_timeout = timeout
54
+ end
55
+ opts.on("--evaluation-control", "trace to_s evaluation") {options.trace_to_s = true}
56
+
57
+ opts.on("-m", "--memory-limit LIMIT", Integer, "evaluation memory limit in mb (default: 10)") do |limit|
58
+ if defined?(JRUBY_VERSION) || RUBY_VERSION < '2.0'
59
+ $stderr.puts "Evaluation memory limit is ineffective in JRuby and MRI < 2.0"
60
+ limit = 0
61
+ end
62
+ options.debugger_memory_limit = limit
63
+ options.trace_to_s ||= limit > 0
64
+ end
65
+
66
+ opts.on("-t", "--time-limit LIMIT", Integer, "evaluation time limit in milliseconds (default: 100)") do |limit|
67
+ options.inspect_time_limit = limit
68
+ options.trace_to_s ||= limit > 0
69
+ end
70
+
71
+ opts.on('--stop', 'stop when the script is loaded') {options.stop = true}
72
+ opts.on("-x", "--trace", "turn on line tracing") {options.tracing = true}
73
+ opts.on("--skip_wait_for_start", "skip wait for 'start' command") {options.skip_wait_for_start = true}
74
+ opts.on("--keep-process-alive", "don't exit the process when debugger is exited") {options.keep_process_alive = true}
75
+ opts.on("-l", "--load-mode", "load mode (experimental)") {options.load_mode = true}
76
+ opts.on("-d", "--debug", "Debug self - prints information for debugging ruby-debug itself") do
77
+ Debugger.cli_debug = true
78
+ options.cli_debug = true
79
+ end
80
+ opts.on("--xml-debug", "Debug self - sends information <message>s for debugging ruby-debug itself") do
81
+ Debugger.xml_debug = true
82
+ end
83
+ opts.on("-I", "--include PATH", String, "Add PATH to $LOAD_PATH") do |path|
84
+ $LOAD_PATH.unshift(path)
85
+ end
86
+ opts.on("--attach-mode", "Tells that rdebug-ide is working in attach mode") do
87
+ options.attach_mode = true
88
+ end
89
+ opts.on("--key-value", "Key/Value presentation of hash items") do
90
+ options.key_value_mode = true
91
+ end
92
+ opts.on("--ignore-port", "Generate another port") do
93
+ options.ignore_port = true
94
+ end
95
+ opts.on("--keep-frame-binding", "Keep frame bindings") {options.frame_bind = true}
96
+ opts.on("--disable-int-handler", "Disables interrupt signal handler") {options.int_handler = false}
97
+ opts.on("--rubymine-protocol-extensions", "Enable all RubyMine-specific incompatible protocol extensions") do
98
+ options.rm_protocol_extensions = true
99
+ end
100
+ opts.on("--catchpoint-deleted-event", "Enable chatchpointDeleted event") do
101
+ options.catchpoint_deleted_event = true
102
+ end
103
+ opts.on("--value-as-nested-element", "Allow to pass variable's value as nested element instead of attribute") do
104
+ options.value_as_nested_element = true
105
+ end
106
+ opts.on("--socket-path PATH", "Listen for debugger on the given UNIX domain socket path") do |path|
107
+ options.socket_path = path
108
+ end
109
+ opts.separator ""
110
+ opts.separator "Common options:"
111
+ opts.on_tail("-v", "--version", "Show version") do
112
+ puts "Using ruby-debug-base #{Debugger::VERSION}"
113
+ exit
114
+ end
115
+ end
116
+
117
+ begin
118
+ Debugger::ARGV = ARGV.clone
119
+ rdebug_path = File.expand_path($0)
120
+ if RUBY_PLATFORM =~ /mswin/
121
+ rdebug_path += ".cmd" unless rdebug_path =~ /\.cmd$/i
122
+ end
123
+ Debugger::RDEBUG_SCRIPT = rdebug_path
124
+ opts.parse! ARGV
125
+ rescue StandardError => e
126
+ puts opts
127
+ puts
128
+ puts e.message
129
+ exit(1)
130
+ end
131
+
132
+ if ARGV.empty? && !options.attach_mode
133
+ puts opts
134
+ puts
135
+ puts "Must specify a script to run"
136
+ exit(1)
137
+ end
138
+
139
+ # save script name
140
+ if !options.attach_mode
141
+ Debugger::PROG_SCRIPT = ARGV.shift
142
+ else
143
+ Debugger::PROG_SCRIPT = $0
144
+ end
145
+
146
+ if options.dispatcher_port != -1
147
+ ENV['IDE_PROCESS_DISPATCHER'] = options.dispatcher_port.to_s
148
+ if RUBY_VERSION < "1.9"
149
+ lib_path = File.expand_path(File.dirname(__FILE__) + "/../lib/")
150
+ $: << lib_path unless $:.include? lib_path
151
+ require 'ruby-debug-ide/multiprocess'
152
+ else
153
+ require_relative '../lib/ruby-debug-ide/multiprocess'
154
+ end
155
+ Debugger::MultiProcess.do_monkey
156
+
157
+ ENV['DEBUGGER_STORED_RUBYLIB'] = ENV['RUBYLIB']
158
+ old_opts = ENV['RUBYOPT'] || ''
159
+ starter = "-r#{File.expand_path(File.dirname(__FILE__))}/../lib/ruby-debug-ide/multiprocess/starter"
160
+ unless old_opts.include? starter
161
+ ENV['RUBYOPT'] = starter
162
+ ENV['RUBYOPT'] += " #{old_opts}" if old_opts != ''
163
+ end
164
+ ENV['DEBUGGER_CLI_DEBUG'] = Debugger.cli_debug.to_s
165
+ end
166
+
167
+ if options.int_handler
168
+ # install interruption handler
169
+ trap('INT') { Debugger.interrupt_last }
170
+ end
171
+
172
+ if options.keep_process_alive
173
+ ENV['DEBUGGER_KEEP_PROCESS_ALIVE'] = "true"
174
+ end
175
+
176
+ # set options
177
+ Debugger.keep_frame_binding = options.frame_bind
178
+ Debugger.tracing = options.tracing
179
+ Debugger.evaluation_timeout = options.evaluation_timeout
180
+ Debugger.trace_to_s = options.trace_to_s && (options.debugger_memory_limit > 0 || options.inspect_time_limit > 0)
181
+ Debugger.debugger_memory_limit = options.debugger_memory_limit
182
+ Debugger.inspect_time_limit = options.inspect_time_limit
183
+ Debugger.catchpoint_deleted_event = options.catchpoint_deleted_event || options.rm_protocol_extensions
184
+ Debugger.value_as_nested_element = options.value_as_nested_element || options.rm_protocol_extensions
185
+ Debugger.key_value_mode = options.key_value_mode
186
+
187
+ if options.attach_mode
188
+ if Debugger::FRONT_END == "debase"
189
+ Debugger.init_variables
190
+ end
191
+
192
+ Debugger::MultiProcess::pre_child(options)
193
+
194
+ if Debugger::FRONT_END == "debase"
195
+ Debugger.setup_tracepoints
196
+ Debugger.prepare_context
197
+ end
198
+ else
199
+ Debugger.debug_program(options)
200
+ end
data/ext/mkrf_conf.rb ADDED
@@ -0,0 +1,44 @@
1
+ install_dir = File.expand_path("../../../..", __FILE__)
2
+ jruby = defined?(JRUBY_VERSION) || (defined?(RUBY_ENGINE) && 'jruby' == RUBY_ENGINE)
3
+ rbx = defined?(RUBY_ENGINE) && 'rbx' == RUBY_ENGINE
4
+
5
+ unless jruby || rbx
6
+ require 'rubygems'
7
+ require 'rubygems/command.rb'
8
+ require 'rubygems/dependency.rb'
9
+ require 'rubygems/dependency_installer.rb'
10
+
11
+ begin
12
+ Gem::Command.build_args = ARGV
13
+ rescue NoMethodError
14
+ end
15
+
16
+ if RUBY_VERSION < "1.9"
17
+ dep = Gem::Dependency.new("ruby-debug-base", '>=0.10.4')
18
+ elsif RUBY_VERSION < '2.0'
19
+ dep = Gem::Dependency.new("ruby-debug-base19x", '>=0.11.30.pre15')
20
+ else
21
+ dep = Gem::Dependency.new("debase", '> 0')
22
+ end
23
+
24
+ begin
25
+ puts "Installing base gem"
26
+ inst = Gem::DependencyInstaller.new(:prerelease => dep.prerelease?, :install_dir => install_dir)
27
+ inst.install dep
28
+ rescue
29
+ begin
30
+ inst = Gem::DependencyInstaller.new(:prerelease => true, :install_dir => install_dir)
31
+ inst.install dep
32
+ rescue Exception => e
33
+ puts e
34
+ puts e.backtrace.join "\n "
35
+ exit(1)
36
+ end
37
+ end unless dep.nil? || dep.matching_specs.any?
38
+ end
39
+
40
+ # create dummy rakefile to indicate success
41
+ f = File.open(File.join(File.dirname(__FILE__), "Rakefile"), "w")
42
+ f.write("task :default\n")
43
+ f.close
44
+
@@ -0,0 +1,20 @@
1
+ def load_debugger(gems_to_include, new_argv)
2
+ path_to_rdebug = File.expand_path(File.dirname(__FILE__)) + '/../../../bin/rdebug-ide'
3
+
4
+ old_argv = ARGV.clone
5
+ ARGV.clear
6
+ new_argv.each do |x|
7
+ ARGV << x
8
+ end
9
+
10
+ gems_to_include.each do |gem_path|
11
+ $LOAD_PATH.unshift(gem_path) unless $LOAD_PATH.include?(gem_path)
12
+ end
13
+
14
+ load path_to_rdebug
15
+
16
+ ARGV.clear
17
+ old_argv.each do |x|
18
+ ARGV << x
19
+ end
20
+ end
@@ -0,0 +1,73 @@
1
+ require 'ruby-debug-ide/attach/native_debugger'
2
+
3
+ class GDB < NativeDebugger
4
+
5
+ def initialize(executable, pid, flags, gems_to_include, debugger_loader_path, argv)
6
+ super(executable, pid, flags, gems_to_include, debugger_loader_path, argv)
7
+ end
8
+
9
+ def set_flags
10
+ execute 'set scheduler-locking off' # we will deadlock with it
11
+ execute 'set unwindonsignal on' # in case of some signal we will exit gdb
12
+ end
13
+
14
+ def update_threads
15
+ @process_threads = []
16
+ info_threads = (execute 'info threads').split("\n")
17
+ info_threads.each do |thread_info|
18
+ next unless thread_info =~ /[\s*]*\d+\s+Thread.*/
19
+ $stdout.puts "thread_info: #{thread_info}"
20
+ is_main = thread_info[0] == '*'
21
+ thread_num = thread_info.sub(/[\s*]*/, '').sub(/\s.*$/, '').to_i
22
+ thread = ProcessThread.new(thread_num, is_main, thread_info, self)
23
+ if thread.is_main
24
+ @main_thread = thread
25
+ end
26
+ @process_threads << thread
27
+ end
28
+ @process_threads
29
+ end
30
+
31
+ def check_already_under_debug
32
+ threads = execute 'info threads'
33
+ threads =~ /ruby-debug-ide/
34
+ end
35
+
36
+ def switch_to_thread(thread_num)
37
+ execute "thread #{thread_num}"
38
+ end
39
+
40
+ def set_break(str)
41
+ execute "tbreak #{str}"
42
+ end
43
+
44
+ def call_start_attach
45
+ super()
46
+ execute "call dlopen(\"#{@path_to_attach}\", 2)"
47
+ execute 'call debase_start_attach()'
48
+ set_break(@tbreak)
49
+ end
50
+
51
+ def print_delimiter
52
+ @pipe.puts "print \"#{@delimiter}\""
53
+ end
54
+
55
+ def check_delimiter(line)
56
+ line =~ /\$\d+\s=\s"#{@delimiter}"/
57
+ end
58
+
59
+ def load_debugger
60
+ execute "call #{@eval_string}"
61
+ end
62
+
63
+ def to_s
64
+ GDB.to_s
65
+ end
66
+
67
+ class << self
68
+ def to_s
69
+ 'gdb'
70
+ end
71
+ end
72
+
73
+ end
@@ -0,0 +1,71 @@
1
+ require 'ruby-debug-ide/attach/native_debugger'
2
+
3
+ class LLDB < NativeDebugger
4
+
5
+ def initialize(executable, pid, flags, gems_to_include, debugger_loader_path, argv)
6
+ super(executable, pid, flags, gems_to_include, debugger_loader_path, argv)
7
+ end
8
+
9
+ def set_flags
10
+
11
+ end
12
+
13
+ def update_threads
14
+ @process_threads = []
15
+ info_threads = (execute 'thread list').split("\n")
16
+ info_threads.each do |thread_info|
17
+ next unless thread_info =~ /[\s*]*thread\s#\d+.*/
18
+ is_main = thread_info[0] == '*'
19
+ thread_num = thread_info.sub(/[\s*]*thread\s#/, '').sub(/:\s.*$/, '').to_i
20
+ thread = ProcessThread.new(thread_num, is_main, thread_info, self)
21
+ if thread.is_main
22
+ @main_thread = thread
23
+ end
24
+ @process_threads << thread
25
+ end
26
+ @process_threads
27
+ end
28
+
29
+ def check_already_under_debug
30
+ threads = execute 'thread list'
31
+ threads =~ /ruby-debug-ide/
32
+ end
33
+
34
+ def switch_to_thread(thread_num)
35
+ execute "thread select #{thread_num}"
36
+ end
37
+
38
+ def set_break(str)
39
+ execute "breakpoint set --shlib #{@path_to_attach} --name #{str}"
40
+ end
41
+
42
+ def call_start_attach
43
+ super()
44
+ execute "expr (void *) dlopen(\"#{@path_to_attach}\", 2)"
45
+ execute 'expr (int) debase_start_attach()'
46
+ set_break(@tbreak)
47
+ end
48
+
49
+ def print_delimiter
50
+ @pipe.puts "script print \"#{@delimiter}\""
51
+ end
52
+
53
+ def check_delimiter(line)
54
+ line =~ /#{@delimiter}$/
55
+ end
56
+
57
+ def load_debugger
58
+ execute "expr (void) #{@eval_string}"
59
+ end
60
+
61
+ def to_s
62
+ LLDB.to_s
63
+ end
64
+
65
+ class << self
66
+ def to_s
67
+ 'lldb'
68
+ end
69
+ end
70
+
71
+ end