Module: Debugger::MultiProcess
- Defined in:
- lib/ruby-debug-ide/multiprocess.rb,
lib/ruby-debug-ide/multiprocess/monkey.rb,
lib/ruby-debug-ide/multiprocess/unmonkey.rb,
lib/ruby-debug-ide/multiprocess/pre_child.rb
Class Method Summary collapse
- .create_mp_exec(private = false) ⇒ Object
- .create_mp_fork(private = false) ⇒ Object
- .do_monkey ⇒ Object
- .pre_child(options = nil) ⇒ Object
- .restore_exec ⇒ Object
- .restore_fork ⇒ Object
- .start_debugger(options) ⇒ Object
- .undo_monkey ⇒ Object
Class Method Details
.create_mp_exec(private = false) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/ruby-debug-ide/multiprocess/monkey.rb', line 19 def self.create_mp_exec(private=false) %Q{ alias pre_debugger_exec exec #{private ? "private" : ""} def exec(*args) Debugger.interface.close pre_debugger_exec(*args) end } end |
.create_mp_fork(private = false) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/ruby-debug-ide/multiprocess/monkey.rb', line 3 def self.create_mp_fork(private=false) %Q{ alias pre_debugger_fork fork #{private ? "private" : ""} def fork(*args) if block_given? return pre_debugger_fork{Debugger::MultiProcess::pre_child; yield} end result = pre_debugger_fork Debugger::MultiProcess::pre_child unless result result end } end |
.do_monkey ⇒ Object
10 11 12 |
# File 'lib/ruby-debug-ide/multiprocess.rb', line 10 def do_monkey load File.(File.dirname(__FILE__) + '/multiprocess/monkey.rb') end |
.pre_child(options = nil) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/ruby-debug-ide/multiprocess/pre_child.rb', line 4 def pre_child( = nil) require 'socket' require 'ostruct' host = ENV['DEBUGGER_HOST'] ||= OpenStruct.new( 'frame_bind' => false, 'host' => host, 'load_mode' => false, 'port' => Debugger.find_free_port(host), 'stop' => false, 'tracing' => false, 'int_handler' => true, 'cli_debug' => (ENV['DEBUGGER_CLI_DEBUG'] == 'true'), 'notify_dispatcher' => true, 'evaluation_timeout' => 10, 'trace_to_s' => false, 'debugger_memory_limit' => 10, 'inspect_time_limit' => 100 ) if(.ignore_port) .port = Debugger.find_free_port(.host) .notify_dispatcher = true end start_debugger() end |
.restore_exec ⇒ Object
9 10 11 12 13 |
# File 'lib/ruby-debug-ide/multiprocess/unmonkey.rb', line 9 def self.restore_exec %Q{ alias exec pre_debugger_exec } end |
.restore_fork ⇒ Object
3 4 5 6 7 |
# File 'lib/ruby-debug-ide/multiprocess/unmonkey.rb', line 3 def self.restore_fork %Q{ alias fork pre_debugger_fork } end |
.start_debugger(options) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/ruby-debug-ide/multiprocess/pre_child.rb', line 34 def start_debugger() if Debugger.started? # we're in forked child, only need to restart control thread Debugger.breakpoints.clear Debugger.control_thread = nil Debugger.start_control(.host, .port, .notify_dispatcher) end if .int_handler # install interruption handler trap('INT') { Debugger.interrupt_last } end # set options Debugger.keep_frame_binding = .frame_bind Debugger.tracing = .tracing Debugger.evaluation_timeout = .evaluation_timeout Debugger.trace_to_s = .trace_to_s Debugger.debugger_memory_limit = .debugger_memory_limit Debugger.inspect_time_limit = .inspect_time_limit Debugger.cli_debug = .cli_debug Debugger.prepare_debugger() end |
.undo_monkey ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/ruby-debug-ide/multiprocess.rb', line 14 def undo_monkey if ENV['IDE_PROCESS_DISPATCHER'] load File.(File.dirname(__FILE__) + '/multiprocess/unmonkey.rb') ruby_opts = ENV['RUBYOPT'].split(' ') ENV['RUBYOPT'] = ruby_opts.keep_if {|opt| !opt.end_with?('ruby-debug-ide/multiprocess/starter')}.join(' ') end end |