18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
# File 'lib/spork/test_framework/rdebug_ide_test_unit.rb', line 18
def setup_rdebug(argv)
if argv.grep(/rdebug-ide/).size > 0
while argv.shift !~ /rdebug-ide/; end
options = OpenStruct.new(
'frame_bind' => false,
'host' => nil,
'load_mode' => false,
'port' => 1234,
'stop' => false,
'tracing' => false
)
opts = OptionParser.new do |opts|
opts.banner = <<-EOB
Using ruby-debug-base #{Debugger::VERSION}
Usage: rdebug-ide is supposed to be called from RDT, NetBeans or RubyMine. The
command line interface to ruby-debug is rdebug.
EOB
opts.separator ""
opts.separator "Options:"
opts.on("-h", "--host HOST", "Host name used for remote debugging") {|host| options.host = host}
opts.on("-p", "--port PORT", Integer, "Port used for remote debugging") {|port| options.port = port}
opts.on('--stop', 'stop when the script is loaded') {options.stop = true}
opts.on("-x", "--trace", "turn on line tracing") {options.tracing = true}
opts.on("-l", "--load-mode", "load mode (experimental)") {options.load_mode = true}
opts.on("-d", "--debug", "Debug self - prints information for debugging ruby-debug itself") do
Debugger.cli_debug = true
end
opts.on("--xml-debug", "Debug self - sends information <message>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
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
trap('INT') { Debugger.interrupt_last }
Debugger.keep_frame_binding = options.frame_bind
Debugger.tracing = options.tracing
Debugger.start_server(options.host, options.port)
Debugger.start do
yield
end
else
yield
end
end
|