byebug 1.0.1 → 1.0.2
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -2
- data/bin/byebug +2 -4
- data/ext/byebug/byebug.c +10 -10
- data/lib/byebug/command.rb +15 -9
- data/lib/byebug/commands/breakpoints.rb +4 -3
- data/lib/byebug/commands/enable.rb +57 -61
- data/lib/byebug/commands/eval.rb +35 -31
- data/lib/byebug/commands/frame.rb +24 -19
- data/lib/byebug/commands/info.rb +74 -95
- data/lib/byebug/commands/list.rb +3 -0
- data/lib/byebug/commands/set.rb +147 -158
- data/lib/byebug/commands/show.rb +46 -41
- data/lib/byebug/commands/trace.rb +6 -6
- data/lib/byebug/context.rb +1 -2
- data/lib/byebug/processor.rb +10 -7
- data/lib/byebug/version.rb +1 -1
- data/old_doc/byebug.texi +426 -461
- data/test/eval_test.rb +35 -29
- data/test/frame_test.rb +48 -47
- data/test/info_test.rb +4 -4
- data/test/list_test.rb +1 -4
- data/test/reload_test.rb +35 -30
- data/test/show_test.rb +4 -6
- data/test/source_test.rb +33 -30
- data/test/stepping_test.rb +0 -1
- data/test/support/test_dsl.rb +0 -4
- data/test/test_helper.rb +0 -5
- data/test/trace_test.rb +65 -69
- metadata +2 -3
- data/old_doc/byebug.html +0 -6178
data/lib/byebug/commands/show.rb
CHANGED
@@ -150,38 +150,46 @@ module Byebug
|
|
150
150
|
|
151
151
|
Subcommands =
|
152
152
|
[
|
153
|
-
|
154
|
-
|
155
|
-
|
153
|
+
['annotate', 2, 'Show annotation level',
|
154
|
+
'0 == normal;' \
|
155
|
+
'2 == output annotated suitably for use by programs that control ' \
|
156
|
+
'byebug.'],
|
156
157
|
['args', 2,
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
['
|
162
|
-
['
|
163
|
-
['
|
164
|
-
['
|
165
|
-
['
|
166
|
-
|
167
|
-
['
|
168
|
-
|
169
|
-
['
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
158
|
+
'Show argument list to give to the program being debugged when it ' \
|
159
|
+
'is started',
|
160
|
+
'Follow this command with any number of args to be passed to the ' \
|
161
|
+
'program.'],
|
162
|
+
['autoeval', 4, 'Show whether unrecognized commands are evaluated'],
|
163
|
+
['autolist', 4, 'Show whether "list" command is run on stopping'],
|
164
|
+
['autoirb', 4, 'Show whether IRB is invoked on stopping'],
|
165
|
+
['autoreload', 4, 'Show whether source code is reloaded when changed'],
|
166
|
+
['basename', 1, 'Show whether basename is used when reporting files'],
|
167
|
+
['callstyle', 2, 'Show paramater style used when showing call frames'],
|
168
|
+
['commands', 2, 'Show the history of commands you typed',
|
169
|
+
'You can supply a command number to start with.'],
|
170
|
+
['forcestep', 1, 'Show whether "next/step" force to move onto a new ' \
|
171
|
+
'line'],
|
172
|
+
['fullpath', 2, 'Show whether full paths are displayed in frames'],
|
173
|
+
['history', 2, 'Generic command to show command history parameters',
|
174
|
+
'show history filename -- Show the filename in which to record the ' \
|
175
|
+
'command history.' \
|
176
|
+
'show history save -- Show whether history record should be saved ' \
|
177
|
+
'on exit.' \
|
178
|
+
'show history size -- Show the size of the command history.'],
|
179
|
+
['keep-frame-bindings', 1, 'Save frame binding on each call'],
|
180
|
+
['linetrace', 3, 'Show line execution tracing'],
|
175
181
|
['linetrace+', 10,
|
176
|
-
|
177
|
-
['listsize', 3,
|
178
|
-
['port', 3,
|
182
|
+
'Show whether different consecutive lines are shown in tracing'],
|
183
|
+
['listsize', 3, 'Show number of source lines to list by default.'],
|
184
|
+
['port', 3, 'Show server port'],
|
179
185
|
['post-mortem', 3,
|
180
|
-
|
186
|
+
'Show whether we go into post-mortem debugging on an uncaught ' \
|
187
|
+
'exception'],
|
181
188
|
['trace', 1,
|
182
|
-
|
183
|
-
|
184
|
-
['
|
189
|
+
'Show whether a stack trace is displayed when "eval" raises an ' \
|
190
|
+
'exception'],
|
191
|
+
['version', 1, 'Show byebug\'s version'],
|
192
|
+
['width', 1, 'Show the number of characters per line for byebug']
|
185
193
|
].map do |name, min, short_help, long_help|
|
186
194
|
SubcmdStruct.new(name, min, short_help, long_help)
|
187
195
|
end unless defined?(Subcommands)
|
@@ -194,7 +202,7 @@ show history size -- Show the size of the command history"],
|
|
194
202
|
|
195
203
|
def execute
|
196
204
|
if not @match[1]
|
197
|
-
|
205
|
+
print_subcmds(Subcommands)
|
198
206
|
else
|
199
207
|
args = @match[1].split(/[ \t]+/)
|
200
208
|
param = args.shift
|
@@ -213,20 +221,17 @@ show history size -- Show the size of the command history"],
|
|
213
221
|
end
|
214
222
|
|
215
223
|
def help(args)
|
224
|
+
# specific subcommand help
|
216
225
|
if args[1]
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
str = subcmd.short_help + '.'
|
224
|
-
str += "\n" + subcmd.long_help if subcmd.long_help
|
225
|
-
return str
|
226
|
-
else
|
227
|
-
return "Invalid 'show' subcommand '#{args[1]}'."
|
228
|
-
end
|
226
|
+
subcmd = find(Subcommands, args[1])
|
227
|
+
return "Invalid \"show\" subcommand \"#{args[1]}\"." unless subcmd
|
228
|
+
|
229
|
+
str = subcmd.short_help + '.'
|
230
|
+
str += "\n" + subcmd.long_help if subcmd.long_help
|
231
|
+
return str
|
229
232
|
end
|
233
|
+
|
234
|
+
# general help
|
230
235
|
s = "
|
231
236
|
Generic command for showing things about byebug.
|
232
237
|
|
@@ -12,29 +12,29 @@ module Byebug
|
|
12
12
|
onoff = 'on' == @match[1]
|
13
13
|
#if @match[2]
|
14
14
|
Byebug.tracing = onoff
|
15
|
-
print "Tracing is #{onoff ? 'on' : 'off'}"
|
15
|
+
print "Tracing is #{onoff ? 'on' : 'off'}\n"
|
16
16
|
#else
|
17
17
|
# Byebug.current_context.tracing = onoff
|
18
|
-
# print "Tracing
|
18
|
+
# print "Tracing #{onoff ? 'on' : 'off'} on current thread.\n"
|
19
19
|
#end
|
20
20
|
elsif @match[1] =~ /var(?:iable)?/
|
21
21
|
varname=@match[2]
|
22
22
|
if debug_eval("defined?(#{varname})")
|
23
23
|
if @match[3] && @match[3] !~ /(:?no)?stop/
|
24
|
-
errmsg
|
24
|
+
errmsg "expecting \"stop\" or \"nostop\"; got \"#{@match[3]}\"\n"
|
25
25
|
else
|
26
26
|
dbg_cmd = (@match[3] && (@match[3] !~ /nostop/)) ? 'byebug' : ''
|
27
27
|
end
|
28
28
|
eval("trace_var(:#{varname}) do |val|
|
29
|
-
print \"traced variable
|
29
|
+
print \"traced variable \#{varname} has value \#{val}\n\"
|
30
30
|
#{dbg_cmd}
|
31
31
|
end")
|
32
32
|
else
|
33
33
|
errmsg "#{varname} is not a global variable.\n"
|
34
34
|
end
|
35
35
|
else
|
36
|
-
errmsg
|
37
|
-
@match[1]
|
36
|
+
errmsg "expecting \"on\", \"off\", \"var\" or \"variable\"; got: " \
|
37
|
+
"\"#{@match[1]}\"\n"
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
data/lib/byebug/context.rb
CHANGED
data/lib/byebug/processor.rb
CHANGED
@@ -125,7 +125,7 @@ module Byebug
|
|
125
125
|
if Byebug.annotate.to_i > 2
|
126
126
|
print afmt("source #{file}:#{line}")
|
127
127
|
end
|
128
|
-
print "Stopped
|
128
|
+
print "Stopped by breakpoint %d at %s:%s\n", n, file, line
|
129
129
|
end
|
130
130
|
protect :at_breakpoint
|
131
131
|
|
@@ -147,14 +147,14 @@ module Byebug
|
|
147
147
|
|
148
148
|
def at_tracing(context, file, line)
|
149
149
|
# Don't trace ourselves
|
150
|
-
return if defined?(Byebug::
|
150
|
+
return if defined?(Byebug::BYEBUG_BIN) && Byebug::BYEBUG_BIN == file
|
151
151
|
|
152
152
|
file = CommandProcessor.canonic_file(file)
|
153
153
|
tracing_plus = Command.settings[:tracing_plus]
|
154
|
-
if file != @last_file || line != @last_line || tracing_plus
|
154
|
+
if file != @last_file || line != @last_line || tracing_plus == false
|
155
155
|
@last_file = file
|
156
156
|
@last_line = line
|
157
|
-
print "Tracing: #{file}:#{line} #{Byebug.line_at(file, line)}"
|
157
|
+
print "Tracing: #{file}:#{line} #{Byebug.line_at(file, line)}\n"
|
158
158
|
end
|
159
159
|
always_run(context, file, line, 2)
|
160
160
|
end
|
@@ -166,8 +166,7 @@ module Byebug
|
|
166
166
|
protect :at_line
|
167
167
|
|
168
168
|
def at_return(context, file, line)
|
169
|
-
context.stop_frame = -1
|
170
|
-
process_commands(context, file, line)
|
169
|
+
#context.stop_frame = -1
|
171
170
|
end
|
172
171
|
|
173
172
|
private
|
@@ -244,7 +243,11 @@ module Byebug
|
|
244
243
|
end
|
245
244
|
|
246
245
|
preloop(commands, context)
|
247
|
-
|
246
|
+
|
247
|
+
if not Command.settings[:autolist]
|
248
|
+
CommandProcessor.print_location_and_text(file, line)
|
249
|
+
end
|
250
|
+
|
248
251
|
while !state.proceed?
|
249
252
|
input = if @interface.command_queue.empty?
|
250
253
|
@interface.read_command(prompt(context))
|
data/lib/byebug/version.rb
CHANGED
data/old_doc/byebug.texi
CHANGED
@@ -7,9 +7,9 @@
|
|
7
7
|
|
8
8
|
@set txicodequoteundirected
|
9
9
|
@set txicodequotebacktick
|
10
|
-
@set BYEBUG_VERSION
|
11
|
-
@set EDITION
|
12
|
-
@set UPDATED
|
10
|
+
@set BYEBUG_VERSION 1.0.1
|
11
|
+
@set EDITION 1.0.1
|
12
|
+
@set UPDATED April-2013
|
13
13
|
|
14
14
|
@macro Example {}
|
15
15
|
@iftex
|
@@ -74,8 +74,7 @@
|
|
74
74
|
@node Top, Summary, (dir), (dir)
|
75
75
|
@top Debugging with byebug
|
76
76
|
|
77
|
-
This file describes Byebug, a Ruby 2.0 debugger,
|
78
|
-
version @value{BYEBUG_VERSION}
|
77
|
+
This file describes Byebug, a Ruby 2.0 debugger, version @value{BYEBUG_VERSION}
|
79
78
|
|
80
79
|
This is the @value{EDITION} Edition, @value{UPDATED}
|
81
80
|
@c Copyleft (U+0254) 2013
|
@@ -124,8 +123,8 @@ Change things in your script, so you can experiment with correcting the effects
|
|
124
123
|
one bug and go on to learn about another.
|
125
124
|
@end itemize
|
126
125
|
|
127
|
-
Although you can use @value{
|
128
|
-
at the outset, there are other ways to use and enter the debugger
|
126
|
+
Although you can use @value{byebug} to invoke your Ruby programs via a debugger
|
127
|
+
at the outset, there are other ways to use and enter the debugger.
|
129
128
|
|
130
129
|
@menu
|
131
130
|
* First Sample Session:: A Simple Sample @code{byebug} session
|
@@ -174,7 +173,7 @@ triangle.rb:4 def hanoi(n,a,b,c)
|
|
174
173
|
[9, 18] in ./triangle.rb
|
175
174
|
9 tri
|
176
175
|
10 end
|
177
|
-
11
|
176
|
+
11
|
178
177
|
12 t = triangle(3)
|
179
178
|
13 puts t
|
180
179
|
(byebug:1) @b{list 1,100}
|
@@ -189,10 +188,10 @@ triangle.rb:4 def hanoi(n,a,b,c)
|
|
189
188
|
8 end
|
190
189
|
9 tri
|
191
190
|
10 end
|
192
|
-
11
|
191
|
+
11
|
193
192
|
12 t = triangle(3)
|
194
193
|
13 puts t
|
195
|
-
(byebug:1)
|
194
|
+
(byebug:1)
|
196
195
|
@end smallexample
|
197
196
|
|
198
197
|
@noindent
|
@@ -298,9 +297,9 @@ Tracing(1):triangle.rb:9 tri
|
|
298
297
|
6
|
299
298
|
Tracing(1):triangle.rb:13 puts t
|
300
299
|
1: tri =
|
301
|
-
2: i =
|
300
|
+
2: i =
|
302
301
|
1: tri =
|
303
|
-
2: i =
|
302
|
+
2: i =
|
304
303
|
triangle.rb:13
|
305
304
|
puts t
|
306
305
|
(byebug:1) @b{quit}
|
@@ -375,7 +374,7 @@ see what private methods we can call before running @code{def hanoi}
|
|
375
374
|
(byebug:1) @b{set autoeval on}
|
376
375
|
autoeval is on.
|
377
376
|
(byebug:1) @b{private_methods}
|
378
|
-
[:require_relative, :Digest, :default_src_encoding, :debug_program, ...
|
377
|
+
[:require_relative, :Digest, :default_src_encoding, :debug_program, ...
|
379
378
|
@end smallexample
|
380
379
|
|
381
380
|
The @code{set autoeval} (@pxref{Autoeval}) command causes any commands
|
@@ -394,26 +393,26 @@ sort and put into columns lists like this using the print command, @code{ps}.
|
|
394
393
|
|
395
394
|
@smallexample
|
396
395
|
(byebug:1) @b{ps private_methods}
|
397
|
-
Array debug_program p spawn
|
398
|
-
Complex default_src_encoding pp sprintf
|
399
|
-
Digest eval print srand
|
400
|
-
Float exec printf syscall
|
401
|
-
Integer exit proc system
|
402
|
-
Pathname exit! process_options test
|
403
|
-
Rational fail putc throw
|
404
|
-
String fork puts trace_var
|
405
|
-
__callee__ format raise trap
|
406
|
-
__method__ gem rand untrace_var
|
407
|
-
` gets readline warn
|
408
|
-
abort global_variables readlines whence_file
|
409
|
-
at_exit initialize remove_instance_variable y
|
410
|
-
autoload initialize_copy require
|
411
|
-
autoload? iterator? require_relative
|
412
|
-
binding lambda select
|
413
|
-
block_given? load set_trace_func
|
414
|
-
caller local_variables singleton_method_added
|
415
|
-
catch loop singleton_method_removed
|
416
|
-
dbg_print method_missing singleton_method_undefined
|
396
|
+
Array debug_program p spawn
|
397
|
+
Complex default_src_encoding pp sprintf
|
398
|
+
Digest eval print srand
|
399
|
+
Float exec printf syscall
|
400
|
+
Integer exit proc system
|
401
|
+
Pathname exit! process_options test
|
402
|
+
Rational fail putc throw
|
403
|
+
String fork puts trace_var
|
404
|
+
__callee__ format raise trap
|
405
|
+
__method__ gem rand untrace_var
|
406
|
+
` gets readline warn
|
407
|
+
abort global_variables readlines whence_file
|
408
|
+
at_exit initialize remove_instance_variable y
|
409
|
+
autoload initialize_copy require
|
410
|
+
autoload? iterator? require_relative
|
411
|
+
binding lambda select
|
412
|
+
block_given? load set_trace_func
|
413
|
+
caller local_variables singleton_method_added
|
414
|
+
catch loop singleton_method_removed
|
415
|
+
dbg_print method_missing singleton_method_undefined
|
417
416
|
dbg_puts open sleep
|
418
417
|
@end smallexample
|
419
418
|
|
@@ -477,47 +476,44 @@ Breakpoint 1 at hanoi.rb:4
|
|
477
476
|
1: n = 2
|
478
477
|
3: a.inspect = :a
|
479
478
|
4: b.inspect = :c
|
480
|
-
./hanoi.rb:4
|
479
|
+
./hanoi.rb:4
|
481
480
|
if n-1 > 0
|
482
481
|
(byebug:1) @b{c}
|
483
482
|
Breakpoint 1 at hanoi.rb:4
|
484
483
|
1: n = 1
|
485
484
|
3: a.inspect = :a
|
486
485
|
4: b.inspect = :b
|
487
|
-
./hanoi.rb:4
|
486
|
+
./hanoi.rb:4
|
488
487
|
if n-1 > 0
|
489
488
|
(byebug:1) @b{where}
|
490
|
-
--> #0 Object.hanoi(n#Fixnum, a#Symbol, b#Symbol, c#Symbol) at
|
491
|
-
#1 Object.hanoi(n#Fixnum, a#Symbol, b#Symbol, c#Symbol) at
|
492
|
-
#2 Object.hanoi(n#Fixnum, a#Symbol, b#Symbol, c#Symbol) at
|
493
|
-
#3 at
|
494
|
-
(byebug:1)
|
495
|
-
@end smallexample
|
496
|
-
|
497
|
-
In the above we added a new command, @code{break}
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
that display expression is removed.
|
505
|
-
|
506
|
-
Above we also used a new command @code{where} (@pxref{Backtrace} to
|
507
|
-
show the call stack. In the above situation, starting from the bottom
|
508
|
-
line we see we called the hanoi from line 35 of the file
|
509
|
-
@code{hanoi.rb} and the hanoi method called itself two more times at
|
510
|
-
line 5.
|
511
|
-
|
512
|
-
In the call stack we show the file line position in the same format
|
513
|
-
when we stop at a line. Also we see the names of the parameters and
|
514
|
-
the types that those parameters @emph{currently} have. It's possible
|
515
|
-
that when the program was called the parameter had a different type,
|
516
|
-
since the types of variables can change dynamically. You alter the
|
517
|
-
style of what to show in the trace (@pxref{Callstyle}).
|
518
|
-
|
519
|
-
Let's explore a little more. Now were were we?
|
489
|
+
--> #0 Object.hanoi(n#Fixnum, a#Symbol, b#Symbol, c#Symbol) at hanoi.rb:4
|
490
|
+
#1 Object.hanoi(n#Fixnum, a#Symbol, b#Symbol, c#Symbol) at hanoi.rb:5
|
491
|
+
#2 Object.hanoi(n#Fixnum, a#Symbol, b#Symbol, c#Symbol) at hanoi.rb:5
|
492
|
+
#3 at hanoi.rb:35
|
493
|
+
(byebug:1)
|
494
|
+
@end smallexample
|
495
|
+
|
496
|
+
In the above we added a new command, @code{break} (@pxref{Breakpoints}) which
|
497
|
+
indicates to go into byebug just before that line of code is run. And
|
498
|
+
@code{continue} resumes execution. Notice the difference between
|
499
|
+
@code{display a} and @code{display a.inspect}. An implied string conversion is
|
500
|
+
performed on the expression after it is evaluated. To remove a display
|
501
|
+
expression @code{undisplay} is used. If we give a display number, just that
|
502
|
+
display expression is removed.
|
520
503
|
|
504
|
+
Above we also used a new command @code{where} (@pxref{Backtrace} to show the
|
505
|
+
call stack. In the above situation, starting from the bottom line we see we
|
506
|
+
called the hanoi from line 35 of the file @code{hanoi.rb} and the hanoi method
|
507
|
+
called itself two more times at line 5.
|
508
|
+
|
509
|
+
In the call stack we show the file line position in the same format we use when
|
510
|
+
we stop at a line. Also we see the names of the parameters and the types that
|
511
|
+
those parameters @emph{currently} have. It's possible that when the program was
|
512
|
+
called the parameter had a different type, since the types of variables can
|
513
|
+
change dynamically. You can alter the style of what to show in the trace
|
514
|
+
(@pxref{Callstyle}).
|
515
|
+
|
516
|
+
Let's explore a little more. Now where were we?
|
521
517
|
@smallexample
|
522
518
|
(byebug:1) @b{list}
|
523
519
|
1 #!/usr/bin/ruby
|
@@ -533,72 +529,67 @@ Clear all expressions? (y/n) @b{y}
|
|
533
529
|
(byebug:1) @b{i_args}
|
534
530
|
NameError Exception: undefined local variable or method `i_args' for main:Object
|
535
531
|
(byebug:1) @b{frame -1}
|
536
|
-
#3 at
|
532
|
+
#3 at hanoi.rb:35
|
537
533
|
(byebug:1) @b{i_args}
|
538
534
|
1
|
539
535
|
(byebug:1) @b{p n}
|
540
536
|
3
|
541
537
|
(byebug:1) @b{down 2}
|
542
|
-
#2 Object.hanoi(n#Fixnum, a#Symbol, b#Symbol, c#Symbol) at
|
538
|
+
#2 Object.hanoi(n#Fixnum, a#Symbol, b#Symbol, c#Symbol) at hanoi.rb:5
|
543
539
|
(byebug:1) @b{p n}
|
544
540
|
2
|
545
541
|
@end smallexample
|
546
542
|
|
547
|
-
Notice in the above to get the value of variable @code{n}
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
would have been the same thing; so would issuing @code{up 3}.
|
543
|
+
Notice in the above to get the value of variable @code{n} I had to use a print
|
544
|
+
command like @code{p n}; If I entered just @code{n}, that would be taken to mean
|
545
|
+
byebug command ``next''. In the current scope, variable @code{i_args} is not
|
546
|
+
defined. However I can change to the top-most frame by using the @code{frame}
|
547
|
+
command. Just as with arrays, -1 means the last one. Alternatively using frame
|
548
|
+
number 3 would have been the same thing; so would issuing @code{up 3}.
|
554
549
|
|
555
|
-
Note that in the outside frame 3, the value of @code{i_args} can be
|
556
|
-
|
550
|
+
Note that in the outside frame 3, the value of @code{i_args} can be shown. Also
|
551
|
+
note that the value of variable @code{n} is different.
|
557
552
|
|
558
553
|
@node Unit Testing Session
|
559
|
-
@section Using byebug in unit testing (@code{byebug
|
554
|
+
@section Using byebug in unit testing (@code{byebug}, @code{Byebug.start})
|
560
555
|
|
561
|
-
In the previous sessions we've been calling byebug right at the
|
562
|
-
|
563
|
-
byebug.
|
556
|
+
In the previous sessions we've been calling byebug right at the outset. I
|
557
|
+
confess that this mode of operation is usually not how I use byebug.
|
564
558
|
|
565
559
|
There are a number of situations where calling byebug at the outset is
|
566
560
|
impractical for a couple of reasons.
|
567
561
|
|
568
562
|
@enumerate
|
569
|
-
@item
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
@item
|
574
|
-
There's a lot of code
|
575
|
-
|
576
|
-
overhead of byebug.
|
563
|
+
@item
|
564
|
+
byebug just doesn't work when run at the outset. By necessity any debugging
|
565
|
+
changes the behavior or the program in slight and subtle ways, and sometimes
|
566
|
+
this can hinder finding bugs.
|
567
|
+
@item
|
568
|
+
There's a lot of code that needs to be run before the part you want to inspect.
|
569
|
+
Running this code takes time and you don't want the overhead of byebug.
|
577
570
|
@end enumerate
|
578
571
|
|
579
|
-
In this section we'll show how to enter the code in the middle
|
580
|
-
|
581
|
-
|
582
|
-
In this section we will also use unit testing. Using unit tests will
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
What we'll do is take the @code{triangle} code from the first session
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
@smallexample
|
601
|
-
if __FILE__ == $0
|
572
|
+
In this section we'll show how to enter the code in the middle of your program,
|
573
|
+
while delving more into byebug's operation.
|
574
|
+
|
575
|
+
In this section we will also use unit testing. Using unit tests will greatly
|
576
|
+
reduce the amount of debugging needed, while at the same time, will increase the
|
577
|
+
quality of your program.
|
578
|
+
|
579
|
+
What we'll do is take the @code{triangle} code from the first session and write
|
580
|
+
a unit test for that. In a sense we did write a minitest for the program which
|
581
|
+
was basically the last line where we printed the value of triangle(3). This test
|
582
|
+
however wasn't automated: the implication is that someone would look at the
|
583
|
+
output and verify that what was printed is what was expected.
|
584
|
+
|
585
|
+
Before we can turn that into something that can be @code{required}, we probably
|
586
|
+
want to remove that output. However I like to keep in that line so that when I
|
587
|
+
look at the file, I have an example of how to run it. Therefore we will
|
588
|
+
conditionally run this line if that file is invoked directly, but skip it if it
|
589
|
+
is not@footnote{@code{byebug} resets @code{$0} to try to make things like this
|
590
|
+
work.}.
|
591
|
+
@smallexample
|
592
|
+
if __FILE__ == $0
|
602
593
|
t = triangle(3)
|
603
594
|
puts t
|
604
595
|
end
|
@@ -606,10 +597,9 @@ like this work.}
|
|
606
597
|
|
607
598
|
Let's call this file @code{tri2.rb}.
|
608
599
|
|
609
|
-
Okay, we're now ready to write our unit test. We'll use
|
610
|
-
|
611
|
-
|
612
|
-
|
600
|
+
Okay, we're now ready to write our unit test. We'll use @code{"test/unit"} which
|
601
|
+
comes with the standard Ruby distribution. Here's the test code; it should be
|
602
|
+
in the same directory as tri2.rb.
|
613
603
|
@smallexample
|
614
604
|
#!/usr/bin/env ruby
|
615
605
|
require 'test/unit'
|
@@ -617,8 +607,8 @@ Here's the test code; it should be in the same directory as tri2.rb.
|
|
617
607
|
|
618
608
|
class TestTri < Test::Unit::TestCase
|
619
609
|
def test_basic
|
620
|
-
|
621
|
-
|
610
|
+
solutions = []
|
611
|
+
0.upto(5) do |i|
|
622
612
|
solutions << triangle(i)
|
623
613
|
end
|
624
614
|
assert_equal([0, 1, 3, 6, 10, 15], solutions,
|
@@ -627,17 +617,15 @@ Here's the test code; it should be in the same directory as tri2.rb.
|
|
627
617
|
end
|
628
618
|
@end smallexample
|
629
619
|
|
630
|
-
If you run it will work. However if you run @code{byebug} initially,
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
byebug
|
635
|
-
|
636
|
-
|
637
|
-
to modify the code as shown here.}
|
620
|
+
If you run it, it will work. However if you run @code{byebug} initially, you
|
621
|
+
will not get into the test, because @code{test/unit} wants to be the main
|
622
|
+
program. So here is a situation where one may need to modify the program to add
|
623
|
+
an explicit @emph{entry} into byebug. @footnote{For some versions of rake and
|
624
|
+
@code{byebug} you can in fact set a breakpoint after running @code{byebug}
|
625
|
+
initially. Personally though I find it much simpler and more reliable to modify
|
626
|
+
the code as shown here.}
|
638
627
|
|
639
|
-
One way to do this is to add the following before the place you want
|
640
|
-
to stop:
|
628
|
+
One way to do this is to add the following before the place you want to stop:
|
641
629
|
@smallexample
|
642
630
|
require 'byebug'
|
643
631
|
byebug
|
@@ -645,7 +633,7 @@ to stop:
|
|
645
633
|
|
646
634
|
Let's add this code just after entering @code{test_basic}:
|
647
635
|
@smallexample
|
648
|
-
...
|
636
|
+
...
|
649
637
|
def test_basic
|
650
638
|
@b{require "byebug"}
|
651
639
|
@b{byebug}
|
@@ -662,31 +650,29 @@ Now we run the program..
|
|
662
650
|
solutions = []
|
663
651
|
(byebug:1)
|
664
652
|
@end smallexample
|
665
|
-
and we see that we are stopped at line 9 just before the
|
666
|
-
|
653
|
+
and we see that we are stopped at line 9 just before the initialization of the
|
654
|
+
list @code{solutions}.
|
667
655
|
|
668
656
|
Now let's see where we are...
|
669
|
-
|
670
657
|
@smallexample
|
671
658
|
(byebug:1) @b{where}
|
672
|
-
--> #0 TestTri.test_basic at
|
673
|
-
(byebug:1)
|
659
|
+
--> #0 TestTri.test_basic at /home/rocky/ruby/test-tri.rb:9
|
660
|
+
(byebug:1)
|
674
661
|
@end smallexample
|
675
662
|
|
676
|
-
Something seems wrong here; @code{TestTri.test_basic} indicates that
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
663
|
+
Something seems wrong here; @code{TestTri.test_basic} indicates that we are in
|
664
|
+
class @code{TestTri} in method @code{test_basic}. However we don't see the call
|
665
|
+
to this like we did in the last example when we used the @code{where} command.
|
666
|
+
This is because byebug really didn't spring into existence until after we
|
667
|
+
already had entered that method, and Ruby doesn't keep call stack information
|
668
|
+
around in a way that would give the information we show when running
|
669
|
+
@code{where}.
|
683
670
|
|
684
|
-
If we want call stack information, we have to turn call-stack tracking
|
685
|
-
|
686
|
-
|
687
|
-
Here's what our test program looks like so after we modify it to start
|
688
|
-
tracking calls from the outset
|
671
|
+
If we want call stack information, we have to turn call-stack tracking on
|
672
|
+
@emph{beforehand}. This is done by adding @code{Byebug.start}.
|
689
673
|
|
674
|
+
Here's what our test program looks like so after we modify it to start tracking
|
675
|
+
calls from the outset
|
690
676
|
@smallexample
|
691
677
|
#!/usr/bin/env ruby
|
692
678
|
require 'test/unit'
|
@@ -715,47 +701,44 @@ Started
|
|
715
701
|
test-tri2.rb:11
|
716
702
|
solutions = []
|
717
703
|
(byebug:1) @b{where}
|
718
|
-
--> #0 TestTri.test_basic at
|
719
|
-
#1 MiniTest::Unit::TestCase.run(runner#MiniTest::Unit)
|
720
|
-
at
|
721
|
-
#2 MiniTest::Unit.run_test_suites
|
722
|
-
at
|
723
|
-
#3 MiniTest::Unit.run
|
724
|
-
at
|
725
|
-
#4 at
|
726
|
-
(byebug:1)
|
704
|
+
--> #0 TestTri.test_basic at test-tri2.rb:11
|
705
|
+
#1 MiniTest::Unit::TestCase.run(runner#MiniTest::Unit)
|
706
|
+
at /usr/local/lib/ruby/1.9.1/minitest/unit.rb:458
|
707
|
+
#2 MiniTest::Unit.run_test_suites
|
708
|
+
at /usr/local/lib/ruby/1.9.1/minitest/unit.rb:426
|
709
|
+
#3 MiniTest::Unit.run
|
710
|
+
at /usr/local/lib/ruby/1.9.1/minitest/unit.rb:393
|
711
|
+
#4 at /usr/local/lib/ruby/1.9.1/minitest/unit.rb:334
|
712
|
+
(byebug:1)
|
727
713
|
@end smallexample
|
728
714
|
|
729
|
-
Much better. But again let me emphasize that the parameter types are
|
730
|
-
|
731
|
-
|
715
|
+
Much better. But again let me emphasize that the parameter types are those of
|
716
|
+
the corresponding variables that @emph{currently} exist, and this might have
|
717
|
+
changed since the time when the call was made.
|
732
718
|
|
733
719
|
@node Byebug.start with a block
|
734
720
|
@section Using the @code{Byebug.start} with a block
|
735
721
|
|
736
|
-
We saw that @code{Byebug.start()} and @code{Byebug.stop()} allow
|
737
|
-
|
738
|
-
|
739
|
-
Rather than use an explicit @code{stop()}, you can also pass a block
|
740
|
-
to the @code{start()} method. This causes @code{start()} to run and
|
741
|
-
then @code{yield} to that block. When the block is finished,
|
742
|
-
@code{stop()} is run. In other words, this wraps a
|
743
|
-
@code{Byebug.start()} and @code{Byebug.stop()} around the block of
|
744
|
-
code. But it also has a side benefit of ensuring that in the presence
|
745
|
-
of an uncaught exception @code{stop} is run, without having to
|
746
|
-
explicitly use @code{begin} ... @code{ensure Byebug.stop() end}.
|
722
|
+
We saw that @code{Byebug.start()} and @code{Byebug.stop()} allow fine-grain
|
723
|
+
control over where byebug tracking should occur.
|
747
724
|
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
725
|
+
Rather than use an explicit @code{stop()}, you can also pass a block to the
|
726
|
+
@code{start()} method. This causes @code{start()} to run and then @code{yield}
|
727
|
+
to that block. When the block is finished, @code{stop()} is run. In other words,
|
728
|
+
this wraps a @code{Byebug.start()} and @code{Byebug.stop()} around the block of
|
729
|
+
code. But it also has a side benefit of ensuring that in the presence of an
|
730
|
+
uncaught exception @code{stop} is run, without having to explicitly use
|
731
|
+
@code{begin} ... @code{ensure Byebug.stop() end}.
|
753
732
|
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
733
|
+
For example, in Ruby on Rails you might want to debug code in one of the
|
734
|
+
controllers without causing any slowdown to any other code. And this can be done
|
735
|
+
by wrapping the controller in a @code{start()} with a block; when the method
|
736
|
+
wrapped this way finishes, byebug is turned off and the application proceeds at
|
737
|
+
regular speed.
|
758
738
|
|
739
|
+
Of course, inside the block you will probably want to enter the byebug using
|
740
|
+
@code{Byebug.byebug()}, otherwise there would be little point in using the
|
741
|
+
@code{start}. For example, you can do this in @code{irb}:
|
759
742
|
@smallexample
|
760
743
|
$ @b{irb}
|
761
744
|
irb(main):001:0> @b{require 'byebug'}
|
@@ -776,66 +759,53 @@ irb(main):006:0> @b{Byebug.start@{byebug; foo@}}
|
|
776
759
|
(byebug:1) @b{s}
|
777
760
|
foo
|
778
761
|
=> true
|
779
|
-
irb(main):007:0>
|
762
|
+
irb(main):007:0>
|
780
763
|
@end smallexample
|
781
764
|
|
782
|
-
There is a counter inside of @code{Byebug.start} method to make sure
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
765
|
+
There is a counter inside of @code{Byebug.start} method to make sure that this
|
766
|
+
works when another @code{Byebug.start} method is called inside of the outer one.
|
767
|
+
However if you are stopped inside byebug, issuing another @code{byebug} call
|
768
|
+
will not have any effect even if it is nested inside another
|
769
|
+
@code{Byebug.start}.
|
787
770
|
|
788
771
|
@node Debugging Oddities
|
789
|
-
@section How debugging Ruby may be different
|
790
|
-
|
791
|
-
If you are used to debugging in other languages like C, C++, Perl,
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
those other languages
|
798
|
-
those other languages, writing a byebug has to also be a little
|
772
|
+
@section How debugging Ruby may be different from debugging other languages
|
773
|
+
|
774
|
+
If you are used to debugging in other languages like C, C++, Perl, Java or even
|
775
|
+
Bash@footnote{this is just an excuse to put in a shameless plug for this bash
|
776
|
+
debugger @url{http://bashdb.sf.net}}, there may be a number of things that seem
|
777
|
+
or feel a little bit different and may confuse you. A number of these things
|
778
|
+
aren't oddities of the debugger per se, so much as a difference in how Ruby
|
779
|
+
works compared to those other languages. Because Ruby works a little differently
|
780
|
+
from those other languages, writing a debugger has to also be a little
|
799
781
|
different as well if it is to be useful.
|
800
782
|
|
801
|
-
In this respect, using byebug may help you understand Ruby
|
802
|
-
better.
|
783
|
+
In this respect, using byebug may help you understand Ruby better.
|
803
784
|
|
804
|
-
We've already seen two examples of such differences. One difference is
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
C++ generally you have to ask the compiler to add such information.}
|
785
|
+
We've already seen two examples of such differences. One difference is the fact
|
786
|
+
that we stop on method definitions or @code{def}'s and that is because these are
|
787
|
+
in fact executable statements. In other compiled languages this would not happen
|
788
|
+
because that's already been done when you compile the program (or in Perl when
|
789
|
+
it scans in the program). The other difference we saw was our inability to show
|
790
|
+
call stack parameter types without having made arrangements for byebug to track
|
791
|
+
this. In other languages call stack information is usually available without
|
792
|
+
asking assistance of the debugger@footnote{However in C and C++ you generally
|
793
|
+
have to ask the compiler to add such information.}.
|
814
794
|
|
815
|
-
In this section we'll consider some other things that might throw
|
816
|
-
|
817
|
-
debugging in them.
|
795
|
+
In this section we'll consider some other things that might throw off new users
|
796
|
+
to Ruby who are familiar with other languages and debugging in them.
|
818
797
|
|
819
798
|
@menu
|
820
|
-
* Stack No Longer Shows Scope Nesting::
|
821
799
|
* Bouncing Around in Blocks (e.g. Iterators)::
|
822
800
|
* No Parameter Values in a Call Stack::
|
823
801
|
* Lines You Can Stop At::
|
824
802
|
@end menu
|
825
803
|
|
826
|
-
@node Stack No Longer Shows Scope Nesting
|
827
|
-
@subsection Stack No Longer Shows Scope Nesting
|
828
|
-
In the Ruby 1.8 byebug, backtraces will show more stack frames
|
829
|
-
that you might find in other languages, such as C. In the Ruby 1.9
|
830
|
-
byebug, this is no longer the case.
|
831
|
-
|
832
804
|
@node Bouncing Around in Blocks (e.g. Iterators)
|
833
805
|
@subsection Bouncing Around in Blocks (e.g.@: Iterators)
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
method header. It's possible the call will continue after a
|
838
|
-
@code{yield} statement from a prior call.
|
806
|
+
When debugging languages with coroutines like Python and Ruby, a method call may
|
807
|
+
not necessarily go to the first statement after the method header. It's possible
|
808
|
+
that the call will continue after a @code{yield} statement from a prior call.
|
839
809
|
|
840
810
|
@smallexample
|
841
811
|
1 #!/usr/bin/env ruby
|
@@ -854,7 +824,7 @@ method header. It's possible the call will continue after a
|
|
854
824
|
14 end
|
855
825
|
15 unless not_prime
|
856
826
|
16 @@@@odd_primes << candidate
|
857
|
-
17 yield candidate
|
827
|
+
17 yield candidate
|
858
828
|
18 end
|
859
829
|
19 candidate += 2
|
860
830
|
20 end
|
@@ -885,60 +855,55 @@ Tracing(1):primes.rb:8 not_prime = false
|
|
885
855
|
Tracing(1):primes.rb:9 candidate += 1
|
886
856
|
primes.rb:9
|
887
857
|
candidate += 1
|
888
|
-
(byebug:1)
|
858
|
+
(byebug:1)
|
889
859
|
@end smallexample
|
890
860
|
|
891
861
|
The loop between lines 23--26 gets interleaved between those of
|
892
|
-
@code{Sieve::next_prime}, lines 6--19 above.
|
862
|
+
@code{Sieve::next_prime}, lines 6--19 above.
|
893
863
|
|
894
|
-
A similar kind of thing can occur
|
864
|
+
A similar kind of thing can occur when debugging programs with many threads.
|
895
865
|
|
896
866
|
@node No Parameter Values in a Call Stack
|
897
867
|
@subsection No Parameter Values in a Call Stack
|
898
|
-
In traditional
|
899
|
-
|
900
|
-
|
901
|
-
Ruby is a very dynamic language and it tries to be efficient within
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
change.
|
868
|
+
In traditional debuggers, in a call stack you can generally see the names of the
|
869
|
+
parameters and the values that were passed in.
|
870
|
+
|
871
|
+
Ruby is a very dynamic language and it tries to be efficient within the confines
|
872
|
+
of the language definition. Values generally aren't taken out of a variable or
|
873
|
+
expression and pushed onto a stack. Instead a new scope created and the
|
874
|
+
parameters are given initial values. Parameter passing is by @emph{reference},
|
875
|
+
not by value as it is say Algol, C, or Perl. During the execution of a method,
|
876
|
+
parameter values can change---and often do. In fact even the @emph{class} of the
|
877
|
+
object can change.
|
909
878
|
|
910
879
|
So at present, the name of the parameter shown. The call-style setting
|
911
|
-
@pxref{Callstyle} can be used to set whether the name is shown or the
|
912
|
-
|
880
|
+
@pxref{Callstyle} can be used to set whether the name is shown or the name and
|
881
|
+
the @emph{current} class of the object.
|
913
882
|
|
914
|
-
It has been contemplated that a style might be added which saves on
|
915
|
-
|
883
|
+
It has been contemplated that a style might be added which saves on call shorter
|
884
|
+
``scalar'' types of values and the class name.
|
916
885
|
|
917
886
|
@node Lines You Can Stop At
|
918
887
|
@subsection Lines You Can Stop At
|
919
|
-
As with the duplicate stops per control (e.g.@: @code{if} statement),
|
920
|
-
|
921
|
-
|
922
|
-
|
923
|
-
stop at.
|
888
|
+
As with the duplicate stops per control (e.g.@: @code{if} statement), until
|
889
|
+
tools like byebugs get more traction among core ruby developers there are going
|
890
|
+
to be weirdness. Here we describe the stopping locations which effects the
|
891
|
+
breakpoint line numbers you can stop at.
|
924
892
|
|
925
893
|
Consider the following little Ruby program.
|
926
|
-
|
927
894
|
@smallexample
|
928
895
|
'Yes it does' =~ /
|
929
896
|
(Yes) \s+
|
930
897
|
it \s+
|
931
898
|
does
|
932
|
-
/ix
|
899
|
+
/ix
|
933
900
|
puts $1
|
934
901
|
@end smallexample
|
935
902
|
|
936
|
-
The stopping points that Ruby records are the last two lines, lines 5
|
937
|
-
and 6.
|
903
|
+
The stopping points that Ruby records are the last two lines, lines 5 and 6.
|
938
904
|
|
939
|
-
Inside @code{byebug} you
|
940
|
-
|
941
|
-
@code{breakpoints}.
|
905
|
+
Inside @code{byebug} you can get a list of stoppable lines for a file using the
|
906
|
+
@code{info file} command with the attribute @code{breakpoints}.
|
942
907
|
|
943
908
|
@ifset FINISHED
|
944
909
|
To be continued...
|
@@ -957,14 +922,14 @@ To be continued...
|
|
957
922
|
@chapter Getting in and out
|
958
923
|
|
959
924
|
@menu
|
960
|
-
* Starting byebug::
|
961
|
-
* Command Files::
|
962
|
-
* Quitting byebug::
|
963
|
-
* Calling from Program::
|
925
|
+
* Starting byebug:: How to enter byebug
|
926
|
+
* Command Files:: Command files
|
927
|
+
* Quitting byebug:: How to leave byebug (quit, kill)
|
928
|
+
* Calling from Program:: Calling byebug from inside your program
|
964
929
|
@end menu
|
965
930
|
|
966
931
|
It is also possible to enter byebug when you have an uncaught
|
967
|
-
exception. See See also @ref{Post-Mortem Debugging}.
|
932
|
+
exception. See See also @ref{Post-Mortem Debugging}.
|
968
933
|
|
969
934
|
@node Starting byebug
|
970
935
|
@section Starting byebug
|
@@ -1007,10 +972,10 @@ Options:
|
|
1007
972
|
--no-quit Do not quit when script finishes
|
1008
973
|
--no-rewrite-program Do not set $0 to the program being debugged
|
1009
974
|
--no-stop Do not stop when script is loaded
|
1010
|
-
-nx Not run byebug initialization files (e.g. .byebugrc
|
975
|
+
-nx Not run byebug initialization files (e.g. .byebugrc
|
1011
976
|
-p, --port PORT Port used for remote debugging
|
1012
977
|
-r, --require SCRIPT Require the library, before executing your script
|
1013
|
-
--restart-script FILE Name of the script file to run. Erased after read
|
978
|
+
--restart-script FILE Name of the script file to run. Erased after read
|
1014
979
|
--script FILE Name of the script file to run
|
1015
980
|
-s, --server Listen for remote connections
|
1016
981
|
-w, --wait Wait for a client connection, implies -s option
|
@@ -1023,7 +988,7 @@ Common options:
|
|
1023
988
|
-v Print version number, then turn on verbose mode
|
1024
989
|
@end smallexample
|
1025
990
|
|
1026
|
-
Options for the @code{byebug} are shown in the following list.
|
991
|
+
Options for the @code{byebug} are shown in the following list.
|
1027
992
|
|
1028
993
|
@menu
|
1029
994
|
* byebug command-line options:: Options you can pass to byebug
|
@@ -1036,7 +1001,7 @@ Options for the @code{byebug} are shown in the following list.
|
|
1036
1001
|
You can run @DBG{} in various alternative modes---for example, as a
|
1037
1002
|
program that interacts directly with the program in the same process
|
1038
1003
|
on the same computer or via a socket to another process possibly on a
|
1039
|
-
different computer.
|
1004
|
+
different computer.
|
1040
1005
|
|
1041
1006
|
Many options appear as a long option name, such as @option{--help}, and
|
1042
1007
|
a short one letter option name, such as @option{-h}. A double dash
|
@@ -1068,7 +1033,7 @@ having to poll for it.
|
|
1068
1033
|
@cindex @option{--client}
|
1069
1034
|
Connect to remote byebug. The remote byebug should have been set
|
1070
1035
|
up previously our you will get a connection error and @code{byebug}
|
1071
|
-
will terminate.
|
1036
|
+
will terminate.
|
1072
1037
|
|
1073
1038
|
@item --cport @var{port}
|
1074
1039
|
@cindex @option{--cport} @var{port}
|
@@ -1081,13 +1046,13 @@ Ruby's.
|
|
1081
1046
|
|
1082
1047
|
@item --emacs
|
1083
1048
|
Activates GNU Emacs mode.
|
1084
|
-
@c @pxref{GNU Emacs}.
|
1049
|
+
@c @pxref{GNU Emacs}.
|
1085
1050
|
Byebug output is tagged in such a way to allow GNU Emacs to track
|
1086
1051
|
where you are in the code.
|
1087
1052
|
|
1088
1053
|
@item --emacs-basic
|
1089
1054
|
Activates full GNU Emacs mode.
|
1090
|
-
@c (@pxref{GNU Emacs}).
|
1055
|
+
@c (@pxref{GNU Emacs}).
|
1091
1056
|
This is the equivalent of setting the options @option{--emacs-basic},
|
1092
1057
|
@code{annotate=3}, @option{--no-stop}, @option{-no-control} and
|
1093
1058
|
@option{--post-mortem}.
|
@@ -1119,7 +1084,7 @@ and module name resolution.
|
|
1119
1084
|
However it's still possible to restore the old, slower behavior by
|
1120
1085
|
using this option or by setting @code{Byebug.keep_frame_binding =
|
1121
1086
|
true}. There are two possibilities for which you might want to use
|
1122
|
-
this option.
|
1087
|
+
this option.
|
1123
1088
|
|
1124
1089
|
First, if you think there's a bug in the evaluation of variables, you
|
1125
1090
|
might want to set this to see if this corrects things.
|
@@ -1137,8 +1102,8 @@ is partly why this byebug doesn't work on Ruby 1.9.
|
|
1137
1102
|
@cindex @option{--post-mortem}
|
1138
1103
|
If your program raises an exception that isn't caught you can enter
|
1139
1104
|
byebug for inspection of what went wrong. You may also want to
|
1140
|
-
use this option in conjunction with @option{--no-stop}. See also
|
1141
|
-
@ref{Post-Mortem Debugging}.
|
1105
|
+
use this option in conjunction with @option{--no-stop}. See also
|
1106
|
+
@ref{Post-Mortem Debugging}.
|
1142
1107
|
|
1143
1108
|
@item --no-control
|
1144
1109
|
@cindex @option{--no-control}
|
@@ -1201,14 +1166,14 @@ If all you want to do however is get a linetrace, @code{tracer}, not
|
|
1201
1166
|
@smallexample
|
1202
1167
|
$ @b{time ruby -rtracer gcd.rb 34 21 > /dev/null}
|
1203
1168
|
|
1204
|
-
real
|
1205
|
-
user
|
1206
|
-
sys
|
1169
|
+
real 0m0.266s
|
1170
|
+
user 0m0.008s
|
1171
|
+
sys 0m0.000s
|
1207
1172
|
$ @b{time byebug --trace gcd.rb 34 21 > /dev/null}
|
1208
1173
|
|
1209
|
-
real
|
1210
|
-
user
|
1211
|
-
sys
|
1174
|
+
real 0m0.875s
|
1175
|
+
user 0m0.448s
|
1176
|
+
sys 0m0.056s
|
1212
1177
|
$
|
1213
1178
|
@end smallexample
|
1214
1179
|
|
@@ -1223,7 +1188,7 @@ people may want @option{--no-quit --no-control} to be the default
|
|
1223
1188
|
behavior. One could write a wrapper script or set a shell alias to
|
1224
1189
|
handle this. @DBG{} has another way to do this as well. Before
|
1225
1190
|
processing command options if the file @code{$HOME/.rdboptrc} is found
|
1226
|
-
(or, on Windows, @code{$HOME/rdbopt.ini}, it is loaded.
|
1191
|
+
(or, on Windows, @code{$HOME/rdbopt.ini}, it is loaded.
|
1227
1192
|
If you want to set the defaults in some other way, you
|
1228
1193
|
can put Ruby code here and set variable @code{options} which is an
|
1229
1194
|
OpenStruct. For example here's how you'd set @option{-no-quit} and
|
@@ -1272,7 +1237,7 @@ Processes command line options and operands.
|
|
1272
1237
|
@item
|
1273
1238
|
Reads the init file in your current directory, if any, and failing
|
1274
1239
|
that the home directory. The home directory is the directory named in
|
1275
|
-
the @code{HOME} or @code{HOMEPATH} environment variable.
|
1240
|
+
the @code{HOME} or @code{HOMEPATH} environment variable.
|
1276
1241
|
|
1277
1242
|
Thus, you can have more than one init file, one generic in your home
|
1278
1243
|
directory, and another, specific to the program you are debugging, in
|
@@ -1323,13 +1288,13 @@ at the same speed as if there were no byebug.
|
|
1323
1288
|
There are three parts to calling byebug from inside the script,
|
1324
1289
|
``requiring'' byebug code, telling byebug to start
|
1325
1290
|
tracking things and then making the call calling byebug to
|
1326
|
-
stop.
|
1291
|
+
stop.
|
1327
1292
|
|
1328
1293
|
To get byebug class accessible from your Ruby program:
|
1329
1294
|
|
1330
1295
|
@smallexample
|
1331
1296
|
require 'byebug'
|
1332
|
-
@end smallexample
|
1297
|
+
@end smallexample
|
1333
1298
|
After @code{require 'byebug'}, it's possible to set some of the
|
1334
1299
|
byebug variables influence preferences. For example if you want to
|
1335
1300
|
have @ttDBG run a @code{list} command every time it stops you set the
|
@@ -1342,7 +1307,7 @@ To tell byebug to start tracking things:
|
|
1342
1307
|
|
1343
1308
|
@smallexample
|
1344
1309
|
Byebug.start
|
1345
|
-
@end smallexample
|
1310
|
+
@end smallexample
|
1346
1311
|
|
1347
1312
|
There is also a @code{Byebug.stop} to turn off byebug tracking. If
|
1348
1313
|
speed is crucial, you may want to start and stop this around certain
|
@@ -1356,7 +1321,7 @@ And finally to enter byebug:
|
|
1356
1321
|
|
1357
1322
|
@smallexample
|
1358
1323
|
byebug
|
1359
|
-
@end smallexample
|
1324
|
+
@end smallexample
|
1360
1325
|
|
1361
1326
|
As indicated above, when @code{byebug} is run a @code{.byebugrc}
|
1362
1327
|
profile is read if that file exists.
|
@@ -1367,14 +1332,14 @@ where there is a problem you want to investigate. And since
|
|
1367
1332
|
conditional expression, for example:
|
1368
1333
|
@smallexample
|
1369
1334
|
byebug if 'bar' == foo and 20 == iter_count
|
1370
|
-
@end smallexample
|
1335
|
+
@end smallexample
|
1371
1336
|
|
1372
1337
|
Although each step does a very specific thing which offers great
|
1373
1338
|
flexibility, in order to make getting into byebug easier the
|
1374
1339
|
three steps have been rolled into one command:
|
1375
1340
|
@smallexample
|
1376
1341
|
require "byebug/byebug"
|
1377
|
-
@end smallexample
|
1342
|
+
@end smallexample
|
1378
1343
|
|
1379
1344
|
@node Byebug Command Reference
|
1380
1345
|
@chapter @code{byebug} Command Reference
|
@@ -1426,7 +1391,7 @@ arguments. Some commands do not allow any arguments.
|
|
1426
1391
|
|
1427
1392
|
Multiple commands can be put on a line by separating each with a
|
1428
1393
|
semicolon (@code{;}). You can disable the meaning of a semicolon to
|
1429
|
-
separate commands by escaping it with a backslash.
|
1394
|
+
separate commands by escaping it with a backslash.
|
1430
1395
|
|
1431
1396
|
For example, if you have @code{autoeval} (@ref{Autoeval}) set, you
|
1432
1397
|
might want to enter the following code to compute the 5th Fibonacci
|
@@ -1449,7 +1414,7 @@ You might also consider using the @code{irb} command, @ref{irb}, and
|
|
1449
1414
|
then you won't have to escape semicolons.
|
1450
1415
|
|
1451
1416
|
A blank line as input (typing just @key{<RET>}) means to repeat the
|
1452
|
-
previous command.
|
1417
|
+
previous command.
|
1453
1418
|
|
1454
1419
|
In the ``local'' interface, the Ruby Readline module is used. It
|
1455
1420
|
handles line editing and retrieval of previous commands. Up arrow, for
|
@@ -1500,16 +1465,16 @@ byebug help v@value{BYEBUG_VERSION}
|
|
1500
1465
|
Type 'help <command-name>' for help on a specific command
|
1501
1466
|
|
1502
1467
|
Available commands:
|
1503
|
-
backtrace delete enable help list ps save thread where
|
1504
|
-
break disable eval info method putl set trace
|
1505
|
-
catch display exit irb next quit show undisplay
|
1506
|
-
condition down finish jump p reload source up
|
1468
|
+
backtrace delete enable help list ps save thread where
|
1469
|
+
break disable eval info method putl set trace
|
1470
|
+
catch display exit irb next quit show undisplay
|
1471
|
+
condition down finish jump p reload source up
|
1507
1472
|
continue edit frame kill pp restart step var
|
1508
1473
|
@end smallexample
|
1509
1474
|
@end flushleft
|
1510
1475
|
@c the above line break eliminates huge line overfull...
|
1511
1476
|
|
1512
|
-
@end table
|
1477
|
+
@end table
|
1513
1478
|
|
1514
1479
|
@table @code
|
1515
1480
|
@item help @var{command}
|
@@ -1519,10 +1484,10 @@ information on how to use that command.
|
|
1519
1484
|
@smallexample
|
1520
1485
|
(byebug:1) @b{help list}
|
1521
1486
|
byebug help v@value{BYEBUG_VERSION}
|
1522
|
-
l[ist]
|
1523
|
-
l[ist] -
|
1524
|
-
l[ist] =
|
1525
|
-
l[ist] nn-mm
|
1487
|
+
l[ist] list forward
|
1488
|
+
l[ist] - list backward
|
1489
|
+
l[ist] = list current line
|
1490
|
+
l[ist] nn-mm list given lines
|
1526
1491
|
* NOTE - to turn on autolist, use 'set autolist'
|
1527
1492
|
(byebug:1)
|
1528
1493
|
@end smallexample
|
@@ -1546,9 +1511,9 @@ Some examples follow.
|
|
1546
1511
|
@example
|
1547
1512
|
(byebug:1) @b{help info}
|
1548
1513
|
Generic command for showing things about the program being debugged.
|
1549
|
-
--
|
1514
|
+
--
|
1550
1515
|
List of info subcommands:
|
1551
|
-
--
|
1516
|
+
--
|
1552
1517
|
info args -- Argument variables of current stack frame
|
1553
1518
|
info breakpoints -- Status of user-settable breakpoints
|
1554
1519
|
info catch -- Exceptions that can be caught in the current stack frame
|
@@ -1616,7 +1581,7 @@ questions asked, enter the ``unconditionally''.
|
|
1616
1581
|
@kindex restart @r{[}@var{program args}@r{]}
|
1617
1582
|
@kindex R @r{(@code{restart})}
|
1618
1583
|
@item restart
|
1619
|
-
@itemx R
|
1584
|
+
@itemx R
|
1620
1585
|
|
1621
1586
|
Restart the program. This is a re-exec - all byebug state is
|
1622
1587
|
lost. If command arguments are passed those are used. Otherwise the
|
@@ -1625,7 +1590,7 @@ last program arguments used in the last invocation are used.
|
|
1625
1590
|
In not all cases will you be able to restart the program. First, the
|
1626
1591
|
program should have been invoked at the outset rather than having been
|
1627
1592
|
called from inside your program or invoked as a result of post-mortem
|
1628
|
-
handling.
|
1593
|
+
handling.
|
1629
1594
|
|
1630
1595
|
Also, since this relies on the the OS @code{exec} call, this command
|
1631
1596
|
is available only if your OS supports that @code{exec}; OSX for
|
@@ -1674,7 +1639,7 @@ automatic display looks like this:
|
|
1674
1639
|
@end smallexample
|
1675
1640
|
|
1676
1641
|
@noindent
|
1677
|
-
This display shows item numbers, expressions and their current values.
|
1642
|
+
This display shows item numbers, expressions and their current values.
|
1678
1643
|
If the expression is undefined or illegal the expression will be
|
1679
1644
|
printed but no value will appear.
|
1680
1645
|
|
@@ -1682,7 +1647,7 @@ printed but no value will appear.
|
|
1682
1647
|
(byebug:1) display undefined_variable
|
1683
1648
|
2: undefined_variable =
|
1684
1649
|
(byebug:1) display 1/0
|
1685
|
-
3: 1/0 =
|
1650
|
+
3: 1/0 =
|
1686
1651
|
@end smallexample
|
1687
1652
|
|
1688
1653
|
Note: this command uses @code{to_s} to in expressions; for example an
|
@@ -1699,7 +1664,7 @@ on (@pxref{DisplayCommands}).
|
|
1699
1664
|
|
1700
1665
|
@item display
|
1701
1666
|
Display the current values of the expressions on the list, just as is
|
1702
|
-
done when your program stops.
|
1667
|
+
done when your program stops.
|
1703
1668
|
|
1704
1669
|
@kindex undisplay @ovar{num}
|
1705
1670
|
@item undisplay @ovar{num}
|
@@ -1747,7 +1712,7 @@ does in @code{irb}.
|
|
1747
1712
|
@node eval
|
1748
1713
|
@subsection Printing an expression (@samp{eval}, @samp{p})
|
1749
1714
|
@table @code
|
1750
|
-
@kindex eval @var{expr}
|
1715
|
+
@kindex eval @var{expr}
|
1751
1716
|
@kindex p @r{(@code{eval})}
|
1752
1717
|
@item eval @var{expr}
|
1753
1718
|
@itemx p @var{expr}
|
@@ -1796,8 +1761,8 @@ list looks nicer:
|
|
1796
1761
|
@end smallexample
|
1797
1762
|
|
1798
1763
|
Note however that entries are sorted to run down first rather than
|
1799
|
-
across. So in the example above the second entry in the list is
|
1800
|
-
@code{/usr/lib/ruby/site_ruby/1.8/i586-linux} and the @emph{third} entry is
|
1764
|
+
across. So in the example above the second entry in the list is
|
1765
|
+
@code{/usr/lib/ruby/site_ruby/1.8/i586-linux} and the @emph{third} entry is
|
1801
1766
|
@code{/usr/lib/ruby/site_ruby/1.8}.
|
1802
1767
|
|
1803
1768
|
If the value is not an array @code{putl} will just call pretty-print.
|
@@ -1811,24 +1776,24 @@ and so does the output of the @code{method} commands.
|
|
1811
1776
|
@group
|
1812
1777
|
(byebug:1) ps Kernel.private_methods
|
1813
1778
|
Digest initialize y
|
1814
|
-
Pathname initialize_copy
|
1815
|
-
Rational location_of_caller
|
1816
|
-
active_gem_with_options method_added
|
1817
|
-
alias_method method_removed
|
1818
|
-
append_features method_undefined
|
1819
|
-
attr module_function
|
1820
|
-
attr_accessor private
|
1821
|
-
attr_reader protected
|
1822
|
-
attr_writer public
|
1823
|
-
class_variable_get remove_class_variable
|
1824
|
-
class_variable_set remove_const
|
1825
|
-
define_method remove_instance_variable
|
1826
|
-
extend_object remove_method
|
1827
|
-
extended singleton_method_added
|
1828
|
-
gcd singleton_method_removed
|
1779
|
+
Pathname initialize_copy
|
1780
|
+
Rational location_of_caller
|
1781
|
+
active_gem_with_options method_added
|
1782
|
+
alias_method method_removed
|
1783
|
+
append_features method_undefined
|
1784
|
+
attr module_function
|
1785
|
+
attr_accessor private
|
1786
|
+
attr_reader protected
|
1787
|
+
attr_writer public
|
1788
|
+
class_variable_get remove_class_variable
|
1789
|
+
class_variable_set remove_const
|
1790
|
+
define_method remove_instance_variable
|
1791
|
+
extend_object remove_method
|
1792
|
+
extended singleton_method_added
|
1793
|
+
gcd singleton_method_removed
|
1829
1794
|
gem_original_require singleton_method_undefined
|
1830
|
-
include timeout
|
1831
|
-
included undef_method
|
1795
|
+
include timeout
|
1796
|
+
included undef_method
|
1832
1797
|
@end group
|
1833
1798
|
@end smallexample
|
1834
1799
|
|
@@ -1839,7 +1804,7 @@ See also the @code{methods}.
|
|
1839
1804
|
@node irb
|
1840
1805
|
@subsection Run irb (@samp{irb})
|
1841
1806
|
@table @code
|
1842
|
-
@kindex irb
|
1807
|
+
@kindex irb
|
1843
1808
|
@item irb
|
1844
1809
|
Run an interactive ruby session (@code{irb}) with the bindings
|
1845
1810
|
environment set to the state you are in the program.
|
@@ -1915,17 +1880,17 @@ Show methods of @var{object}. Basically this is the same as running
|
|
1915
1880
|
@kindex method iv @var{object}
|
1916
1881
|
Show method instance variables of @var{object}. Basically this is the same as running
|
1917
1882
|
@smallexample
|
1918
|
-
obj.instance_variables.each do |v|
|
1883
|
+
obj.instance_variables.each do |v|
|
1919
1884
|
puts "%s = %s\n" % [v, obj.instance_variable_get(v)]
|
1920
|
-
end
|
1885
|
+
end
|
1921
1886
|
@end smallexample
|
1922
1887
|
on @var{object}.
|
1923
1888
|
@item signature @var{object}
|
1924
1889
|
@kindex method signature @var{object}
|
1925
|
-
Show procedure signature of method @var{object}.
|
1890
|
+
Show procedure signature of method @var{object}.
|
1926
1891
|
@emph{This command is available only if the nodewrap is installed.}
|
1927
1892
|
@smallexample
|
1928
|
-
def mymethod(a, b=5, &bock)
|
1893
|
+
def mymethod(a, b=5, &bock)
|
1929
1894
|
end
|
1930
1895
|
(byebug:1) @b{method sig mymethod}
|
1931
1896
|
Mine#mymethod(a, b=5, &bock)
|
@@ -1955,7 +1920,7 @@ You can print other portions of source files by giving an explicit
|
|
1955
1920
|
position as a parameter to the list command.
|
1956
1921
|
|
1957
1922
|
If you use @value{DBG} through its Emacs interface, you may prefer to
|
1958
|
-
use Emacs facilities to view source.
|
1923
|
+
use Emacs facilities to view source.
|
1959
1924
|
@c @pxref{GNU Emacs}.
|
1960
1925
|
|
1961
1926
|
@kindex list @ovar{line-number}
|
@@ -2126,8 +2091,8 @@ frame numbers shown. The position of the current frame is marked with
|
|
2126
2091
|
|
2127
2092
|
@smallexample
|
2128
2093
|
(byebug:1) where
|
2129
|
-
--> #0 Object.gcd(a#Fixnum, b#Fixnum) at
|
2130
|
-
#1 at
|
2094
|
+
--> #0 Object.gcd(a#Fixnum, b#Fixnum) at /tmp/gcd.rb:6
|
2095
|
+
#1 at /tmp/gcd.rb:19
|
2131
2096
|
@end smallexample
|
2132
2097
|
|
2133
2098
|
@ifset FINISHED
|
@@ -2162,7 +2127,7 @@ frames that have existed longer. Using a negative @var{n} is the same thing
|
|
2162
2127
|
as issuing a @code{down} command of the absolute value of the @var{n}.
|
2163
2128
|
Using zero for @var{n} does no frame adjustment, but since the current
|
2164
2129
|
position is redisplayed, it may trigger a resynchronization if there is
|
2165
|
-
a front end also watching over things.
|
2130
|
+
a front end also watching over things.
|
2166
2131
|
|
2167
2132
|
@var{n} defaults to one. You may abbreviate @code{up} as @code{u}.
|
2168
2133
|
|
@@ -2174,7 +2139,7 @@ that were created more recently. Using a negative @var{n} is the same
|
|
2174
2139
|
as issuing a @code{up} command of the absolute value of the @var{n}.
|
2175
2140
|
Using zero for @var{n} does no frame adjustment, but since the current
|
2176
2141
|
position is redisplayed, it may trigger a resynchronization if there is
|
2177
|
-
a front end also watching over things.
|
2142
|
+
a front end also watching over things.
|
2178
2143
|
|
2179
2144
|
@var{n} defaults to one.
|
2180
2145
|
@end table
|
@@ -2195,10 +2160,10 @@ most ``main'' stack frame.
|
|
2195
2160
|
Without an argument, @code{frame} prints the current stack
|
2196
2161
|
frame. Since the current position is redisplayed, it may trigger a
|
2197
2162
|
resynchronization if there is a front end also watching over
|
2198
|
-
things.
|
2163
|
+
things.
|
2199
2164
|
|
2200
2165
|
If a thread number is given then we set the context for evaluating
|
2201
|
-
expressions to that frame of that thread.
|
2166
|
+
expressions to that frame of that thread.
|
2202
2167
|
@end table
|
2203
2168
|
|
2204
2169
|
@node Stopping
|
@@ -2229,7 +2194,7 @@ remove old ones, and then continue execution.
|
|
2229
2194
|
@cindex breakpoints
|
2230
2195
|
A @dfn{breakpoint} makes your script stop whenever a certain point in
|
2231
2196
|
the program is reached. For each breakpoint, you can add conditions to
|
2232
|
-
control in finer detail whether your script stops.
|
2197
|
+
control in finer detail whether your script stops.
|
2233
2198
|
|
2234
2199
|
You specify the place where your script should stop with the
|
2235
2200
|
@code{break} command and its variants.
|
@@ -2296,7 +2261,7 @@ specified here. If the method you want to stop in is in the main class
|
|
2296
2261
|
program), then use the name @code{Object}.
|
2297
2262
|
|
2298
2263
|
@kindex catch @ovar{exception} @r{[} on | 1 | off | 0 @r{]}
|
2299
|
-
@kindex cat @r{(@code{catch})}
|
2264
|
+
@kindex cat @r{(@code{catch})}
|
2300
2265
|
@item catch @ovar{exception} @r{[} on | 1 | off | 0 @r{]}
|
2301
2266
|
Set catchpoint to an exception. Without an exception name show catchpoints.
|
2302
2267
|
|
@@ -2307,7 +2272,7 @@ off. To delete all exceptions type ``catch off''.
|
|
2307
2272
|
@kindex delete @ovar{breakpoints}
|
2308
2273
|
@kindex del @r{(@code{delete})}
|
2309
2274
|
@item delete @ovar{breakpoints}
|
2310
|
-
Delete the breakpoints specified as arguments.
|
2275
|
+
Delete the breakpoints specified as arguments.
|
2311
2276
|
|
2312
2277
|
If no argument is specified, delete all breakpoints (@DBG asks
|
2313
2278
|
confirmation. You can abbreviate this command as @code{del}.
|
@@ -2406,7 +2371,7 @@ the state of your other breakpoints; see @ref{Resuming Execution}.)
|
|
2406
2371
|
|
2407
2372
|
The simplest sort of breakpoint breaks every time your script reaches
|
2408
2373
|
a specified place. You can also specify a @dfn{condition} for a
|
2409
|
-
breakpoint. A condition is just a Ruby expression.
|
2374
|
+
breakpoint. A condition is just a Ruby expression.
|
2410
2375
|
|
2411
2376
|
Break conditions can be specified when a breakpoint is set, by using
|
2412
2377
|
@samp{if} in the arguments to the @code{break} command. A breakpoint
|
@@ -2561,7 +2526,7 @@ If you want instead to terminate the program and byebug entirely, use
|
|
2561
2526
|
@item continue @ovar{line-specification}
|
2562
2527
|
@itemx c @ovar{line-specification}
|
2563
2528
|
Resume program execution, at the address where your script last
|
2564
|
-
stopped; any breakpoints set at that address are bypassed.
|
2529
|
+
stopped; any breakpoints set at that address are bypassed.
|
2565
2530
|
|
2566
2531
|
The optional argument @var{line-specification} allows you to specify a
|
2567
2532
|
line number to set a one-time breakpoint which is deleted when that
|
@@ -2585,7 +2550,7 @@ Change the next line to execute to the given line number.
|
|
2585
2550
|
@section byebug settings (@samp{set args}, @samp{set autoeval}..)
|
2586
2551
|
|
2587
2552
|
You can alter the way byebug interacts with you using @code{set}
|
2588
|
-
commands.
|
2553
|
+
commands.
|
2589
2554
|
|
2590
2555
|
The various parameters to @code{set} are given below. Each parameter
|
2591
2556
|
name needs to to be only enough to make it unique. For example
|
@@ -2668,7 +2633,7 @@ autoeval is on.
|
|
2668
2633
|
NameError Exception: undefined local variable or method `stepp' for ...
|
2669
2634
|
@end smallexample
|
2670
2635
|
|
2671
|
-
@kindex show autoeval
|
2636
|
+
@kindex show autoeval
|
2672
2637
|
@item show args
|
2673
2638
|
Shows whether Ruby evaluation of byebug input should occur or not.
|
2674
2639
|
@end table
|
@@ -2728,12 +2693,12 @@ Shows the whether filename display shows just the file basename or not.
|
|
2728
2693
|
@kindex set callstyle @r{[} short | last | tracked @r{]}
|
2729
2694
|
@item set forcestep @r{[} short | last | tracked @r{]}
|
2730
2695
|
@else
|
2731
|
-
@kindex set callstyle @r{[} short | last
|
2732
|
-
@item set forcestep @r{[} short | last
|
2696
|
+
@kindex set callstyle @r{[} short | last
|
2697
|
+
@item set forcestep @r{[} short | last
|
2733
2698
|
@end ifset
|
2734
2699
|
|
2735
2700
|
Sets how you want call parameters displayed; @code{short} shows just
|
2736
|
-
the parameter names;
|
2701
|
+
the parameter names;
|
2737
2702
|
@ifset FINISHED
|
2738
2703
|
@code{last} shows the parameter names and the
|
2739
2704
|
class of these variables as they currently exist. Note the type could
|
@@ -2742,7 +2707,7 @@ values.
|
|
2742
2707
|
@end ifset
|
2743
2708
|
@code{tracked} is the most accurate but this adds
|
2744
2709
|
overhead. On every call, scalar values of the parameters get
|
2745
|
-
saved. For non-scalar values the class is saved.
|
2710
|
+
saved. For non-scalar values the class is saved.
|
2746
2711
|
@end table
|
2747
2712
|
|
2748
2713
|
@node Forcestep
|
@@ -2755,7 +2720,7 @@ saved. For non-scalar values the class is saved.
|
|
2755
2720
|
Due to the interpretive, expression-oriented nature of the Ruby
|
2756
2721
|
Language and implementation, each line often contains many possible
|
2757
2722
|
stopping points, while in a byebug it is often desired to treat each
|
2758
|
-
line as an individual stepping unit.
|
2723
|
+
line as an individual stepping unit.
|
2759
2724
|
|
2760
2725
|
Setting forcestep on will cause each @code{step} or @code{next}
|
2761
2726
|
command to stop at a different line number. See also @ref{Step} and
|
@@ -2829,11 +2794,11 @@ Shows whether line tracing is in effect or not.
|
|
2829
2794
|
|
2830
2795
|
Setting linetrace+ on will cause consecutive trace lines not to be a
|
2831
2796
|
duplicate of the preceding line-trace line. Note however that this
|
2832
|
-
setting doesn't by itself turn on or off line tracing.
|
2797
|
+
setting doesn't by itself turn on or off line tracing.
|
2833
2798
|
|
2834
2799
|
@kindex show linetrace+
|
2835
2800
|
@item show linetrace
|
2836
|
-
Shows whether the line tracing style is to show all lines or remove
|
2801
|
+
Shows whether the line tracing style is to show all lines or remove
|
2837
2802
|
duplicates linetrace lines when it is a repeat of the previous line.
|
2838
2803
|
@end table
|
2839
2804
|
|
@@ -2867,7 +2832,7 @@ have the ability to change the state inside byebug.
|
|
2867
2832
|
@kindex set width @var{column-width}
|
2868
2833
|
@item set width @var{column-width}
|
2869
2834
|
Set number of characters byebug thinks are in a line.
|
2870
|
-
We also change OS environment variable @code{COLUMNS}.
|
2835
|
+
We also change OS environment variable @code{COLUMNS}.
|
2871
2836
|
@kindex show width
|
2872
2837
|
@item show width
|
2873
2838
|
Shows the current width setting.
|
@@ -2943,14 +2908,14 @@ an example:
|
|
2943
2908
|
|
2944
2909
|
@smallexample
|
2945
2910
|
(byebug:7) info threads
|
2946
|
-
1 #<Thread:0xb7d08704 sleep>
|
2947
|
-
!2 #<Byebug::DebugThread:0xb7782e4c sleep>
|
2948
|
-
3 #<Thread:0xb777e220 sleep>
|
2949
|
-
4 #<Thread:0xb777e144 sleep>
|
2950
|
-
5 #<Thread:0xb777e07c sleep>
|
2951
|
-
6 #<Thread:0xb777dfb4 sleep>
|
2952
|
-
+ 7 #<Thread:0xb777deec run>
|
2953
|
-
(byebug:1)
|
2911
|
+
1 #<Thread:0xb7d08704 sleep> ./test/thread1.rb:27
|
2912
|
+
!2 #<Byebug::DebugThread:0xb7782e4c sleep>
|
2913
|
+
3 #<Thread:0xb777e220 sleep> ./test/thread1.rb:11
|
2914
|
+
4 #<Thread:0xb777e144 sleep> ./test/thread1.rb:11
|
2915
|
+
5 #<Thread:0xb777e07c sleep> ./test/thread1.rb:11
|
2916
|
+
6 #<Thread:0xb777dfb4 sleep> ./test/thread1.rb:11
|
2917
|
+
+ 7 #<Thread:0xb777deec run> ./test/thread1.rb:14
|
2918
|
+
(byebug:1)
|
2954
2919
|
@end smallexample
|
2955
2920
|
|
2956
2921
|
Thread 7 is the current thread since it has a plus sign in front. Thread 2 is
|
@@ -2958,29 +2923,29 @@ ignored since it has a @code{!}. A ``verbose'' listing of the above:
|
|
2958
2923
|
|
2959
2924
|
@smallexample
|
2960
2925
|
(byebug:7) info threads verbose
|
2961
|
-
1 #<Thread:0xb7d08704 sleep>
|
2962
|
-
|
2963
|
-
|
2964
|
-
!2 #<Byebug::DebugThread:0xb7782e4c sleep>
|
2965
|
-
3 #<Thread:0xb777e220 sleep>
|
2966
|
-
|
2967
|
-
|
2968
|
-
|
2969
|
-
4 #<Thread:0xb777e144 sleep>
|
2970
|
-
|
2971
|
-
|
2972
|
-
|
2973
|
-
5 #<Thread:0xb777e07c sleep>
|
2974
|
-
|
2975
|
-
|
2976
|
-
|
2977
|
-
6 #<Thread:0xb777dfb4 sleep>
|
2978
|
-
|
2979
|
-
|
2980
|
-
|
2981
|
-
+ 7 #<Thread:0xb777deec run>
|
2982
|
-
|
2983
|
-
|
2926
|
+
1 #<Thread:0xb7d08704 sleep>
|
2927
|
+
#0 Integer.join at test/thread1.rb:27
|
2928
|
+
#1 at test/thread1.rb:27
|
2929
|
+
!2 #<Byebug::DebugThread:0xb7782e4c sleep>
|
2930
|
+
3 #<Thread:0xb777e220 sleep>
|
2931
|
+
#0 sleep(count#Fixnum) at test/thread1.rb:11
|
2932
|
+
#1 Object.fn(count#Fixnum, i#Fixnum) at test/thread1.rb:11
|
2933
|
+
#2 at test/thread1.rb:23
|
2934
|
+
4 #<Thread:0xb777e144 sleep>
|
2935
|
+
#0 sleep(count#Fixnum) at test/thread1.rb:11
|
2936
|
+
#1 Object.fn(count#Fixnum, i#Fixnum) at test/thread1.rb:11
|
2937
|
+
#2 at test/thread1.rb:23
|
2938
|
+
5 #<Thread:0xb777e07c sleep>
|
2939
|
+
#0 sleep(count#Fixnum) at test/thread1.rb:11
|
2940
|
+
#1 Object.fn(count#Fixnum, i#Fixnum) at test/thread1.rb:11
|
2941
|
+
#2 at test/thread1.rb:23
|
2942
|
+
6 #<Thread:0xb777dfb4 sleep>
|
2943
|
+
#0 sleep(count#Fixnum) at test/thread1.rb:11
|
2944
|
+
#1 Object.fn(count#Fixnum, i#Fixnum) at test/thread1.rb:11
|
2945
|
+
#2 at test/thread1.rb:23
|
2946
|
+
+ 7 #<Thread:0xb777deec run>
|
2947
|
+
#0 Object.fn(count#Fixnum, i#Fixnum) at test/thread1.rb:14
|
2948
|
+
#1 at test/thread1.rb:23
|
2984
2949
|
@end smallexample
|
2985
2950
|
|
2986
2951
|
@kindex info variables
|
@@ -3031,10 +2996,10 @@ post-mortem debugging set the @code{post_mortem} key in
|
|
3031
2996
|
t.rb:8: raise 'test'
|
3032
2997
|
(byebug:post-mortem) @b{l=}
|
3033
2998
|
[3, 12] in t.rb
|
3034
|
-
3
|
2999
|
+
3
|
3035
3000
|
4 Byebug.start
|
3036
3001
|
5 Byebug.post_mortem
|
3037
|
-
6
|
3002
|
+
6
|
3038
3003
|
7 def t1
|
3039
3004
|
=> 8 raise 'test'
|
3040
3005
|
9 end
|
@@ -3059,7 +3024,7 @@ can enable post-mortem mode by wrapping this block inside a
|
|
3059
3024
|
|
3060
3025
|
@smallexample
|
3061
3026
|
def offender
|
3062
|
-
1/0
|
3027
|
+
1/0
|
3063
3028
|
end
|
3064
3029
|
...
|
3065
3030
|
require "ruby-gems"
|
@@ -3069,7 +3034,7 @@ Byebug.post_mortem do
|
|
3069
3034
|
offender
|
3070
3035
|
...
|
3071
3036
|
end
|
3072
|
-
@end smallexample
|
3037
|
+
@end smallexample
|
3073
3038
|
|
3074
3039
|
Once inside byebug in post-mortem debugging, the prompt should
|
3075
3040
|
be @code{(byebug:post-mortem)}.
|
@@ -3087,9 +3052,9 @@ be @code{(byebug:post-mortem)}.
|
|
3087
3052
|
@section The Byebug Module
|
3088
3053
|
|
3089
3054
|
@menu
|
3090
|
-
* Byebug.run::
|
3055
|
+
* Byebug.run::
|
3091
3056
|
@ifset LATER
|
3092
|
-
* Byebug.post-mortem::
|
3057
|
+
* Byebug.post-mortem::
|
3093
3058
|
@end ifset
|
3094
3059
|
* Byebug.context::
|
3095
3060
|
* Byebug.settings::
|
@@ -3133,7 +3098,7 @@ method.
|
|
3133
3098
|
|
3134
3099
|
The first time Byebug.start is called there is also some additional
|
3135
3100
|
setup to make the @code{restart} command work. In particular, @code{$0} and
|
3136
|
-
@code{ARGV} are used to set internal byebug variables.
|
3101
|
+
@code{ARGV} are used to set internal byebug variables.
|
3137
3102
|
|
3138
3103
|
Therefore you should make try to make sure that when
|
3139
3104
|
@code{Byebug.start} is called neither of these variables has been
|
@@ -3171,9 +3136,9 @@ If not @code{nil}, this contains @code{$!} from the last exception.
|
|
3171
3136
|
@subsection @code{Byebug.context}
|
3172
3137
|
As mentioned previously, @code{Byebug.start} instruments additional
|
3173
3138
|
information to be obtained about the current block/frame stack. Here
|
3174
|
-
we describe these additional @code{Byebug.context} methods.
|
3139
|
+
we describe these additional @code{Byebug.context} methods.
|
3175
3140
|
|
3176
|
-
Were a frame position is indicated, it is optional. The top or current frame
|
3141
|
+
Were a frame position is indicated, it is optional. The top or current frame
|
3177
3142
|
position (position zero) is used if none is given.
|
3178
3143
|
|
3179
3144
|
@table @code
|
@@ -3266,19 +3231,17 @@ Fixnum. Number of characters byebug thinks are in a line. @xref{Width}.
|
|
3266
3231
|
@table @code
|
3267
3232
|
@item add_breakpoint(file, line, expr)
|
3268
3233
|
@vindex @code{Byebug.add_breakpoint}
|
3269
|
-
Adds a breakpoint in file @var{file}, at line @var{line}. If
|
3270
|
-
|
3271
|
-
|
3272
|
-
|
3273
|
-
|
3274
|
-
terminate.
|
3234
|
+
Adds a breakpoint in file @var{file}, at line @var{line}. If @var{expr} is not
|
3235
|
+
nil, it is evaluated and a breakpoint takes effect at the indicated position
|
3236
|
+
when that expression is true. You should verify that @var{expr} is syntactically
|
3237
|
+
valid or a @code{SyntaxError} exception, and unless your code handles this the
|
3238
|
+
debugged program may terminate.
|
3275
3239
|
|
3276
3240
|
@item remove_breakpoint(bpnum)
|
3277
3241
|
@vindex @code{Byebug.remove_breakpoint}
|
3278
|
-
When a breakpoint is added, it is assigned a number as a way to
|
3279
|
-
|
3280
|
-
|
3281
|
-
breakpoint number @var{bpnum}.
|
3242
|
+
When a breakpoint is added, it is assigned a number as a way to uniquely
|
3243
|
+
identify it. (There can be more than one breakpoint on a given line.) To remove
|
3244
|
+
a breakpoint, use @code{remove_breakpoint} with breakpoint number @var{bpnum}.
|
3282
3245
|
|
3283
3246
|
@item breakpoints
|
3284
3247
|
@vindex @code{Byebug.breakpoints}
|
@@ -3287,7 +3250,7 @@ Return a list of the breakpoints that have been added but not removed.
|
|
3287
3250
|
|
3288
3251
|
@node Byebug.Breakpoint
|
3289
3252
|
@subsection The @code{Byebug::Breakpoint} Class
|
3290
|
-
|
3253
|
+
Breakpoints are objects in the @code{Byebug::Breakpoint} class.
|
3291
3254
|
@table @code
|
3292
3255
|
@item enabled?
|
3293
3256
|
@vindex @code{Byebug::Breakpoints.enabled?}
|
@@ -3295,15 +3258,17 @@ Returns whether breakpoint is enabled or not.
|
|
3295
3258
|
|
3296
3259
|
@item enabled=
|
3297
3260
|
@vindex @code{Byebug::Breakpoints.enabled=}
|
3298
|
-
Sets
|
3261
|
+
Sets a breakpoint as enabled or not.
|
3299
3262
|
|
3300
3263
|
@item expr
|
3301
3264
|
@vindex @code{Byebug::Breakpoints.expr}
|
3302
|
-
|
3265
|
+
Returns an expression which has to be true at the point where the breakpoint is
|
3303
3266
|
set before we stop.
|
3304
3267
|
|
3305
3268
|
@item expr=
|
3306
3269
|
@vindex @code{Byebug::Breakpoints.expr=}
|
3270
|
+
Sets an expression which has to be true at the point where the breakpoint is set
|
3271
|
+
before we stop.
|
3307
3272
|
|
3308
3273
|
@item hit_condition
|
3309
3274
|
@item hit_condition=
|
@@ -3324,8 +3289,8 @@ Sets the hit value of the breakpoint.
|
|
3324
3289
|
|
3325
3290
|
@item id
|
3326
3291
|
@cindex @code{Byebug::Breakpoints.id}
|
3327
|
-
A numeric name for the breakpoint which is used in listing breakpoints
|
3328
|
-
|
3292
|
+
A numeric name for the breakpoint which is used in listing breakpoints and
|
3293
|
+
removing, enabling or disabling the breakpoint.
|
3329
3294
|
|
3330
3295
|
@item pos
|
3331
3296
|
@vindex @code{Byebug::Breakpoints.pos=}
|
@@ -3345,56 +3310,54 @@ Sets the file name in which the breakpoint occurs.
|
|
3345
3310
|
|
3346
3311
|
@node Byebug.Context
|
3347
3312
|
@subsection The @code{Byebug::Context} Class
|
3348
|
-
Callbacks in @code{Byebug:Context} get called when a stopping point
|
3349
|
-
|
3350
|
-
|
3351
|
-
|
3352
|
-
|
3313
|
+
Callbacks in @code{Byebug:Context} get called when a stopping point or an event
|
3314
|
+
is reached. It has information about the suspended program which enable byebug
|
3315
|
+
to inspect the frame stack, evaluate variables from the perspective of the
|
3316
|
+
debugged program, and contains information about the place the debugged program
|
3317
|
+
is stopped.
|
3353
3318
|
|
3354
3319
|
@table @code
|
3355
3320
|
@item at_line(@var{file}, @var{line})
|
3356
3321
|
@vindex Byebug::Context::at_line(@var{file}, @var{line})
|
3357
|
-
This routine is called when byebug encounters a ``line'' event for
|
3358
|
-
|
3359
|
-
|
3322
|
+
This routine is called when byebug encounters a ``line'' event for which it has
|
3323
|
+
been indicated we want to stop at, such as by hitting a breakpoint or by some
|
3324
|
+
sort of stepping.
|
3360
3325
|
|
3361
3326
|
@item at_return(@var{file}, @var{line})
|
3362
3327
|
@vindex Byebug::Context::at_return(@var{file}, @var{line})
|
3363
|
-
This routine is called when byebug encounters a ``return'' event for
|
3364
|
-
|
3365
|
-
|
3328
|
+
This routine is called when byebug encounters a ``return'' event for which it
|
3329
|
+
has been indicated we want to stop at, such as by hitting a @code{finish}
|
3330
|
+
statement.
|
3366
3331
|
|
3367
3332
|
@item debug_load(@var{file}, @var{stop-initially})
|
3368
3333
|
@vindex Byebug::Context::debug_load(@var{file}, @var{stop-initially})
|
3369
|
-
This method should be used to debug a file. If the file terminates
|
3370
|
-
|
3334
|
+
This method should be used to debug a file. If the file terminates normally,
|
3335
|
+
@code{nil} is returned. If not a backtrace is returned.
|
3371
3336
|
|
3372
|
-
The @var{stop-initially} parameter indicates whether the program
|
3373
|
-
|
3374
|
-
|
3337
|
+
The @var{stop-initially} parameter indicates whether the program should stop
|
3338
|
+
after loading. If an explicit call to byebug is in the debugged program, you may
|
3339
|
+
want to set this @code{false}.
|
3375
3340
|
@end table
|
3376
3341
|
|
3377
3342
|
@node Byebug.Command
|
3378
3343
|
@subsection The @code{Byebug::Command} Class
|
3344
|
+
Each command you run is in fact its own class. Should you want to extend byebug,
|
3345
|
+
it's pretty easy to do since after all byebug is Ruby.
|
3379
3346
|
|
3380
|
-
Each
|
3381
|
-
|
3382
|
-
|
3383
|
-
|
3384
|
-
method. This method returns regular expression for command-line
|
3385
|
-
strings that match your command. It's up to you to make sure this
|
3386
|
-
regular expression doesn't conflict with another one. If it does, it's
|
3387
|
-
undefined which one will get matched and run
|
3347
|
+
Each @code{Byebug#Command} class should have a @code{regexp} method. This method
|
3348
|
+
returns regular expression for command-line strings that match your command.
|
3349
|
+
It's up to you to make sure this regular expression doesn't conflict with
|
3350
|
+
another one. If it does, it's undefined which one will get matched and run.
|
3388
3351
|
|
3389
3352
|
In addition the instance needs these methods:
|
3390
3353
|
@table @code
|
3391
3354
|
@item execute
|
3392
|
-
Code which gets run when you type a command (string) that matches the
|
3393
|
-
|
3355
|
+
Code which gets run when you type a command (string) that matches the commands
|
3356
|
+
regular expression.
|
3394
3357
|
@item help
|
3395
|
-
A string which gets displayed when folks
|
3358
|
+
A string which gets displayed when folks ask for help on that command.
|
3396
3359
|
@item help_command
|
3397
|
-
A name
|
3360
|
+
A name the help system uses to show what commands are available.
|
3398
3361
|
@end table
|
3399
3362
|
|
3400
3363
|
Here's a small example of a new command:
|
@@ -3451,7 +3414,7 @@ continue edit frame me ps save thread where
|
|
3451
3414
|
This does whatever it is I want to do
|
3452
3415
|
(byebug:1) me
|
3453
3416
|
hi
|
3454
|
-
(byebug:1)
|
3417
|
+
(byebug:1)
|
3455
3418
|
@end smallexample
|
3456
3419
|
|
3457
3420
|
@node Kernel routines
|
@@ -3461,12 +3424,12 @@ hi
|
|
3461
3424
|
|
3462
3425
|
@item byebug @ovar{steps=1}
|
3463
3426
|
@vindex @code{Kernel::byebug}
|
3464
|
-
Enters byebug in the current thread after a stepping @var{steps} line-event
|
3465
|
-
Before entering byebug startup script is read.
|
3427
|
+
Enters byebug in the current thread after a stepping @var{steps} line-event
|
3428
|
+
steps. Before entering byebug startup script is read.
|
3466
3429
|
|
3467
|
-
Setting @var{steps} to 0 will cause a break in byebug subroutine
|
3468
|
-
|
3469
|
-
|
3430
|
+
Setting @var{steps} to 0 will cause a break in byebug subroutine and not wait
|
3431
|
+
for any line event to occur. This could be useful you want to stop right after
|
3432
|
+
the last statement in some scope.
|
3470
3433
|
|
3471
3434
|
Consider this example:
|
3472
3435
|
@smallexample
|
@@ -3474,7 +3437,7 @@ $ cat scope-test.rb
|
|
3474
3437
|
|
3475
3438
|
require 'rubygems'
|
3476
3439
|
require 'byebug' ; Byebug.start
|
3477
|
-
1.times do
|
3440
|
+
1.times do
|
3478
3441
|
a = 1
|
3479
3442
|
byebug # implied steps=1
|
3480
3443
|
end
|
@@ -3486,36 +3449,39 @@ y = 1
|
|
3486
3449
|
NameError Exception: undefined local variable or method `a' for main:Object
|
3487
3450
|
(byebug:1)
|
3488
3451
|
@end smallexample
|
3489
|
-
|
3490
|
-
|
3491
|
-
|
3492
|
-
|
3452
|
+
|
3453
|
+
Byebug will stop at the line event which follows @samp{a=1}. This is outside the
|
3454
|
+
@code{do} block scope where @var{a} is defined. If instead you want to stop
|
3455
|
+
before leaving the @code{do} loop it is possibly to stop right inside
|
3456
|
+
@code{byebug}; call with 0 zero parameter:
|
3457
|
+
|
3493
3458
|
@smallexample
|
3494
3459
|
$ cat scope-test.rb
|
3495
3460
|
|
3496
3461
|
require 'rubygems'
|
3497
3462
|
require 'byebug' ; Byebug.start
|
3498
|
-
1.times do
|
3463
|
+
1.times do
|
3499
3464
|
a = 1
|
3500
3465
|
byebug(0)
|
3501
3466
|
end
|
3502
3467
|
y = 1
|
3503
3468
|
|
3504
3469
|
$ scope-test.rb:8
|
3505
|
-
../lib/byebug
|
3470
|
+
../lib/byebug.rb:386
|
3506
3471
|
Byebug.current_context.stop_frame = 0
|
3507
3472
|
(byebug:1) where
|
3508
|
-
--> #0 Kernel.byebug(steps#Fixnum) at
|
3509
|
-
#1 at
|
3510
|
-
#2 at
|
3473
|
+
--> #0 Kernel.byebug(steps#Fixnum) at ../lib/byebug-base.rb:386
|
3474
|
+
#1 at scope-test.rb:6
|
3475
|
+
#2 at scope-test.rb:4
|
3511
3476
|
(byebug:1) up
|
3512
|
-
#1 at
|
3477
|
+
#1 at scope-test.rb:6
|
3513
3478
|
(byebug:1) p a
|
3514
3479
|
1
|
3515
3480
|
(byebug:1)
|
3516
3481
|
@end smallexample
|
3517
|
-
|
3518
|
-
|
3482
|
+
|
3483
|
+
As seen above you will have to position the frame up one to be back in your
|
3484
|
+
debugged program rather than in byebug.
|
3519
3485
|
|
3520
3486
|
@item breakpoint @ovar{steps=1}
|
3521
3487
|
@vindex @code{Kernel::breakpoint}
|
@@ -3547,12 +3513,12 @@ OSX some of the below may need adjusting.
|
|
3547
3513
|
@section Prerequisites: To build the package you'll need at a minimum:
|
3548
3514
|
|
3549
3515
|
@itemize @bullet
|
3550
|
-
@item
|
3551
|
-
Ruby (of course). Currently only version 1.8.6 and above but not
|
3516
|
+
@item
|
3517
|
+
Ruby (of course). Currently only version 1.8.6 and above but not
|
3552
3518
|
version 1.9.@emph{x} work.
|
3553
3519
|
@item
|
3554
3520
|
Ruby development headers. This typically includes a file called @file{ruby.h}
|
3555
|
-
@item
|
3521
|
+
@item
|
3556
3522
|
A C compiler like GNU C (@code{gcc})
|
3557
3523
|
@item
|
3558
3524
|
Rake
|
@@ -3564,7 +3530,7 @@ If you want to build the documentation and install Emacs files, you'll
|
|
3564
3530
|
also need:
|
3565
3531
|
|
3566
3532
|
@itemize @bullet
|
3567
|
-
@item
|
3533
|
+
@item
|
3568
3534
|
a POSIX shell like bash
|
3569
3535
|
@item
|
3570
3536
|
autoconf
|
@@ -3577,9 +3543,9 @@ also need:
|
|
3577
3543
|
@end itemize
|
3578
3544
|
|
3579
3545
|
@node Package Checkout
|
3580
|
-
@section Basic Package Checkout and Installation
|
3546
|
+
@section Basic Package Checkout and Installation
|
3581
3547
|
|
3582
|
-
Check out the trunk of repository following the instructions at
|
3548
|
+
Check out the trunk of repository following the instructions at
|
3583
3549
|
@url{http://rubyforge.org/scm/?group_id=1900} For example on a Unixy system,
|
3584
3550
|
this may work:
|
3585
3551
|
|
@@ -3599,7 +3565,7 @@ the code has been checked out and run:
|
|
3599
3565
|
@end smallexample
|
3600
3566
|
|
3601
3567
|
If all goes well you should have some gem files put in the directory
|
3602
|
-
@code{pkg}. Use the gem command to install that.
|
3568
|
+
@code{pkg}. Use the gem command to install that.
|
3603
3569
|
|
3604
3570
|
@smallexample
|
3605
3571
|
sudo gem install byebug-*.gem # See gem help for other possibilities
|
@@ -3640,7 +3606,7 @@ script @code{runner.sh}. For example (again from trunk)
|
|
3640
3606
|
|
3641
3607
|
@node Running Regression Tests
|
3642
3608
|
@section Running the Regression Tests
|
3643
|
-
|
3609
|
+
|
3644
3610
|
We've put together some basic tests to make sure byebug is doing
|
3645
3611
|
what we think it should do. To run these (from @code{trunk}):
|
3646
3612
|
|
@@ -3710,26 +3676,25 @@ On my system, this script fails in running @code{make ruby} because the
|
|
3710
3676
|
fake.rb that got created needed to have a small change:
|
3711
3677
|
|
3712
3678
|
@smallexample
|
3713
|
-
|
3714
|
-
ALT_SEPARATOR = "\"; \
|
3679
|
+
ALT_SEPARATOR = "\"; \
|
3715
3680
|
@end smallexample
|
3716
3681
|
should be:
|
3717
3682
|
@smallexample
|
3718
|
-
|
3683
|
+
ALT_SEPARATOR = "\\"; \
|
3719
3684
|
@end smallexample
|
3720
3685
|
|
3721
3686
|
After fixing this, run @code{make ruby}. Also, I needed to run
|
3722
3687
|
@code{make rubyw}.
|
3723
3688
|
|
3724
|
-
And then @code{make install} as indicated.
|
3689
|
+
And then @code{make install} as indicated.
|
3725
3690
|
|
3726
3691
|
Once all of that's in place, the place you want be is in
|
3727
|
-
@code{byebug/trunk/ext/win32}, not @code{byebug/ext}.
|
3692
|
+
@code{byebug/trunk/ext/win32}, not @code{byebug/ext}.
|
3728
3693
|
|
3729
3694
|
So let's say you've installed the cross-compiled install ruby in
|
3730
3695
|
@code{/usr/local/ruby-mingw32/}. Here then are the commands to build @code{byebug-base-}@emph{xxx}@code{-mswin32.gem}:
|
3731
3696
|
@smallexample
|
3732
|
-
cd .../byebug/trunk/ext/win32
|
3697
|
+
cd .../byebug/trunk/ext/win32
|
3733
3698
|
ruby -I /usr/local/ruby-mingw32/lib/ruby/1.8/i386-mingw32 ../extconf.rb
|
3734
3699
|
make # Not rake
|
3735
3700
|
cd ../.. # back in byebug/trunk
|