bin/rdebug-ide in debugger-xml-0.2.0 vs bin/rdebug-ide in debugger-xml-0.3.1

- old
+ new

@@ -12,21 +12,22 @@ def initialize check_argv! Debugger.const_set("ARGV", ARGV.clone) Debugger.const_set("RDEBUG_SCRIPT", rdebug_path) - install_interruption_hander if options.int_handler + install_interruption_handler if options.int_handler Debugger.tracing = options.tracing Debugger.wait_for_start = options.wait_for_start Debugger.wait_connection = true Debugger.printer = Printers::Xml.new Debugger.const_set("PROG_SCRIPT", ARGV.shift) Debugger::Xml.logger = if options.debug_mode Debugger::Xml::Ide::Logger.new else Debugger::Xml::FakeLogger.new end + init_multi_process_debug(options) if options.dispatcher_port end def run Debugger.start_remote_ide(options.host, options.port) bt = Debugger.debug_load(Debugger::PROG_SCRIPT, false, false) @@ -36,20 +37,30 @@ end end private - def check_argv! + def init_multi_process_debug(options) + ENV['IDE_PROCESS_DISPATCHER'] = options.dispatcher_port.to_s + ENV['DEBUGGER_HOST'] = options.host.to_s + ENV['DEBUGGER_DEBUG_MODE'] = options.debug_mode.to_s + ENV['DEBUGGER_STORED_RUBYLIB'] = $LOAD_PATH.join(File::PATH_SEPARATOR) + old_opts = ENV['RUBYOPT'] + ENV['RUBYOPT'] = "-r#{File.expand_path(File.dirname(__FILE__))}/../lib/debugger/xml/multiprocess/starter" + ENV['RUBYOPT'] += " #{old_opts}" if old_opts + end + + def check_argv! if ARGV.empty? puts opts puts puts "Must specify a script to run" exit(1) end end - def install_interruption_hander + def install_interruption_handler trap('INT') { Debugger.interrupt_last } end def rdebug_path File.expand_path($0).tap do |path| @@ -66,23 +77,25 @@ def opts @opts ||= begin @options = OpenStruct.new( host: "127.0.0.1", port: 12345, stop: false, tracing: false, wait_for_start: true, - int_handler: true, debug_mode: false + int_handler: true, debug_mode: false, dispatcher_port: nil ) opts = OptionParser.new do |opts| opts.banner = %{ Using rdebug-ide Usage: rdebug-ide is supposed to be called from RDT, NetBeans, RubyMine or vim-ruby-debugger. The command line interface to 'debugger' is rdebug. }.gsub(/^\s*/, '') opts.separator "" opts.separator "Options:" opts.on("-h", "--host HOST", "Host name used for remote debugging") { |host| @options.host = host } - opts.on("-d", "--debug", "Enable debug mode") { |host| @options.debug_mode = true } - opts.on("--cport PORT", Integer, "Port used for control commands") { |cport| @options.cport = cport } opts.on("-p", "--port PORT", Integer, "Port used for remote debugging") { |port| @options.port = port } + opts.on('--dispatcher-port PORT', Integer, 'Port used for multi-process debugging dispatcher') do |dp| + @options.dispatcher_port = dp + end + opts.on("-d", "--debug", "Enable debug mode") { |host| @options.debug_mode = true } opts.on("--wait", String, "Wait for 'start' command") do |bool| @options.wait_for_start = (bool == "false" ? false : true) end opts.on('--stop', 'stop when the script is loaded') { @options.stop = true } opts.on("-x", "--trace", "turn on line tracing") { @options.tracing = true }