ruby-debug-ide22 0.7.4 → 0.7.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGES +75 -75
- data/ChangeLog.archive +1073 -1073
- data/ChangeLog.md +594 -594
- data/Gemfile +38 -38
- data/MIT-LICENSE +24 -24
- data/Rakefile +92 -92
- data/bin/gdb_wrapper +96 -96
- data/bin/rdebug-ide +200 -200
- data/ext/mkrf_conf.rb +44 -44
- data/lib/ruby-debug-ide/attach/debugger_loader.rb +20 -20
- data/lib/ruby-debug-ide/attach/gdb.rb +73 -73
- data/lib/ruby-debug-ide/attach/lldb.rb +71 -71
- data/lib/ruby-debug-ide/attach/native_debugger.rb +133 -133
- data/lib/ruby-debug-ide/attach/process_thread.rb +54 -54
- data/lib/ruby-debug-ide/attach/util.rb +114 -114
- data/lib/ruby-debug-ide/command.rb +187 -187
- data/lib/ruby-debug-ide/commands/breakpoints.rb +128 -128
- data/lib/ruby-debug-ide/commands/catchpoint.rb +64 -64
- data/lib/ruby-debug-ide/commands/condition.rb +51 -51
- data/lib/ruby-debug-ide/commands/control.rb +164 -158
- data/lib/ruby-debug-ide/commands/enable.rb +203 -203
- data/lib/ruby-debug-ide/commands/eval.rb +64 -64
- data/lib/ruby-debug-ide/commands/expression_info.rb +71 -71
- data/lib/ruby-debug-ide/commands/file_filtering.rb +106 -106
- data/lib/ruby-debug-ide/commands/frame.rb +155 -155
- data/lib/ruby-debug-ide/commands/inspect.rb +25 -25
- data/lib/ruby-debug-ide/commands/load.rb +17 -17
- data/lib/ruby-debug-ide/commands/stepping.rb +108 -108
- data/lib/ruby-debug-ide/commands/threads.rb +178 -178
- data/lib/ruby-debug-ide/commands/variables.rb +154 -154
- data/lib/ruby-debug-ide/event_processor.rb +71 -71
- data/lib/ruby-debug-ide/greeter.rb +42 -42
- data/lib/ruby-debug-ide/helper.rb +33 -33
- data/lib/ruby-debug-ide/ide_processor.rb +155 -155
- data/lib/ruby-debug-ide/interface.rb +47 -45
- data/lib/ruby-debug-ide/multiprocess/monkey.rb +46 -46
- data/lib/ruby-debug-ide/multiprocess/pre_child.rb +58 -58
- data/lib/ruby-debug-ide/multiprocess/starter.rb +10 -10
- data/lib/ruby-debug-ide/multiprocess/unmonkey.rb +30 -30
- data/lib/ruby-debug-ide/multiprocess.rb +22 -22
- data/lib/ruby-debug-ide/thread_alias.rb +26 -26
- data/lib/ruby-debug-ide/version.rb +3 -3
- data/lib/ruby-debug-ide/xml_printer.rb +570 -570
- data/lib/ruby-debug-ide.rb +230 -228
- data/ruby-debug-ide.gemspec +47 -47
- metadata +4 -4
data/Gemfile
CHANGED
@@ -1,38 +1,38 @@
|
|
1
|
-
source "http://rubygems.org"
|
2
|
-
|
3
|
-
# @param [Array<String>] versions compatible ruby versions
|
4
|
-
# @return [Array<String>] an array with mri platforms of given versions
|
5
|
-
def mries(*versions)
|
6
|
-
versions.map do |v|
|
7
|
-
%w(ruby mingw x64_mingw).map do |platform|
|
8
|
-
"#{platform}_#{v}".to_sym unless platform == "x64_mingw" && v < "2.0"
|
9
|
-
end.delete_if &:nil?
|
10
|
-
end.flatten
|
11
|
-
end
|
12
|
-
|
13
|
-
if RUBY_VERSION < '1.9' || defined?(JRUBY_VERSION)
|
14
|
-
gem "ruby-debug-base", :platforms => [:jruby, *mries('18')]
|
15
|
-
end
|
16
|
-
|
17
|
-
if RUBY_VERSION && RUBY_VERSION >= "1.9"
|
18
|
-
gem "ruby-debug-base19x", ">= 0.11.32", :platforms => mries('19')
|
19
|
-
end
|
20
|
-
|
21
|
-
if RUBY_VERSION && RUBY_VERSION >= "2.0"
|
22
|
-
gem "debase", "~> 0.2", ">= 0.2.2", :platforms => mries('20', '21', '22', '23', '24', '25')
|
23
|
-
end
|
24
|
-
|
25
|
-
gemspec
|
26
|
-
|
27
|
-
group :development do
|
28
|
-
gem "bundler"
|
29
|
-
end
|
30
|
-
|
31
|
-
group :test do
|
32
|
-
if RUBY_VERSION < "1.9"
|
33
|
-
gem "test-unit", "~> 2.1.2"
|
34
|
-
else
|
35
|
-
gem "test-unit"
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
# @param [Array<String>] versions compatible ruby versions
|
4
|
+
# @return [Array<String>] an array with mri platforms of given versions
|
5
|
+
def mries(*versions)
|
6
|
+
versions.map do |v|
|
7
|
+
%w(ruby mingw x64_mingw).map do |platform|
|
8
|
+
"#{platform}_#{v}".to_sym unless platform == "x64_mingw" && v < "2.0"
|
9
|
+
end.delete_if &:nil?
|
10
|
+
end.flatten
|
11
|
+
end
|
12
|
+
|
13
|
+
if RUBY_VERSION < '1.9' || defined?(JRUBY_VERSION)
|
14
|
+
gem "ruby-debug-base", :platforms => [:jruby, *mries('18')]
|
15
|
+
end
|
16
|
+
|
17
|
+
if RUBY_VERSION && RUBY_VERSION >= "1.9"
|
18
|
+
gem "ruby-debug-base19x", ">= 0.11.32", :platforms => mries('19')
|
19
|
+
end
|
20
|
+
|
21
|
+
if RUBY_VERSION && RUBY_VERSION >= "2.0"
|
22
|
+
gem "debase", "~> 0.2", ">= 0.2.2", :platforms => mries('20', '21', '22', '23', '24', '25')
|
23
|
+
end
|
24
|
+
|
25
|
+
gemspec
|
26
|
+
|
27
|
+
group :development do
|
28
|
+
gem "bundler"
|
29
|
+
end
|
30
|
+
|
31
|
+
group :test do
|
32
|
+
if RUBY_VERSION < "1.9"
|
33
|
+
gem "test-unit", "~> 2.1.2"
|
34
|
+
else
|
35
|
+
gem "test-unit"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
data/MIT-LICENSE
CHANGED
@@ -1,24 +1,24 @@
|
|
1
|
-
The file lib/classic-debug.rb is based on the debug.rb file from Ruby
|
2
|
-
project.
|
3
|
-
|
4
|
-
Copyright (c) 2007-2008, debug-commons team
|
5
|
-
|
6
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
7
|
-
a copy of this software and associated documentation files (the
|
8
|
-
"Software"), to deal in the Software without restriction, including
|
9
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
10
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
11
|
-
permit persons to whom the Software is furnished to do so, subject to
|
12
|
-
the following conditions:
|
13
|
-
|
14
|
-
The above copyright notice and this permission notice shall be
|
15
|
-
included in all copies or substantial portions of the Software.
|
16
|
-
|
17
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
18
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
19
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
20
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
21
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
22
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
23
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
24
|
-
|
1
|
+
The file lib/classic-debug.rb is based on the debug.rb file from Ruby
|
2
|
+
project.
|
3
|
+
|
4
|
+
Copyright (c) 2007-2008, debug-commons team
|
5
|
+
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
7
|
+
a copy of this software and associated documentation files (the
|
8
|
+
"Software"), to deal in the Software without restriction, including
|
9
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
10
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
11
|
+
permit persons to whom the Software is furnished to do so, subject to
|
12
|
+
the following conditions:
|
13
|
+
|
14
|
+
The above copyright notice and this permission notice shall be
|
15
|
+
included in all copies or substantial portions of the Software.
|
16
|
+
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
18
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
19
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
20
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
21
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
22
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
23
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
24
|
+
|
data/Rakefile
CHANGED
@@ -1,93 +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
|
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
93
|
end
|
data/bin/gdb_wrapper
CHANGED
@@ -1,96 +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
|
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
|