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
@@ -0,0 +1,228 @@
1
+ require 'pp'
2
+ require 'stringio'
3
+ require "socket"
4
+ require 'thread'
5
+ if RUBY_VERSION < '2.0' || defined?(JRUBY_VERSION)
6
+ require 'ruby-debug-base'
7
+ Debugger::FRONT_END = "ruby-debug-base"
8
+ else
9
+ require 'debase'
10
+ Debugger::FRONT_END = "debase"
11
+ end
12
+
13
+ require 'ruby-debug-ide/greeter'
14
+ require 'ruby-debug-ide/xml_printer'
15
+ require 'ruby-debug-ide/ide_processor'
16
+ require 'ruby-debug-ide/event_processor'
17
+
18
+ module Debugger
19
+
20
+ class << self
21
+ def find_free_port(host)
22
+ server = TCPServer.open(host, 0)
23
+ port = server.addr[1]
24
+ server.close
25
+ port
26
+ end
27
+
28
+ # Prints to the stderr using printf(*args) if debug logging flag (-d) is on.
29
+ def print_debug(*args)
30
+ if Debugger.cli_debug
31
+ $stderr.printf("#{Process.pid}: ")
32
+ $stderr.printf(*args)
33
+ $stderr.printf("\n")
34
+ $stderr.flush
35
+ end
36
+ end
37
+
38
+ def cleanup_backtrace(backtrace)
39
+ cleared = []
40
+ return cleared unless backtrace
41
+ backtrace.each do |line|
42
+ if line.index(File.expand_path(File.dirname(__FILE__) + "/..")) == 0
43
+ next
44
+ end
45
+ if line.index("-e:1") == 0
46
+ break
47
+ end
48
+ cleared << line
49
+ end
50
+ cleared
51
+ end
52
+
53
+ attr_accessor :attached
54
+ attr_accessor :key_value_mode
55
+ attr_accessor :cli_debug, :xml_debug, :evaluation_timeout
56
+ attr_accessor :trace_to_s, :debugger_memory_limit, :inspect_time_limit
57
+ attr_accessor :control_thread
58
+ attr_reader :interface
59
+ # protocol extensions
60
+ attr_accessor :catchpoint_deleted_event, :value_as_nested_element
61
+
62
+
63
+ #
64
+ # Interrupts the last debugged thread
65
+ #
66
+ def interrupt_last
67
+ skip do
68
+ if context = last_context
69
+ return nil unless context.thread.alive?
70
+ context.interrupt
71
+ end
72
+ context
73
+ end
74
+ end
75
+
76
+ def start_server(host = nil, port = 1234, notify_dispatcher = false)
77
+ _start_server_common(host, port, nil, notify_dispatcher)
78
+ end
79
+
80
+ def start_server_unix(socket_path, notify_dispatcher = false)
81
+ _start_server_common(nil, 0, socket_path, notify_dispatcher)
82
+ end
83
+
84
+ def prepare_debugger(options)
85
+ @mutex = Mutex.new
86
+ @proceed = ConditionVariable.new
87
+
88
+ if options.socket_path.nil?
89
+ start_server(options.host, options.port, options.notify_dispatcher)
90
+ else
91
+ start_server_unix(options.socket_path, options.notify_dispatcher)
92
+ end
93
+
94
+ raise "Control thread did not start (#{@control_thread}}" unless @control_thread && @control_thread.alive?
95
+
96
+ # wait for 'start' command
97
+ @mutex.synchronize do
98
+ @proceed.wait(@mutex)
99
+ end unless options.skip_wait_for_start
100
+ end
101
+
102
+ def debug_program(options)
103
+ prepare_debugger(options)
104
+
105
+ abs_prog_script = File.expand_path(Debugger::PROG_SCRIPT)
106
+ bt = debug_load(abs_prog_script, options.stop, options.load_mode)
107
+ if bt && !bt.is_a?(SystemExit)
108
+ $stderr.print "Uncaught exception: #{bt}\n"
109
+ $stderr.print Debugger.cleanup_backtrace(bt.backtrace).map{|l| "\t#{l}"}.join("\n"), "\n"
110
+ end
111
+ end
112
+
113
+ def run_prog_script
114
+ return unless @mutex
115
+ @mutex.synchronize do
116
+ @proceed.signal
117
+ end
118
+ end
119
+
120
+ def start_control(host, port, notify_dispatcher)
121
+ _start_control_common(host, port, nil, notify_dispatcher)
122
+ end
123
+
124
+ def start_control_unix(socket_path, notify_dispatcher)
125
+ _start_control_common(nil, 0, socket_path, notify_dispatcher)
126
+ end
127
+
128
+ private
129
+
130
+ def _start_server_common(host, port, socket_path, notify_dispatcher)
131
+ return if started?
132
+ start
133
+ _start_control_common(host, port, socket_path, notify_dispatcher)
134
+ end
135
+
136
+ def _start_control_common(host, port, socket_path, notify_dispatcher)
137
+ raise "Debugger is not started" unless started?
138
+ return if @control_thread
139
+ @control_thread = DebugThread.new do
140
+ begin
141
+ if socket_path.nil?
142
+ # 127.0.0.1 seemingly works with all systems and with IPv6 as well.
143
+ # "localhost" and nil have problems on some systems.
144
+ host ||= '127.0.0.1'
145
+
146
+ server = notify_dispatcher_if_needed(host, port, notify_dispatcher) do |real_port, port_changed|
147
+ s = TCPServer.new(host, real_port)
148
+ print_greeting_msg $stderr, host, real_port, port_changed ? "Subprocess" : "Fast" if defined? IDE_VERSION
149
+ s
150
+ end
151
+ else
152
+ raise "Cannot specify host and socket_file at the same time" if host
153
+ File.delete(socket_path) if File.exist?(socket_path)
154
+ server = UNIXServer.new(socket_path)
155
+ print_greeting_msg $stderr, nil, nil, "Fast", socket_path if defined? IDE_VERSION
156
+ end
157
+
158
+ return unless server
159
+
160
+ while (session = server.accept)
161
+ if Debugger.cli_debug
162
+ if session.peeraddr == 'AF_INET'
163
+ $stderr.puts "Connected from #{session.peeraddr[2]}"
164
+ else
165
+ $stderr.puts "Connected from local client"
166
+ end
167
+ end
168
+ dispatcher = ENV['IDE_PROCESS_DISPATCHER']
169
+ if dispatcher
170
+ ENV['IDE_PROCESS_DISPATCHER'] = "#{session.peeraddr[2]}:#{dispatcher}" unless dispatcher.include?(":")
171
+ ENV['DEBUGGER_HOST'] = host
172
+ end
173
+ begin
174
+ @interface = RemoteInterface.new(session)
175
+ self.handler = EventProcessor.new(interface)
176
+ IdeControlCommandProcessor.new(interface).process_commands
177
+ rescue StandardError, ScriptError => ex
178
+ bt = ex.backtrace
179
+ $stderr.printf "#{Process.pid}: Exception in DebugThread loop: #{ex.message}(#{ex.class})\nBacktrace:\n#{bt ? bt.join("\n from: ") : "<none>"}\n"
180
+ exit 1
181
+ end
182
+ end
183
+ rescue
184
+ bt = $!.backtrace
185
+ $stderr.printf "Fatal exception in DebugThread loop: #{$!.message}\nBacktrace:\n#{bt ? bt.join("\n from: ") : "<none>"}\n"
186
+ exit 2
187
+ end
188
+ end
189
+ end
190
+
191
+ def notify_dispatcher_if_needed(host, port, need_notify)
192
+ return yield port unless need_notify
193
+
194
+ return unless ENV['IDE_PROCESS_DISPATCHER']
195
+ acceptor_host, acceptor_port = ENV['IDE_PROCESS_DISPATCHER'].split(":")
196
+ acceptor_host, acceptor_port = '127.0.0.1', acceptor_host unless acceptor_port
197
+ connected = false
198
+
199
+ 3.times do |i|
200
+ begin
201
+ s = TCPSocket.open(acceptor_host, acceptor_port)
202
+ dispatcher_answer = s.gets.chomp
203
+
204
+ if dispatcher_answer == "true"
205
+ port = Debugger.find_free_port(host)
206
+ end
207
+
208
+ server = yield port, dispatcher_answer == "true"
209
+
210
+ s.print(port)
211
+ s.close
212
+ connected = true
213
+ print_debug "Ide process dispatcher notified about sub-debugger which listens on #{port}\n"
214
+ return server
215
+ rescue => bt
216
+ $stderr.puts "#{Process.pid}: connection failed(#{i+1})"
217
+ $stderr.puts "Exception: #{bt}"
218
+ $stderr.puts bt.backtrace.map { |l| "\t#{l}" }.join("\n")
219
+ sleep 0.3
220
+ end unless connected
221
+ end
222
+ end
223
+ end
224
+
225
+ class Exception # :nodoc:
226
+ attr_reader :__debug_file, :__debug_line, :__debug_binding, :__debug_context
227
+ end
228
+ end
@@ -0,0 +1,47 @@
1
+ require File.dirname(__FILE__) + '/lib/ruby-debug-ide/version'
2
+ require "date"
3
+
4
+ # ------- Default Package ----------
5
+ RUBY_DEBUG_IDE_VERSION = Debugger::IDE_VERSION unless defined? RUBY_DEBUG_IDE_VERSION
6
+
7
+ unless defined? FILES
8
+ FILES = ['CHANGES',
9
+ 'ChangeLog.md',
10
+ 'ChangeLog.archive',
11
+ 'MIT-LICENSE',
12
+ 'Rakefile',
13
+ 'ext/mkrf_conf.rb',
14
+ 'Gemfile',
15
+ 'ruby-debug-ide.gemspec'
16
+ ]
17
+ FILES.push(*Dir['bin/*'])
18
+ FILES.push(*Dir['lib/**/*'])
19
+ # 'test/**/*',
20
+ end
21
+
22
+ Gem::Specification.new do |spec|
23
+ spec.name = "ruby-debug-ide22"
24
+
25
+ spec.homepage = "https://github.com/ruby-debug/ruby-debug-ide"
26
+ spec.summary = "IDE interface for ruby-debug."
27
+ spec.description = <<-EOF
28
+ An interface which glues ruby-debug to IDEs like Eclipse (RDT), NetBeans and RubyMine.
29
+ EOF
30
+
31
+ spec.version = RUBY_DEBUG_IDE_VERSION
32
+
33
+ spec.author = "Vilmos Agoston"
34
+ spec.email = "agoston.vilmos@gmail.com"
35
+ spec.license = "MIT"
36
+ spec.platform = Gem::Platform::RUBY
37
+ spec.require_path = "lib"
38
+ spec.bindir = "bin"
39
+ spec.executables = ["rdebug-ide", "gdb_wrapper"]
40
+ spec.files = FILES
41
+
42
+ spec.extensions << "ext/mkrf_conf.rb" unless ENV['NO_EXT']
43
+ spec.add_dependency("rake", ">= 0.8.1")
44
+
45
+ spec.required_ruby_version = '>= 1.8.2'
46
+ spec.date = DateTime.now
47
+ end
metadata ADDED
@@ -0,0 +1,110 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruby-debug-ide22
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.7.4
5
+ platform: ruby
6
+ authors:
7
+ - Vilmos Agoston
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-06-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 0.8.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 0.8.1
27
+ description: 'An interface which glues ruby-debug to IDEs like Eclipse (RDT), NetBeans
28
+ and RubyMine.
29
+
30
+ '
31
+ email: agoston.vilmos@gmail.com
32
+ executables:
33
+ - rdebug-ide
34
+ - gdb_wrapper
35
+ extensions:
36
+ - ext/mkrf_conf.rb
37
+ extra_rdoc_files: []
38
+ files:
39
+ - CHANGES
40
+ - ChangeLog.archive
41
+ - ChangeLog.md
42
+ - Gemfile
43
+ - MIT-LICENSE
44
+ - Rakefile
45
+ - bin/gdb_wrapper
46
+ - bin/rdebug-ide
47
+ - ext/mkrf_conf.rb
48
+ - lib/ruby-debug-ide.rb
49
+ - lib/ruby-debug-ide/attach/debugger_loader.rb
50
+ - lib/ruby-debug-ide/attach/gdb.rb
51
+ - lib/ruby-debug-ide/attach/lldb.rb
52
+ - lib/ruby-debug-ide/attach/native_debugger.rb
53
+ - lib/ruby-debug-ide/attach/process_thread.rb
54
+ - lib/ruby-debug-ide/attach/util.rb
55
+ - lib/ruby-debug-ide/command.rb
56
+ - lib/ruby-debug-ide/commands/breakpoints.rb
57
+ - lib/ruby-debug-ide/commands/catchpoint.rb
58
+ - lib/ruby-debug-ide/commands/condition.rb
59
+ - lib/ruby-debug-ide/commands/control.rb
60
+ - lib/ruby-debug-ide/commands/enable.rb
61
+ - lib/ruby-debug-ide/commands/eval.rb
62
+ - lib/ruby-debug-ide/commands/expression_info.rb
63
+ - lib/ruby-debug-ide/commands/file_filtering.rb
64
+ - lib/ruby-debug-ide/commands/frame.rb
65
+ - lib/ruby-debug-ide/commands/inspect.rb
66
+ - lib/ruby-debug-ide/commands/jump.rb
67
+ - lib/ruby-debug-ide/commands/load.rb
68
+ - lib/ruby-debug-ide/commands/pause.rb
69
+ - lib/ruby-debug-ide/commands/set_type.rb
70
+ - lib/ruby-debug-ide/commands/stepping.rb
71
+ - lib/ruby-debug-ide/commands/threads.rb
72
+ - lib/ruby-debug-ide/commands/variables.rb
73
+ - lib/ruby-debug-ide/event_processor.rb
74
+ - lib/ruby-debug-ide/greeter.rb
75
+ - lib/ruby-debug-ide/helper.rb
76
+ - lib/ruby-debug-ide/ide_processor.rb
77
+ - lib/ruby-debug-ide/interface.rb
78
+ - lib/ruby-debug-ide/multiprocess.rb
79
+ - lib/ruby-debug-ide/multiprocess/monkey.rb
80
+ - lib/ruby-debug-ide/multiprocess/pre_child.rb
81
+ - lib/ruby-debug-ide/multiprocess/starter.rb
82
+ - lib/ruby-debug-ide/multiprocess/unmonkey.rb
83
+ - lib/ruby-debug-ide/thread_alias.rb
84
+ - lib/ruby-debug-ide/version.rb
85
+ - lib/ruby-debug-ide/xml_printer.rb
86
+ - ruby-debug-ide.gemspec
87
+ homepage: https://github.com/ruby-debug/ruby-debug-ide
88
+ licenses:
89
+ - MIT
90
+ metadata: {}
91
+ post_install_message:
92
+ rdoc_options: []
93
+ require_paths:
94
+ - lib
95
+ required_ruby_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: 1.8.2
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ requirements: []
106
+ rubygems_version: 3.1.6
107
+ signing_key:
108
+ specification_version: 4
109
+ summary: IDE interface for ruby-debug.
110
+ test_files: []