byebug 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +10 -0
- data/.travis.yml +8 -0
- data/AUTHORS +10 -0
- data/CHANGELOG.md +2 -0
- data/CONTRIBUTING.md +1 -0
- data/Gemfile +3 -0
- data/LICENSE +20 -0
- data/README.md +5 -0
- data/Rakefile +28 -0
- data/bin/byebug +395 -0
- data/byebug.gemspec +29 -0
- data/doc/hanoi.rb +35 -0
- data/doc/primes.rb +28 -0
- data/doc/rdebug-emacs.texi +1030 -0
- data/doc/test-tri2.rb +18 -0
- data/doc/tri3.rb +8 -0
- data/doc/triangle.rb +12 -0
- data/ext/byebug/breakpoint.c +476 -0
- data/ext/byebug/byebug.c +512 -0
- data/ext/byebug/byebug.h +131 -0
- data/ext/byebug/context.c +424 -0
- data/ext/byebug/extconf.rb +21 -0
- data/ext/byebug/locker.c +53 -0
- data/lib/byebug.rb +404 -0
- data/lib/byebug/command.rb +232 -0
- data/lib/byebug/commands/breakpoints.rb +153 -0
- data/lib/byebug/commands/catchpoint.rb +56 -0
- data/lib/byebug/commands/condition.rb +49 -0
- data/lib/byebug/commands/continue.rb +38 -0
- data/lib/byebug/commands/control.rb +110 -0
- data/lib/byebug/commands/display.rb +122 -0
- data/lib/byebug/commands/edit.rb +48 -0
- data/lib/byebug/commands/enable.rb +202 -0
- data/lib/byebug/commands/eval.rb +176 -0
- data/lib/byebug/commands/finish.rb +43 -0
- data/lib/byebug/commands/frame.rb +303 -0
- data/lib/byebug/commands/help.rb +56 -0
- data/lib/byebug/commands/info.rb +462 -0
- data/lib/byebug/commands/irb.rb +123 -0
- data/lib/byebug/commands/jump.rb +66 -0
- data/lib/byebug/commands/kill.rb +51 -0
- data/lib/byebug/commands/list.rb +94 -0
- data/lib/byebug/commands/method.rb +84 -0
- data/lib/byebug/commands/quit.rb +39 -0
- data/lib/byebug/commands/reload.rb +40 -0
- data/lib/byebug/commands/save.rb +90 -0
- data/lib/byebug/commands/set.rb +210 -0
- data/lib/byebug/commands/show.rb +246 -0
- data/lib/byebug/commands/skip.rb +35 -0
- data/lib/byebug/commands/source.rb +36 -0
- data/lib/byebug/commands/stepping.rb +83 -0
- data/lib/byebug/commands/threads.rb +189 -0
- data/lib/byebug/commands/tmate.rb +36 -0
- data/lib/byebug/commands/trace.rb +56 -0
- data/lib/byebug/commands/variables.rb +199 -0
- data/lib/byebug/context.rb +58 -0
- data/lib/byebug/helper.rb +69 -0
- data/lib/byebug/interface.rb +223 -0
- data/lib/byebug/processor.rb +468 -0
- data/lib/byebug/version.rb +3 -0
- data/man/rdebug.1 +241 -0
- data/test/breakpoints_test.rb +357 -0
- data/test/conditions_test.rb +77 -0
- data/test/continue_test.rb +44 -0
- data/test/display_test.rb +141 -0
- data/test/edit_test.rb +56 -0
- data/test/eval_test.rb +92 -0
- data/test/examples/breakpoint1.rb +15 -0
- data/test/examples/breakpoint2.rb +7 -0
- data/test/examples/conditions.rb +4 -0
- data/test/examples/continue.rb +4 -0
- data/test/examples/display.rb +5 -0
- data/test/examples/edit.rb +3 -0
- data/test/examples/edit2.rb +3 -0
- data/test/examples/eval.rb +4 -0
- data/test/examples/finish.rb +20 -0
- data/test/examples/frame.rb +20 -0
- data/test/examples/frame_threads.rb +31 -0
- data/test/examples/help.rb +2 -0
- data/test/examples/info.rb +38 -0
- data/test/examples/info2.rb +3 -0
- data/test/examples/info_threads.rb +48 -0
- data/test/examples/irb.rb +6 -0
- data/test/examples/jump.rb +14 -0
- data/test/examples/kill.rb +2 -0
- data/test/examples/list.rb +12 -0
- data/test/examples/method.rb +15 -0
- data/test/examples/post_mortem.rb +19 -0
- data/test/examples/quit.rb +2 -0
- data/test/examples/reload.rb +6 -0
- data/test/examples/restart.rb +6 -0
- data/test/examples/save.rb +3 -0
- data/test/examples/set.rb +3 -0
- data/test/examples/set_annotate.rb +12 -0
- data/test/examples/settings.rb +1 -0
- data/test/examples/show.rb +2 -0
- data/test/examples/source.rb +3 -0
- data/test/examples/stepping.rb +21 -0
- data/test/examples/thread.rb +32 -0
- data/test/examples/tmate.rb +10 -0
- data/test/examples/trace.rb +7 -0
- data/test/examples/trace_threads.rb +20 -0
- data/test/examples/variables.rb +26 -0
- data/test/finish_test.rb +48 -0
- data/test/frame_test.rb +143 -0
- data/test/help_test.rb +50 -0
- data/test/info_test.rb +313 -0
- data/test/irb_test.rb +81 -0
- data/test/jump_test.rb +70 -0
- data/test/kill_test.rb +48 -0
- data/test/list_test.rb +145 -0
- data/test/method_test.rb +70 -0
- data/test/post_mortem_test.rb +27 -0
- data/test/quit_test.rb +56 -0
- data/test/reload_test.rb +44 -0
- data/test/restart_test.rb +164 -0
- data/test/save_test.rb +92 -0
- data/test/set_test.rb +177 -0
- data/test/show_test.rb +293 -0
- data/test/source_test.rb +45 -0
- data/test/stepping_test.rb +130 -0
- data/test/support/breakpoint.rb +13 -0
- data/test/support/context.rb +14 -0
- data/test/support/matchers.rb +67 -0
- data/test/support/mocha_extensions.rb +72 -0
- data/test/support/processor.rb +7 -0
- data/test/support/test_dsl.rb +206 -0
- data/test/support/test_interface.rb +68 -0
- data/test/test_helper.rb +10 -0
- data/test/tmate_test.rb +44 -0
- data/test/trace_test.rb +159 -0
- data/test/variables_test.rb +119 -0
- metadata +265 -0
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/AUTHORS
ADDED
data/CHANGELOG.md
ADDED
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Thanks for trying out this project! [See here for contribution guidelines.](http://tagaholic.me/contributing.html)
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2013 David Rodríguez
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# -*- Ruby -*-
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rake/extensiontask'
|
4
|
+
require 'rubygems/package_task'
|
5
|
+
|
6
|
+
Rake::ExtensionTask.new('byebug')
|
7
|
+
|
8
|
+
SO_NAME = "byebug.so"
|
9
|
+
|
10
|
+
desc "Run MiniTest suite"
|
11
|
+
task :test do
|
12
|
+
Rake::TestTask.new(:test) do |t|
|
13
|
+
t.test_files = FileList["test/*_test.rb"]
|
14
|
+
t.verbose = true
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
desc "Test everything - same as test."
|
19
|
+
task :check => :test
|
20
|
+
|
21
|
+
base_spec = eval(File.read('byebug.gemspec'), binding, 'byebug.gemspec')
|
22
|
+
|
23
|
+
# Rake task to build the default package
|
24
|
+
Gem::PackageTask.new(base_spec) do |pkg|
|
25
|
+
pkg.need_tar = true
|
26
|
+
end
|
27
|
+
|
28
|
+
task :default => :test
|
data/bin/byebug
ADDED
@@ -0,0 +1,395 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
#=== Summary
|
4
|
+
#
|
5
|
+
#A command-line front-end to <tt>byebug</tt>
|
6
|
+
#
|
7
|
+
#Command invocation:
|
8
|
+
#
|
9
|
+
# byebug [options] [--] [script-options] ruby-script-to-debug
|
10
|
+
# byebug [options] [script-options] [--client]
|
11
|
+
# byebug [--version | --help]
|
12
|
+
#
|
13
|
+
#=== Options
|
14
|
+
#
|
15
|
+
#<tt>-A | --annotate</tt> <i>level</i>::
|
16
|
+
# Set gdb-style annotation to <i>level</i>, a number. Additional
|
17
|
+
# information is output automatically when program state is
|
18
|
+
# changed. This can be used by front-ends such as GNU Emacs to post
|
19
|
+
# this updated information without having to poll for it.
|
20
|
+
#
|
21
|
+
#<tt>--client</tt>::
|
22
|
+
# Connect to a remote byebug. Used with another rdebug invocation
|
23
|
+
# using <tt>--server</tt>. See also <tt>--host</tt> and
|
24
|
+
# <tt>--cport</tt> options
|
25
|
+
#
|
26
|
+
#<tt>--cport=</tt><i>port</i>::
|
27
|
+
# Use port <i>port</i> for access to byebug control.
|
28
|
+
#
|
29
|
+
#<tt>-d | --debug</tt>::
|
30
|
+
# Set $DEBUG true.
|
31
|
+
#
|
32
|
+
#<tt>--emacs</tt>::
|
33
|
+
# Activates full GNU Emacs mode. Is the equivalent of setting the
|
34
|
+
# options <tt>--emacs-basic --annotate=3 --no-stop --no-control
|
35
|
+
# --post-mortem</tt>.
|
36
|
+
#
|
37
|
+
#<tt>--emacs-basic</tt>::
|
38
|
+
# Activates GNU Emacs mode. Byebug prompts are prefaced with two
|
39
|
+
# octal 032 characters.
|
40
|
+
#
|
41
|
+
#<tt>-h | --host=</tt><i>host</i>::
|
42
|
+
# Use host name <i>host</i> for remote debugging.
|
43
|
+
#
|
44
|
+
#<tt>-I | --include</tt> <i>path</i>
|
45
|
+
# Add <i>path</i> to <tt>$LOAD_PATH</tt>
|
46
|
+
#
|
47
|
+
#<tt>-m | --post-mortem</tt>::
|
48
|
+
# Activate post-mortem mode.
|
49
|
+
#
|
50
|
+
#<tt>--no-control</tt>::
|
51
|
+
# Do not automatically start control thread.
|
52
|
+
#
|
53
|
+
#<tt>--no-stop</tt>::
|
54
|
+
# Do not stop when script is loaded.
|
55
|
+
#
|
56
|
+
#<tt>-p | --port=PORT</tt>::
|
57
|
+
# Host name used for remote debugging.
|
58
|
+
#
|
59
|
+
#<tt>-r | --require</tt><i>script</i>::
|
60
|
+
# Require the library, before executing your script.
|
61
|
+
#
|
62
|
+
#<tt>--script</tt> <i>file</i>::
|
63
|
+
# Run byebug script file <i>file</i>
|
64
|
+
#
|
65
|
+
#<tt>-x | --trace</tt>::
|
66
|
+
# Show lines before executing them.
|
67
|
+
#
|
68
|
+
#<tt>--no-quit</tt>::
|
69
|
+
# Do not quit when script terminates. Instead rerun the
|
70
|
+
# program.
|
71
|
+
#
|
72
|
+
#<tt>--version</tt>::
|
73
|
+
# Show the version number and exit.
|
74
|
+
#
|
75
|
+
#<tt>--verbose</tt>::
|
76
|
+
# Turn on verbose mode.
|
77
|
+
#
|
78
|
+
#<tt>--v</tt>::
|
79
|
+
# Print the version number, then turn on verbose mode if
|
80
|
+
# a script name is given. If no script name is given
|
81
|
+
# just exit after printing the version number.
|
82
|
+
#
|
83
|
+
#<tt>--nx</tt>::
|
84
|
+
# Don’t execute commands found in any initialization
|
85
|
+
# files, e.g. <tt>.rdebugrc</tt>.
|
86
|
+
#
|
87
|
+
#<tt>--keep-frame-binding</tt>::
|
88
|
+
# Keep frame bindings.
|
89
|
+
#
|
90
|
+
#<tt>--script=</tt><i>file</i>::
|
91
|
+
# Name of the script file to run
|
92
|
+
#
|
93
|
+
#<tt>-s | --server</tt>::
|
94
|
+
# Listen for remote connections. Another rdebug session
|
95
|
+
# accesses using the <tt>--client</tt> option. See also the
|
96
|
+
# <tt>--host</tt>, <tt>--port</tt> and <tt>--cport</tt> options
|
97
|
+
#
|
98
|
+
#<tt>-w | --wait</tt>::
|
99
|
+
# Wait for a client connection; implies <tt>-s</tt> option.
|
100
|
+
#
|
101
|
+
#<tt>--help</tt>::
|
102
|
+
# Show invocation help and exit.
|
103
|
+
|
104
|
+
require 'optparse'
|
105
|
+
require 'ostruct'
|
106
|
+
require File.dirname(__FILE__) + "/../lib/byebug"
|
107
|
+
|
108
|
+
def debug_program(options)
|
109
|
+
# Make sure Ruby script syntax checks okay.
|
110
|
+
# Otherwise we get a load message that looks like rdebug has a problem.
|
111
|
+
output = `ruby -c "#{Byebug::PROG_SCRIPT}" 2>&1`
|
112
|
+
if $?.exitstatus != 0 and RUBY_PLATFORM !~ /mswin/
|
113
|
+
puts output
|
114
|
+
exit $?.exitstatus
|
115
|
+
end
|
116
|
+
print "\032\032starting\n" if Byebug.annotate and Byebug.annotate > 2
|
117
|
+
|
118
|
+
# Record where we are we can know if the call stack has been truncated or not.
|
119
|
+
Byebug.start_sentinal=caller(0)[1]
|
120
|
+
|
121
|
+
bt = Byebug.debug_load(Byebug::PROG_SCRIPT, options.stop)
|
122
|
+
if bt
|
123
|
+
print bt.backtrace.map{|l| "\t#{l}"}.join("\n"), "\n"
|
124
|
+
print "Uncaught exception: #{bt}\n"
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
# Do a shell-like path lookup for prog_script and return the results.
|
129
|
+
# If we can't find anything return prog_script.
|
130
|
+
def whence_file(prog_script)
|
131
|
+
if prog_script.index(File::SEPARATOR)
|
132
|
+
# Don't search since this name has path separator components
|
133
|
+
return prog_script
|
134
|
+
end
|
135
|
+
for dirname in ENV['PATH'].split(File::PATH_SEPARATOR) do
|
136
|
+
prog_script_try = File.join(dirname, prog_script)
|
137
|
+
return prog_script_try if File.exist?(prog_script_try)
|
138
|
+
end
|
139
|
+
# Failure
|
140
|
+
return prog_script
|
141
|
+
end
|
142
|
+
|
143
|
+
options = OpenStruct.new(
|
144
|
+
'annotate' => Byebug.annotate,
|
145
|
+
'client' => false,
|
146
|
+
'control' => true,
|
147
|
+
'cport' => Byebug::PORT + 1,
|
148
|
+
'host' => nil,
|
149
|
+
'quit' => true,
|
150
|
+
'no_rewrite_program' => false,
|
151
|
+
'stop' => true,
|
152
|
+
'nx' => false,
|
153
|
+
'port' => Byebug::PORT,
|
154
|
+
'restart_script' => nil,
|
155
|
+
'script' => nil,
|
156
|
+
'server' => false,
|
157
|
+
'tracing' => false,
|
158
|
+
'verbose_long' => false,
|
159
|
+
'wait' => false
|
160
|
+
)
|
161
|
+
|
162
|
+
def process_options(options)
|
163
|
+
program = File.basename($0)
|
164
|
+
opts = OptionParser.new do |opts|
|
165
|
+
opts.banner = <<EOB
|
166
|
+
#{program} #{Byebug::VERSION}
|
167
|
+
Usage: #{program} [options] <script.rb> -- <script.rb parameters>
|
168
|
+
EOB
|
169
|
+
opts.separator ""
|
170
|
+
opts.separator "Options:"
|
171
|
+
opts.on("-A", "--annotate LEVEL", Integer, "Set annotation level") do
|
172
|
+
|annotate|
|
173
|
+
Byebug.annotate = annotate
|
174
|
+
end
|
175
|
+
opts.on("-c", "--client", "Connect to remote byebug") do
|
176
|
+
options.client = true
|
177
|
+
end
|
178
|
+
opts.on("--cport PORT", Integer, "Port used for control commands") do
|
179
|
+
|cport|
|
180
|
+
options.cport = cport
|
181
|
+
end
|
182
|
+
opts.on("-d", "--debug", "Set $DEBUG=true") {$DEBUG = true}
|
183
|
+
opts.on("--emacs LEVEL", Integer,
|
184
|
+
"Activates full Emacs support at annotation level LEVEL") do
|
185
|
+
|level|
|
186
|
+
Byebug.annotate = level.to_i
|
187
|
+
ENV['EMACS'] = '1'
|
188
|
+
ENV['COLUMNS'] = '120' if ENV['COLUMNS'].to_i < 120
|
189
|
+
options.control = false
|
190
|
+
options.quit = false
|
191
|
+
end
|
192
|
+
opts.on('--emacs-basic', 'Activates basic Emacs mode') do
|
193
|
+
ENV['EMACS'] = '1'
|
194
|
+
end
|
195
|
+
opts.on('-h', '--host HOST', 'Host name used for remote debugging') do
|
196
|
+
|host|
|
197
|
+
options.host = host
|
198
|
+
end
|
199
|
+
opts.on('-I', '--include PATH', String, 'Add PATH to $LOAD_PATH') do |path|
|
200
|
+
$LOAD_PATH.unshift(path)
|
201
|
+
end
|
202
|
+
opts.on('--no-control', 'Do not automatically start control thread') do
|
203
|
+
options.control = false
|
204
|
+
end
|
205
|
+
opts.on('--no-quit', 'Do not quit when script finishes') do
|
206
|
+
options.quit = false
|
207
|
+
end
|
208
|
+
opts.on('--no-rewrite-program',
|
209
|
+
'Do not set $0 to the program being debugged') do
|
210
|
+
options.no_rewrite_program = true
|
211
|
+
end
|
212
|
+
opts.on('--no-stop', 'Do not stop when script is loaded') do
|
213
|
+
options.stop = false
|
214
|
+
end
|
215
|
+
opts.on('-nx', 'Not run byebug initialization files (e.g. .rdebugrc') do
|
216
|
+
options.nx = true
|
217
|
+
end
|
218
|
+
opts.on('-p', '--port PORT', Integer, 'Port used for remote debugging') do
|
219
|
+
|port|
|
220
|
+
options.port = port
|
221
|
+
end
|
222
|
+
opts.on('-r', '--require SCRIPT', String,
|
223
|
+
'Require the library, before executing your script') do |name|
|
224
|
+
if name == 'debug'
|
225
|
+
puts "byebug is not compatible with Ruby's 'debug' library. This option is ignored."
|
226
|
+
else
|
227
|
+
require name
|
228
|
+
end
|
229
|
+
end
|
230
|
+
opts.on('--restart-script FILE', String,
|
231
|
+
'Name of the script file to run. Erased after read') do
|
232
|
+
|restart_script|
|
233
|
+
options.restart_script = restart_script
|
234
|
+
unless File.exists?(options.restart_script)
|
235
|
+
puts "Script file '#{options.restart_script}' is not found"
|
236
|
+
exit
|
237
|
+
end
|
238
|
+
end
|
239
|
+
opts.on('--script FILE', String, 'Name of the script file to run') do
|
240
|
+
|script|
|
241
|
+
options.script = script
|
242
|
+
unless File.exists?(options.script)
|
243
|
+
puts "Script file '#{options.script}' is not found"
|
244
|
+
exit
|
245
|
+
end
|
246
|
+
end
|
247
|
+
opts.on('-s', '--server', 'Listen for remote connections') do
|
248
|
+
options.server = true
|
249
|
+
end
|
250
|
+
opts.on('-w', '--wait', 'Wait for a client connection, implies -s option') do
|
251
|
+
options.wait = true
|
252
|
+
end
|
253
|
+
opts.on('-x', '--trace', 'Turn on line tracing') {options.tracing = true}
|
254
|
+
opts.separator ''
|
255
|
+
opts.separator 'Common options:'
|
256
|
+
opts.on_tail('--help', 'Show this message') do
|
257
|
+
puts opts
|
258
|
+
exit
|
259
|
+
end
|
260
|
+
opts.on_tail('--version',
|
261
|
+
'Print the version') do
|
262
|
+
puts "byebug #{Byebug::VERSION}"
|
263
|
+
exit
|
264
|
+
end
|
265
|
+
opts.on('--verbose', 'Turn on verbose mode') do
|
266
|
+
$VERBOSE = true
|
267
|
+
options.verbose_long = true
|
268
|
+
end
|
269
|
+
opts.on_tail('-v',
|
270
|
+
'Print version number, then turn on verbose mode') do
|
271
|
+
puts "byebug #{Byebug::VERSION}"
|
272
|
+
$VERBOSE = true
|
273
|
+
end
|
274
|
+
end
|
275
|
+
return opts
|
276
|
+
end
|
277
|
+
|
278
|
+
# What file is used for byebug startup commands.
|
279
|
+
unless defined?(OPTS_INITFILE)
|
280
|
+
if RUBY_PLATFORM =~ /mswin/
|
281
|
+
# Of course MS Windows has to be different
|
282
|
+
OPTS_INITFILE = 'rdbopt.ini'
|
283
|
+
HOME_DIR = (ENV['HOME'] ||
|
284
|
+
ENV['HOMEDRIVE'].to_s + ENV['HOMEPATH'].to_s).to_s
|
285
|
+
else
|
286
|
+
OPTS_INITFILE = '.rdboptrc'
|
287
|
+
HOME_DIR = ENV['HOME'].to_s
|
288
|
+
end
|
289
|
+
end
|
290
|
+
begin
|
291
|
+
initfile = File.join(HOME_DIR, OPTS_INITFILE)
|
292
|
+
eval(File.read(initfile)) if
|
293
|
+
File.exist?(initfile)
|
294
|
+
rescue
|
295
|
+
end
|
296
|
+
|
297
|
+
opts = process_options(options)
|
298
|
+
begin
|
299
|
+
if not defined? Byebug::ARGV
|
300
|
+
Byebug::ARGV = ARGV.clone
|
301
|
+
end
|
302
|
+
rdebug_path = File.expand_path($0)
|
303
|
+
if RUBY_PLATFORM =~ /mswin/
|
304
|
+
rdebug_path += '.cmd' unless rdebug_path =~ /\.cmd$/i
|
305
|
+
end
|
306
|
+
Byebug::RDEBUG_SCRIPT = rdebug_path
|
307
|
+
Byebug::RDEBUG_FILE = __FILE__
|
308
|
+
Byebug::INITIAL_DIR = Dir.pwd
|
309
|
+
opts.parse! ARGV
|
310
|
+
rescue StandardError => e
|
311
|
+
puts opts
|
312
|
+
puts
|
313
|
+
puts e.message
|
314
|
+
exit(-1)
|
315
|
+
end
|
316
|
+
|
317
|
+
if options.client
|
318
|
+
Byebug.start_client(options.host, options.port)
|
319
|
+
else
|
320
|
+
if ARGV.empty?
|
321
|
+
exit if $VERBOSE and not options.verbose_long
|
322
|
+
puts opts
|
323
|
+
puts
|
324
|
+
puts 'Must specify a script to run'
|
325
|
+
exit(-1)
|
326
|
+
end
|
327
|
+
|
328
|
+
# save script name
|
329
|
+
prog_script = ARGV.shift
|
330
|
+
prog_script = whence_file(prog_script) unless File.exist?(prog_script)
|
331
|
+
Byebug::PROG_SCRIPT = File.expand_path prog_script
|
332
|
+
|
333
|
+
# install interruption handler
|
334
|
+
trap('INT') { Byebug.interrupt_last }
|
335
|
+
|
336
|
+
# set options
|
337
|
+
Byebug.wait_connection = options.wait
|
338
|
+
|
339
|
+
if options.server
|
340
|
+
# start remote mode
|
341
|
+
Byebug.start_remote(options.host, [options.port, options.cport]) do
|
342
|
+
# load initrc script
|
343
|
+
Byebug.run_init_script(StringIO.new) unless options.nx
|
344
|
+
end
|
345
|
+
debug_program(options)
|
346
|
+
else
|
347
|
+
# Set up trace hook for byebug
|
348
|
+
Byebug.start
|
349
|
+
|
350
|
+
# start control thread
|
351
|
+
Byebug.start_control(options.host, options.cport) if options.control
|
352
|
+
|
353
|
+
# load initrc script (e.g. .rdebugrc)
|
354
|
+
Byebug.run_init_script(StringIO.new) unless options.nx
|
355
|
+
|
356
|
+
# run restore-settings startup script if specified
|
357
|
+
if options.restart_script
|
358
|
+
require 'fileutils'
|
359
|
+
Byebug.run_script(options.restart_script)
|
360
|
+
FileUtils.rm(options.restart_script)
|
361
|
+
end
|
362
|
+
|
363
|
+
# run startup script if specified
|
364
|
+
if options.script
|
365
|
+
Byebug.run_script(options.script)
|
366
|
+
end
|
367
|
+
|
368
|
+
options.stop = false if options.tracing
|
369
|
+
Byebug.current_context.tracing = options.tracing
|
370
|
+
|
371
|
+
if !options.quit
|
372
|
+
if Byebug.started?
|
373
|
+
until Byebug.stop do end
|
374
|
+
end
|
375
|
+
begin
|
376
|
+
debug_program(options)
|
377
|
+
rescue SyntaxError
|
378
|
+
puts $!.backtrace.map{|l| "\t#{l}"}.join("\n")
|
379
|
+
puts "Uncaught Syntax Error\n"
|
380
|
+
rescue
|
381
|
+
print $!.backtrace.map{|l| "\t#{l}"}.join("\n"), "\n"
|
382
|
+
print "Uncaught exception: #{$!}\n"
|
383
|
+
end
|
384
|
+
print "The program finished.\n" unless
|
385
|
+
Byebug.annotate.to_i > 1 # annotate has its own way
|
386
|
+
interface = Byebug::LocalInterface.new
|
387
|
+
# Not sure if ControlCommandProcessor is really the right
|
388
|
+
# thing to use. CommandProcessor requires a state.
|
389
|
+
processor = Byebug::ControlCommandProcessor.new(interface)
|
390
|
+
processor.process_commands
|
391
|
+
else
|
392
|
+
debug_program(options)
|
393
|
+
end
|
394
|
+
end
|
395
|
+
end
|