#!/usr/bin/env ruby require 'rubygems' require 'optparse' require "ostruct" require 'ruby-debug' $stdout.sync=true options = OpenStruct.new( 'frame_bind' => false, 'host' => nil, 'load_mode' => false, 'port' => 1234, 'stop' => false, 'tracing' => false ) opts = OptionParser.new do |opts| opts.banner = <s for debugging ruby-debug itself") do Debugger.xml_debug = true end opts.on("-I", "--include PATH", String, "Add PATH to $LOAD_PATH") do |path| $LOAD_PATH.unshift(path) end opts.on("--keep-frame-binding", "Keep frame bindings") {options.frame_bind = true} opts.separator "" opts.separator "Common options:" opts.on_tail("-v", "--version", "Show version") do puts "Using ruby-debug-base #{Debugger::VERSION}" exit end end begin Debugger::ARGV = ARGV.clone rdebug_path = File.expand_path($0) if RUBY_PLATFORM =~ /mswin/ rdebug_path += ".cmd" unless rdebug_path =~ /\.cmd$/i end Debugger::RDEBUG_SCRIPT = rdebug_path opts.parse! ARGV rescue StandardError => e puts opts puts puts e.message exit(1) end if ARGV.empty? puts opts puts puts "Must specify a script to run" exit(1) end # save script name Debugger::PROG_SCRIPT = ARGV.shift # install interruption handler trap('INT') { Debugger.interrupt_last } # set options Debugger.keep_frame_binding = options.frame_bind Debugger.tracing = options.tracing Debugger.debug_program(options)