byebug 1.0.0 → 1.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.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/README.md +36 -4
- data/Rakefile +1 -3
- data/bin/byebug +26 -30
- data/byebug.gemspec +8 -2
- data/lib/byebug.rb +6 -5
- data/lib/byebug/command.rb +30 -18
- data/lib/byebug/commands/control.rb +4 -4
- data/lib/byebug/commands/frame.rb +12 -11
- data/lib/byebug/commands/info.rb +43 -56
- data/lib/byebug/commands/irb.rb +3 -3
- data/lib/byebug/commands/list.rb +26 -25
- data/lib/byebug/commands/save.rb +11 -11
- data/lib/byebug/commands/set.rb +32 -38
- data/lib/byebug/commands/show.rb +3 -7
- data/lib/byebug/commands/variables.rb +6 -6
- data/lib/byebug/helper.rb +1 -1
- data/lib/byebug/interface.rb +6 -5
- data/lib/byebug/processor.rb +9 -9
- data/lib/byebug/version.rb +1 -1
- data/old_doc/byebug.1 +16 -16
- data/old_doc/byebug.texi +155 -163
- data/test/info_test.rb +11 -10
- data/test/list_test.rb +45 -22
- data/test/restart_test.rb +1 -1
- data/test/set_test.rb +6 -5
- data/test/support/matchers.rb +2 -3
- data/test/support/mocha_extensions.rb +2 -4
- data/test/support/test_dsl.rb +4 -0
- data/test/test_helper.rb +5 -0
- data/test/variables_test.rb +5 -5
- metadata +9 -26
data/old_doc/byebug.1
CHANGED
@@ -1,18 +1,18 @@
|
|
1
|
-
.\" $Id:
|
2
|
-
.TH
|
1
|
+
.\" $Id: byebug.1 516 2007-12-31 05:55:24Z rockyb $
|
2
|
+
.TH byebug 1
|
3
3
|
.SH NAME
|
4
|
-
|
4
|
+
byebug \- Fast Ruby byebug
|
5
5
|
.SH SYNOPSIS
|
6
|
-
.B
|
6
|
+
.B byebug
|
7
7
|
[byebug-options]
|
8
|
-
|
8
|
+
byebug
|
9
9
|
[script-options...]
|
10
10
|
.SH "DESCRIPTION"
|
11
11
|
This manual page documents briefly the
|
12
|
-
.BR
|
12
|
+
.BR byebug
|
13
13
|
command.
|
14
14
|
.PP
|
15
|
-
.B
|
15
|
+
.B byebug
|
16
16
|
is a fast implementation of the standard Ruby byebug debug.rb. It
|
17
17
|
is implemented by utilizing a Ruby C API hook, allows for remote
|
18
18
|
debugging and can be used as the Ruby byebug backend interface for a
|
@@ -22,7 +22,7 @@ The commands generally follow gdb's command set unless there's good
|
|
22
22
|
reason not to.
|
23
23
|
|
24
24
|
.PP
|
25
|
-
|
25
|
+
byebug can do four main kinds of things (plus other things in support of
|
26
26
|
these) to help you catch bugs in the act:
|
27
27
|
|
28
28
|
.TP
|
@@ -75,10 +75,10 @@ or
|
|
75
75
|
.B down. A negative number starts counting from the other end.
|
76
76
|
.TP
|
77
77
|
.B help \fR[\|\fIname\fR\|]
|
78
|
-
Show information about
|
78
|
+
Show information about byebug command \c
|
79
79
|
.I name\c
|
80
80
|
\&, or general information
|
81
|
-
about using
|
81
|
+
about using byebug.
|
82
82
|
.TP
|
83
83
|
.B info \fR[\|\fIname\fR\|]
|
84
84
|
Get the various information usually about the debugged program.
|
@@ -142,7 +142,7 @@ goes the other direction and is like the down command
|
|
142
142
|
.B where \fR[\|\fIcount\fR\|]
|
143
143
|
Display all or \fIcount\fR items of the program stack.
|
144
144
|
.PP
|
145
|
-
For full details on
|
145
|
+
For full details on byebug, see \c
|
146
146
|
https://github.com/cldwalker/byebug
|
147
147
|
.SH OPTIONS
|
148
148
|
.PP
|
@@ -155,7 +155,7 @@ front-ends such as GNU Emacs to post this updated information without
|
|
155
155
|
having to poll for it.
|
156
156
|
.TP
|
157
157
|
.B \-\-client
|
158
|
-
Connect to a remote byebug. Used with another
|
158
|
+
Connect to a remote byebug. Used with another byebug invocation using \-\-server.
|
159
159
|
See also \-\-host and \-\-cport options
|
160
160
|
.TP
|
161
161
|
.B \-\-cport=PORT
|
@@ -215,7 +215,7 @@ is given. If no script name is given just exit after printing the
|
|
215
215
|
version number.
|
216
216
|
.TP
|
217
217
|
.B \-\-nx
|
218
|
-
Don't execute commands found in any initialization files, e.g. .
|
218
|
+
Don't execute commands found in any initialization files, e.g. .byebugrc.
|
219
219
|
.TP
|
220
220
|
.B \-\-keep-frame-binding
|
221
221
|
Keep frame bindings.
|
@@ -223,7 +223,7 @@ Keep frame bindings.
|
|
223
223
|
.B \-\-script=FILE
|
224
224
|
Name of the script file to run
|
225
225
|
.B \-s | \-\-server
|
226
|
-
Listen for remote connections. Another
|
226
|
+
Listen for remote connections. Another byebug session accesses using the \-\-client option.
|
227
227
|
See also the \-\-host, \-\-port and
|
228
228
|
\-\-cport options
|
229
229
|
.TP
|
@@ -237,5 +237,5 @@ Show invocation help and exit.
|
|
237
237
|
.Sp
|
238
238
|
https://github.com/cldwalker/byebug
|
239
239
|
.SH AUTHOR
|
240
|
-
|
241
|
-
|
240
|
+
byebug was written by Kent Siblev. This manual page was written by Rocky
|
241
|
+
Bernstein <rocky@gnu.org>
|
data/old_doc/byebug.texi
CHANGED
@@ -160,7 +160,7 @@ purposes than how to write short Ruby code.}
|
|
160
160
|
@smallexample
|
161
161
|
$ @b{byebug triangle.rb}
|
162
162
|
triangle.rb:4 def hanoi(n,a,b,c)
|
163
|
-
(
|
163
|
+
(byebug:1) @b{list}
|
164
164
|
[-1, 8] in ./triangle.rb
|
165
165
|
1 #!/usr/bin/env ruby
|
166
166
|
2 # Compute the n'th triangle number - the hard way
|
@@ -170,14 +170,14 @@ triangle.rb:4 def hanoi(n,a,b,c)
|
|
170
170
|
6 0.upto(n) do |i|
|
171
171
|
7 tri += i
|
172
172
|
8 end
|
173
|
-
(
|
173
|
+
(byebug:1) @b{l}
|
174
174
|
[9, 18] in ./triangle.rb
|
175
175
|
9 tri
|
176
176
|
10 end
|
177
177
|
11
|
178
178
|
12 t = triangle(3)
|
179
179
|
13 puts t
|
180
|
-
(
|
180
|
+
(byebug:1) @b{list 1,100}
|
181
181
|
[1, 100] in ./triangle.rb
|
182
182
|
1 #!/usr/bin/env ruby
|
183
183
|
2 # Compute the n'th triangle number - the hard way
|
@@ -192,7 +192,7 @@ triangle.rb:4 def hanoi(n,a,b,c)
|
|
192
192
|
11
|
193
193
|
12 t = triangle(3)
|
194
194
|
13 puts t
|
195
|
-
(
|
195
|
+
(byebug:1)
|
196
196
|
@end smallexample
|
197
197
|
|
198
198
|
@noindent
|
@@ -200,59 +200,53 @@ triangle.rb:4 def hanoi(n,a,b,c)
|
|
200
200
|
There are lots of command options, but we don't need them for now. See
|
201
201
|
@ref{byebug command-line options} for a full list of command options.
|
202
202
|
|
203
|
-
Position information consists of a filename and line number,
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
the
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
(@pxref{Listsize}). To see the entire program in one shot, we gave an
|
235
|
-
explicit starting and ending line number.
|
236
|
-
|
237
|
-
If you use a front-end to byebug such as the Emacs interface,
|
238
|
-
@c (@pxref{GNU Emacs})
|
239
|
-
you probably won't use @code{list} all that much.
|
203
|
+
Position information consists of a filename and line number, e.g.@:
|
204
|
+
@code{triangle.rb:4}. We are currently stopped before the first executable line
|
205
|
+
of the program; this is line 4 of @code{triangle.rb}. If you are used to less
|
206
|
+
dynamic languages and have used debuggers for more statically compiled languages
|
207
|
+
like C, C++, or Java, it may seem odd to be stopped before a function definition
|
208
|
+
but in Ruby line 4 is executed, the name @code{triangle} (probably) does not
|
209
|
+
exist so issuing a method call of @code{triangle} will raise a ``method not
|
210
|
+
found'' error.
|
211
|
+
|
212
|
+
@DBG{}'s prompt is @code{(byebug:@emph{n})}. The @emph{n} is the thread number.
|
213
|
+
Here it is 1 which is usually the case for the main thread. If the program has
|
214
|
+
died and you are in post-mortem debugging, there is no thread number. In this
|
215
|
+
situation, the string @code{post-mortem} is used in place of a thread number. If
|
216
|
+
the program has terminated normally, the string this position will be
|
217
|
+
@code{ctrl}. The commands which are available change depending on the program
|
218
|
+
state.
|
219
|
+
|
220
|
+
The first command, @code{list} (@pxref{List}), prints 10 lines centered around
|
221
|
+
the current line; the current line here is line 4 and is marked by @code{=>}, so
|
222
|
+
the range byebug would like to show is -1..8. However since there aren't 5 lines
|
223
|
+
before the current line, those additional lines---``lines'' -1 and 0---are
|
224
|
+
dropped and we print the remaining 8 lines. The @code{list} command can be
|
225
|
+
abbreviated with @code{l} which is what we use next. Notice that when we use
|
226
|
+
this a second time, we continue listing from the place we last left off. The
|
227
|
+
desired range of lines this time is lines 9 to 18; but since the program ends at
|
228
|
+
line 13, only the remaining 5 lines are shown.
|
229
|
+
|
230
|
+
If you want to set how many lines to print by default rather than use the
|
231
|
+
initial number of lines, 10, use the @code{set listsize} command
|
232
|
+
(@pxref{Listsize}). To see the entire program in one shot, we gave an explicit
|
233
|
+
starting and ending line number.
|
240
234
|
|
241
235
|
Now let us step through the program.
|
242
236
|
|
243
237
|
@smallexample
|
244
|
-
(
|
238
|
+
(byebug:1) @b{step}
|
245
239
|
triangle.rb:12
|
246
240
|
t = triangle(3)
|
247
|
-
(
|
241
|
+
(byebug:1) @b{@key{<RET>}}
|
248
242
|
triangle.rb:5
|
249
243
|
tri = 0
|
250
|
-
(
|
244
|
+
(byebug:1) @b{p tri}
|
251
245
|
nil
|
252
|
-
(
|
246
|
+
(byebug:1) @b{step}
|
253
247
|
triangle.rb:6
|
254
248
|
0.upto(n) do |i|
|
255
|
-
(
|
249
|
+
(byebug:1) @b{p tri}
|
256
250
|
0
|
257
251
|
@end smallexample
|
258
252
|
|
@@ -273,7 +267,7 @@ to see how things are going stop, there is a better way by setting a
|
|
273
267
|
display expression (@pxref{DisplayCommands}).
|
274
268
|
|
275
269
|
@smallexample
|
276
|
-
(
|
270
|
+
(byebug:1) @b{display tri}
|
277
271
|
1: tri = 0
|
278
272
|
@end smallexample
|
279
273
|
|
@@ -281,11 +275,11 @@ Now let us run the program until we return from the function. However
|
|
281
275
|
we'll want to see which lines get run.
|
282
276
|
|
283
277
|
@smallexample
|
284
|
-
(
|
278
|
+
(byebug:1) @b{display i}
|
285
279
|
2: i =
|
286
|
-
(
|
280
|
+
(byebug:1) @b{set linetrace on}
|
287
281
|
line tracing is on.
|
288
|
-
(
|
282
|
+
(byebug:1) @b{finish}
|
289
283
|
Tracing(1):triangle.rb:7 tri += i
|
290
284
|
1: tri = 0
|
291
285
|
2: i = 0
|
@@ -309,14 +303,14 @@ Tracing(1):triangle.rb:13 puts t
|
|
309
303
|
2: i =
|
310
304
|
triangle.rb:13
|
311
305
|
puts t
|
312
|
-
(
|
306
|
+
(byebug:1) @b{quit}
|
313
307
|
Really quit? (y/n) @b{y}
|
314
308
|
@end smallexample
|
315
309
|
|
316
|
-
So far, so good. A you can see from the above to get out of
|
317
|
-
|
318
|
-
|
319
|
-
|
310
|
+
So far, so good. A you can see from the above to get out of byebug, one can
|
311
|
+
issue a @code{quit} command. (@code{q} and @code{exit} are just as good. If you
|
312
|
+
want to quit without being prompted, suffix the command with an exclamation
|
313
|
+
mark, e.g.\@code{q!}.
|
320
314
|
|
321
315
|
@node Second Sample Session
|
322
316
|
@section Sample Session 2: Delving Deeper (@code{where}, @code{frame}, @code{restart}, @code{autoeval}, @code{break}, @code{ps})
|
@@ -333,7 +327,7 @@ command-parameter processing with error checking.
|
|
333
327
|
@smallexample
|
334
328
|
$ @b{byebug hanoi.rb}
|
335
329
|
hanoi.rb:3 def hanoi(n,a,b,c)
|
336
|
-
(
|
330
|
+
(byebug:1) @b{list 1,100}
|
337
331
|
[1, 100] in ./hanoi.rb
|
338
332
|
1 #!/usr/bin/ruby
|
339
333
|
2
|
@@ -370,7 +364,7 @@ hanoi.rb:3 def hanoi(n,a,b,c)
|
|
370
364
|
33 end
|
371
365
|
34
|
372
366
|
35 hanoi(n, :a, :b, :c)
|
373
|
-
(
|
367
|
+
(byebug:1)
|
374
368
|
@end smallexample
|
375
369
|
|
376
370
|
Recall in the first section I said that before the @code{def} is run
|
@@ -378,9 +372,9 @@ the method it names is undefined. Let's check that out. First let's
|
|
378
372
|
see what private methods we can call before running @code{def hanoi}
|
379
373
|
|
380
374
|
@smallexample
|
381
|
-
(
|
375
|
+
(byebug:1) @b{set autoeval on}
|
382
376
|
autoeval is on.
|
383
|
-
(
|
377
|
+
(byebug:1) @b{private_methods}
|
384
378
|
[:require_relative, :Digest, :default_src_encoding, :debug_program, ...
|
385
379
|
@end smallexample
|
386
380
|
|
@@ -399,7 +393,7 @@ sort and put into columns lists like this using the print command, @code{ps}.
|
|
399
393
|
|
400
394
|
|
401
395
|
@smallexample
|
402
|
-
(
|
396
|
+
(byebug:1) @b{ps private_methods}
|
403
397
|
Array debug_program p spawn
|
404
398
|
Complex default_src_encoding pp sprintf
|
405
399
|
Digest eval print srand
|
@@ -426,20 +420,20 @@ dbg_puts open sleep
|
|
426
420
|
Now let's see what happens after stepping:
|
427
421
|
|
428
422
|
@smallexample
|
429
|
-
(
|
423
|
+
(byebug:1) @b{private_methods.member?(:hanoi)}
|
430
424
|
false
|
431
|
-
(
|
425
|
+
(byebug:1) @b{step}
|
432
426
|
hanoi.rb:13
|
433
427
|
i_args=ARGV.length
|
434
|
-
(
|
428
|
+
(byebug:1) @b{private_methods.member?(:hanoi)}
|
435
429
|
true
|
436
|
-
(
|
430
|
+
(byebug:1)
|
437
431
|
@end smallexample
|
438
432
|
|
439
433
|
Okay, now where were we?
|
440
434
|
|
441
435
|
@smallexample
|
442
|
-
(
|
436
|
+
(byebug:1) @b{list}
|
443
437
|
[8, 17] in ./hanoi.rb
|
444
438
|
8 if n-1 > 0
|
445
439
|
9 hanoi(n-1, c, b, a)
|
@@ -451,7 +445,7 @@ Okay, now where were we?
|
|
451
445
|
15 puts "*** Need number of disks or no parameter"
|
452
446
|
16 exit 1
|
453
447
|
17 end
|
454
|
-
(
|
448
|
+
(byebug:1) @b{ARGV}
|
455
449
|
[]
|
456
450
|
@end smallexample
|
457
451
|
|
@@ -459,45 +453,45 @@ Ooops. We forgot to specify any parameters to this program. Let's try
|
|
459
453
|
again. We can use the @code{restart} command here.
|
460
454
|
|
461
455
|
@smallexample
|
462
|
-
(
|
456
|
+
(byebug:1) @b{restart 3}
|
463
457
|
Re exec'ing:
|
464
458
|
/usr/bin/byebug hanoi.rb 3
|
465
459
|
hanoi.rb:3
|
466
460
|
def hanoi(n,a,b,c)
|
467
|
-
(
|
461
|
+
(byebug:1) @b{break 4}
|
468
462
|
Breakpoint 1 file hanoi.rb, line 4
|
469
|
-
(
|
463
|
+
(byebug:1) @b{continue}
|
470
464
|
Breakpoint 1 at hanoi.rb:4
|
471
465
|
./hanoi.rb:4 if n-1 > 0
|
472
|
-
(
|
466
|
+
(byebug:1) @b{display n}
|
473
467
|
1: n = 3
|
474
|
-
(
|
468
|
+
(byebug:1) @b{display a}
|
475
469
|
2: a = a
|
476
|
-
(
|
477
|
-
(
|
470
|
+
(byebug:1) @b{undisplay 2}
|
471
|
+
(byebug:1) @b{display a.inspect}
|
478
472
|
3: a.inspect = :a
|
479
|
-
(
|
473
|
+
(byebug:1) @b{display b.inspect}
|
480
474
|
4: b.inspect = :b
|
481
|
-
(
|
475
|
+
(byebug:1) @b{continue}
|
482
476
|
Breakpoint 1 at hanoi.rb:4
|
483
477
|
1: n = 2
|
484
478
|
3: a.inspect = :a
|
485
479
|
4: b.inspect = :c
|
486
480
|
./hanoi.rb:4
|
487
481
|
if n-1 > 0
|
488
|
-
(
|
482
|
+
(byebug:1) @b{c}
|
489
483
|
Breakpoint 1 at hanoi.rb:4
|
490
484
|
1: n = 1
|
491
485
|
3: a.inspect = :a
|
492
486
|
4: b.inspect = :b
|
493
487
|
./hanoi.rb:4
|
494
488
|
if n-1 > 0
|
495
|
-
(
|
489
|
+
(byebug:1) @b{where}
|
496
490
|
--> #0 Object.hanoi(n#Fixnum, a#Symbol, b#Symbol, c#Symbol) at line hanoi.rb:4
|
497
491
|
#1 Object.hanoi(n#Fixnum, a#Symbol, b#Symbol, c#Symbol) at line hanoi.rb:5
|
498
492
|
#2 Object.hanoi(n#Fixnum, a#Symbol, b#Symbol, c#Symbol) at line hanoi.rb:5
|
499
493
|
#3 at line hanoi.rb:35
|
500
|
-
(
|
494
|
+
(byebug:1)
|
501
495
|
@end smallexample
|
502
496
|
|
503
497
|
In the above we added a new command, @code{break}
|
@@ -525,7 +519,7 @@ style of what to show in the trace (@pxref{Callstyle}).
|
|
525
519
|
Let's explore a little more. Now were were we?
|
526
520
|
|
527
521
|
@smallexample
|
528
|
-
(
|
522
|
+
(byebug:1) @b{list}
|
529
523
|
1 #!/usr/bin/ruby
|
530
524
|
2
|
531
525
|
3 def hanoi(n,a,b,c)
|
@@ -534,19 +528,19 @@ Let's explore a little more. Now were were we?
|
|
534
528
|
6 end
|
535
529
|
7 puts "Move disk %s to %s" % [a, b]
|
536
530
|
8 if n-1 > 0
|
537
|
-
(
|
531
|
+
(byebug:1) @b{undisplay}
|
538
532
|
Clear all expressions? (y/n) @b{y}
|
539
|
-
(
|
533
|
+
(byebug:1) @b{i_args}
|
540
534
|
NameError Exception: undefined local variable or method `i_args' for main:Object
|
541
|
-
(
|
535
|
+
(byebug:1) @b{frame -1}
|
542
536
|
#3 at line hanoi.rb:35
|
543
|
-
(
|
537
|
+
(byebug:1) @b{i_args}
|
544
538
|
1
|
545
|
-
(
|
539
|
+
(byebug:1) @b{p n}
|
546
540
|
3
|
547
|
-
(
|
541
|
+
(byebug:1) @b{down 2}
|
548
542
|
#2 Object.hanoi(n#Fixnum, a#Symbol, b#Symbol, c#Symbol) at line hanoi.rb:5
|
549
|
-
(
|
543
|
+
(byebug:1) @b{p n}
|
550
544
|
2
|
551
545
|
@end smallexample
|
552
546
|
|
@@ -666,7 +660,7 @@ Now we run the program..
|
|
666
660
|
Started
|
667
661
|
test-tri.rb:9
|
668
662
|
solutions = []
|
669
|
-
(
|
663
|
+
(byebug:1)
|
670
664
|
@end smallexample
|
671
665
|
and we see that we are stopped at line 9 just before the
|
672
666
|
initialization of the list @code{solutions}.
|
@@ -674,9 +668,9 @@ initialization of the list @code{solutions}.
|
|
674
668
|
Now let's see where we are...
|
675
669
|
|
676
670
|
@smallexample
|
677
|
-
(
|
671
|
+
(byebug:1) @b{where}
|
678
672
|
--> #0 TestTri.test_basic at line /home/rocky/ruby/test-tri.rb:9
|
679
|
-
(
|
673
|
+
(byebug:1)
|
680
674
|
@end smallexample
|
681
675
|
|
682
676
|
Something seems wrong here; @code{TestTri.test_basic} indicates that
|
@@ -720,7 +714,7 @@ Loaded suite test-tri2
|
|
720
714
|
Started
|
721
715
|
test-tri2.rb:11
|
722
716
|
solutions = []
|
723
|
-
(
|
717
|
+
(byebug:1) @b{where}
|
724
718
|
--> #0 TestTri.test_basic at line test-tri2.rb:11
|
725
719
|
#1 MiniTest::Unit::TestCase.run(runner#MiniTest::Unit)
|
726
720
|
at line /usr/local/lib/ruby/1.9.1/minitest/unit.rb:458
|
@@ -729,7 +723,7 @@ solutions = []
|
|
729
723
|
#3 MiniTest::Unit.run
|
730
724
|
at line /usr/local/lib/ruby/1.9.1/minitest/unit.rb:393
|
731
725
|
#4 at line /usr/local/lib/ruby/1.9.1/minitest/unit.rb:334
|
732
|
-
(
|
726
|
+
(byebug:1)
|
733
727
|
@end smallexample
|
734
728
|
|
735
729
|
Much better. But again let me emphasize that the parameter types are
|
@@ -774,12 +768,12 @@ irb(main):005:1> @b{end}
|
|
774
768
|
irb(main):006:0> @b{Byebug.start@{byebug; foo@}}
|
775
769
|
(irb):3
|
776
770
|
|
777
|
-
(
|
771
|
+
(byebug:1) @b{s}
|
778
772
|
(irb):4
|
779
773
|
|
780
|
-
(
|
774
|
+
(byebug:1) @b{p x}
|
781
775
|
1
|
782
|
-
(
|
776
|
+
(byebug:1) @b{s}
|
783
777
|
foo
|
784
778
|
=> true
|
785
779
|
irb(main):007:0>
|
@@ -876,9 +870,9 @@ method header. It's possible the call will continue after a
|
|
876
870
|
$ @b{byebug primes.rb}
|
877
871
|
primes.rb:3
|
878
872
|
class SievePrime
|
879
|
-
(
|
873
|
+
(byebug:1) @b{set linetrace on}
|
880
874
|
line tracing is on.
|
881
|
-
(
|
875
|
+
(byebug:1) @b{step 9}
|
882
876
|
Tracing(1):primes.rb:4 @@odd_primes = []
|
883
877
|
Tracing(1):primes.rb:5 def self.next_prime(&block)
|
884
878
|
Tracing(1):primes.rb:23 SievePrime.next_prime do |prime|
|
@@ -891,7 +885,7 @@ Tracing(1):primes.rb:8 not_prime = false
|
|
891
885
|
Tracing(1):primes.rb:9 candidate += 1
|
892
886
|
primes.rb:9
|
893
887
|
candidate += 1
|
894
|
-
(
|
888
|
+
(byebug:1)
|
895
889
|
@end smallexample
|
896
890
|
|
897
891
|
The loop between lines 23--26 gets interleaved between those of
|
@@ -1439,15 +1433,15 @@ might want to enter the following code to compute the 5th Fibonacci
|
|
1439
1433
|
number:
|
1440
1434
|
@smallexample
|
1441
1435
|
# Compute the 5 Fibonaci number
|
1442
|
-
(
|
1443
|
-
(
|
1436
|
+
(byebug:1) set autoeval on
|
1437
|
+
(byebug:1) fib1=0; fib2=1; 5.times @{|temp| temp=fib1; fib1=fib2; fib2 += temp @}
|
1444
1438
|
SyntaxError Exception: compile error
|
1445
1439
|
/usr/bin/irb:10: syntax error, unexpected $end, expecting '@}'
|
1446
1440
|
5.times @{|temp| temp=fib1
|
1447
1441
|
^
|
1448
|
-
(
|
1442
|
+
(byebug:1) fib1=0\; fib2=1\; 5.times @{|temp| temp=fib1\; fib1=fib2\; fib2 += temp @}
|
1449
1443
|
5
|
1450
|
-
(
|
1444
|
+
(byebug:1) fib2
|
1451
1445
|
fib2
|
1452
1446
|
8
|
1453
1447
|
@end smallexample
|
@@ -1470,9 +1464,9 @@ history size} command. See @ref{History} for history parameters.
|
|
1470
1464
|
|
1471
1465
|
In the command-line interface, when @code{byebug} is waiting for
|
1472
1466
|
input it presents a prompt of the form
|
1473
|
-
@code{(
|
1467
|
+
@code{(byebug:}@emph{x}@code{)}. If debugging locally, @emph{x} will be
|
1474
1468
|
the thread number. Usual the main thread is 1, so often you'll see
|
1475
|
-
@code{(
|
1469
|
+
@code{(byebug:1)}. In the control interface though @emph{x} will be
|
1476
1470
|
@code{ctrl} and in post-mortem debugging @code{post-mortem}.
|
1477
1471
|
|
1478
1472
|
In the local interface, whenever @code{byebug} gives an error
|
@@ -1501,7 +1495,7 @@ display a short list of named classes of commands:
|
|
1501
1495
|
|
1502
1496
|
@flushleft
|
1503
1497
|
@smallexample
|
1504
|
-
(
|
1498
|
+
(byebug:1) @b{help}
|
1505
1499
|
byebug help v@value{BYEBUG_VERSION}
|
1506
1500
|
Type 'help <command-name>' for help on a specific command
|
1507
1501
|
|
@@ -1523,36 +1517,34 @@ With a command name as @code{help} argument, @DBG displays short
|
|
1523
1517
|
information on how to use that command.
|
1524
1518
|
|
1525
1519
|
@smallexample
|
1526
|
-
(
|
1520
|
+
(byebug:1) @b{help list}
|
1527
1521
|
byebug help v@value{BYEBUG_VERSION}
|
1528
1522
|
l[ist] list forward
|
1529
1523
|
l[ist] - list backward
|
1530
1524
|
l[ist] = list current line
|
1531
1525
|
l[ist] nn-mm list given lines
|
1532
1526
|
* NOTE - to turn on autolist, use 'set autolist'
|
1533
|
-
(
|
1527
|
+
(byebug:1)
|
1534
1528
|
@end smallexample
|
1535
1529
|
@end table
|
1536
1530
|
|
1537
1531
|
@node Help for Subcommands
|
1538
1532
|
@subsection Help on Subcommands
|
1539
|
-
A number of commands have many sub-parameters or
|
1540
|
-
@
|
1541
|
-
|
1542
|
-
|
1543
|
-
|
1544
|
-
|
1545
|
-
|
1546
|
-
|
1547
|
-
|
1548
|
-
|
1549
|
-
help
|
1550
|
-
of the letters to make that subcommand distinct from others will
|
1551
|
-
do. For example, @code{help set an} is the same as @code{help set annotate}.
|
1533
|
+
A number of commands have many sub-parameters or @emph{subcommands}. These
|
1534
|
+
include @code{info}, @code{set}, @code{show}, @code{enable} and @code{disable}.
|
1535
|
+
|
1536
|
+
When you ask for help for one of these commands, you will get help for all of
|
1537
|
+
the subcommands that that command offers. Sometimes you may want help that
|
1538
|
+
subcommand and to do this just follow the command with its subcommand name. For
|
1539
|
+
example @code{help set annotate} will just give help about the annotate command.
|
1540
|
+
Furthermore it will give longer help than the summary information that appears
|
1541
|
+
when you ask for help. You don't need to list the full subcommand name, but just
|
1542
|
+
enough of the letters to make that subcommand distinct from others will do. For
|
1543
|
+
example, @code{help set an} is the same as @code{help set annotate}.
|
1552
1544
|
|
1553
1545
|
Some examples follow.
|
1554
1546
|
@example
|
1555
|
-
(
|
1547
|
+
(byebug:1) @b{help info}
|
1556
1548
|
Generic command for showing things about the program being debugged.
|
1557
1549
|
--
|
1558
1550
|
List of info subcommands:
|
@@ -1575,14 +1567,14 @@ info variables -- Local and instance variables of the current stack frame
|
|
1575
1567
|
@end example
|
1576
1568
|
|
1577
1569
|
@example
|
1578
|
-
(
|
1570
|
+
(byebug:1) @b{help info breakpoints}
|
1579
1571
|
Status of user-settable breakpoints.
|
1580
1572
|
Without argument, list info about all breakpoints. With an
|
1581
1573
|
integer argument, list info on that breakpoint.
|
1582
1574
|
@end example
|
1583
1575
|
|
1584
1576
|
@example
|
1585
|
-
(
|
1577
|
+
(byebug:1) @b{help info br}
|
1586
1578
|
Status of user-settable breakpoints.
|
1587
1579
|
Without argument, list info about all breakpoints. With an
|
1588
1580
|
integer argument, list info on that breakpoint.
|
@@ -1677,7 +1669,7 @@ remove an expression from the list, you specify that number. The
|
|
1677
1669
|
automatic display looks like this:
|
1678
1670
|
|
1679
1671
|
@smallexample
|
1680
|
-
(
|
1672
|
+
(byebug:1) display n
|
1681
1673
|
1: n = 3
|
1682
1674
|
@end smallexample
|
1683
1675
|
|
@@ -1687,9 +1679,9 @@ If the expression is undefined or illegal the expression will be
|
|
1687
1679
|
printed but no value will appear.
|
1688
1680
|
|
1689
1681
|
@smallexample
|
1690
|
-
(
|
1682
|
+
(byebug:1) display undefined_variable
|
1691
1683
|
2: undefined_variable =
|
1692
|
-
(
|
1684
|
+
(byebug:1) display 1/0
|
1693
1685
|
3: 1/0 =
|
1694
1686
|
@end smallexample
|
1695
1687
|
|
@@ -1765,11 +1757,11 @@ same as you would if you were in @code{irb}. If there are many expressions
|
|
1765
1757
|
you want to look at, you may want to go into irb from byebug.
|
1766
1758
|
@smallexample
|
1767
1759
|
@group
|
1768
|
-
(
|
1760
|
+
(byebug:p) p n
|
1769
1761
|
3
|
1770
|
-
(
|
1762
|
+
(byebug:1) p "the value of n is #@{n@}"
|
1771
1763
|
"the value of n is 3"
|
1772
|
-
(
|
1764
|
+
(byebug:1)
|
1773
1765
|
@end group
|
1774
1766
|
@end smallexample
|
1775
1767
|
@end table
|
@@ -1782,9 +1774,9 @@ you want to look at, you may want to go into irb from byebug.
|
|
1782
1774
|
Evaluates and pretty-prints @var{expr}
|
1783
1775
|
@smallexample
|
1784
1776
|
@group
|
1785
|
-
(
|
1777
|
+
(byebug:1) @b{p $LOAD_PATH}
|
1786
1778
|
["/home/rocky/lib/ruby", "/usr/lib/ruby/site_ruby/1.8", "/usr/lib/ruby/site_ruby/1.8/i586-linux", "/usr/lib/ruby/1.8"]
|
1787
|
-
(
|
1779
|
+
(byebug:1) @b{pp $LOAD_PATH}
|
1788
1780
|
["/home/rocky/lib/ruby",
|
1789
1781
|
"/usr/lib/ruby/site_ruby/1.8",
|
1790
1782
|
"/usr/lib/ruby/site_ruby/1.8/i586-linux",
|
@@ -1797,7 +1789,7 @@ If the value you want to print is an array, sometimes a columnized
|
|
1797
1789
|
list looks nicer:
|
1798
1790
|
@smallexample
|
1799
1791
|
@group
|
1800
|
-
(
|
1792
|
+
(byebug:1) @b{putl $LOAD_PATH}
|
1801
1793
|
/home/rocky/lib/ruby /usr/lib/ruby/site_ruby/1.8
|
1802
1794
|
/usr/lib/ruby/site_ruby/1.8/i586-linux /usr/lib/ruby/1.8
|
1803
1795
|
@end group
|
@@ -1817,7 +1809,7 @@ and so does the output of the @code{method} commands.
|
|
1817
1809
|
|
1818
1810
|
@smallexample
|
1819
1811
|
@group
|
1820
|
-
(
|
1812
|
+
(byebug:1) ps Kernel.private_methods
|
1821
1813
|
Digest initialize y
|
1822
1814
|
Pathname initialize_copy
|
1823
1815
|
Rational location_of_caller
|
@@ -1861,7 +1853,7 @@ rather than the position may have gotten updated via a prior
|
|
1861
1853
|
@smallexample
|
1862
1854
|
triangle.rb:4
|
1863
1855
|
def triangle(n)
|
1864
|
-
(
|
1856
|
+
(byebug:1) @b{list}
|
1865
1857
|
[-1, 8] in /home/rocky/ruby/triangle.rb
|
1866
1858
|
1 #!/usr/bin/env ruby
|
1867
1859
|
2 # Compute the n'th triangle number - the hard way
|
@@ -1877,7 +1869,7 @@ def triangle(n)
|
|
1877
1869
|
>> @b{exit}
|
1878
1870
|
triangle.rb:4
|
1879
1871
|
def triangle(n)
|
1880
|
-
(
|
1872
|
+
(byebug:1) @b{list # Note we get the same line range as before going into irb}
|
1881
1873
|
[-1, 8] in /home/rocky/ruby/triangle.rb
|
1882
1874
|
1 #!/usr/bin/env ruby
|
1883
1875
|
2 # Compute the n'th triangle number - the hard way
|
@@ -1935,7 +1927,7 @@ Show procedure signature of method @var{object}.
|
|
1935
1927
|
@smallexample
|
1936
1928
|
def mymethod(a, b=5, &bock)
|
1937
1929
|
end
|
1938
|
-
(
|
1930
|
+
(byebug:1) @b{method sig mymethod}
|
1939
1931
|
Mine#mymethod(a, b=5, &bock)
|
1940
1932
|
@end smallexample
|
1941
1933
|
on @var{object}.
|
@@ -2133,7 +2125,7 @@ frame numbers shown. The position of the current frame is marked with
|
|
2133
2125
|
@code{-->}.
|
2134
2126
|
|
2135
2127
|
@smallexample
|
2136
|
-
(
|
2128
|
+
(byebug:1) where
|
2137
2129
|
--> #0 Object.gcd(a#Fixnum, b#Fixnum) at line /tmp/gcd.rb:6
|
2138
2130
|
#1 at line /tmp/gcd.rb:19
|
2139
2131
|
@end smallexample
|
@@ -2280,17 +2272,17 @@ Here's an example:
|
|
2280
2272
|
$ @b{byebug ~/ruby/gcd.rb 3 5}
|
2281
2273
|
/home/rocky/ruby/gcd.rb:4 # Note this is the file name
|
2282
2274
|
def gcd(a, b)
|
2283
|
-
(
|
2275
|
+
(byebug:1) @b{break gcd.rb:6}
|
2284
2276
|
*** No source file named gcd.rb
|
2285
|
-
(
|
2277
|
+
(byebug:1) @b{info line}
|
2286
2278
|
Line 4 of "/home/rocky/ruby/gcd.rb"
|
2287
|
-
(
|
2279
|
+
(byebug:1) @b{break /home/rocky/ruby/gcd.rb:6}
|
2288
2280
|
Breakpoint 1 file /home/rocky/ruby/gcd.rb, line 6
|
2289
|
-
(
|
2281
|
+
(byebug:1) @b{break ~/ruby/gcd.rb:10} # tilde expansion also works
|
2290
2282
|
Breakpoint 2 file /home/rocky/ruby/gcd.rb, line 10
|
2291
|
-
(
|
2283
|
+
(byebug:1) @b{info file gcd.rb}
|
2292
2284
|
File gcd.rb is not cached
|
2293
|
-
(
|
2285
|
+
(byebug:1) @b{info file /home/rocky/ruby/gcd.rb}
|
2294
2286
|
File /home/rocky/ruby/gcd.rb
|
2295
2287
|
19 lines
|
2296
2288
|
@end example
|
@@ -2348,12 +2340,12 @@ only that breakpoint.
|
|
2348
2340
|
|
2349
2341
|
Examples:
|
2350
2342
|
@example
|
2351
|
-
(
|
2343
|
+
(byebug:1) @b{info break}
|
2352
2344
|
Breakpoints at following places:
|
2353
2345
|
Num Enb What
|
2354
2346
|
1 y gcd.rb:3
|
2355
2347
|
2 y gcb.rb:28 if n > 1
|
2356
|
-
(
|
2348
|
+
(byebug:1) @b{info break 2}
|
2357
2349
|
2 y gcb.rb:28 if n > 1
|
2358
2350
|
@end example
|
2359
2351
|
@end table
|
@@ -2668,11 +2660,11 @@ When autoeval is set on, you'll get a different error message when you
|
|
2668
2660
|
invalid commands are encountered. Here's a session fragment to show
|
2669
2661
|
the difference
|
2670
2662
|
@smallexample
|
2671
|
-
(
|
2663
|
+
(byebug:1) @b{stepp}
|
2672
2664
|
Unknown command
|
2673
|
-
(
|
2665
|
+
(byebug:1) @b{set autoeval on}
|
2674
2666
|
autoeval is on.
|
2675
|
-
(
|
2667
|
+
(byebug:1) @b{stepp}
|
2676
2668
|
NameError Exception: undefined local variable or method `stepp' for ...
|
2677
2669
|
@end smallexample
|
2678
2670
|
|
@@ -2950,7 +2942,7 @@ ignored (!); the thread number and the top stack item. If
|
|
2950
2942
|
an example:
|
2951
2943
|
|
2952
2944
|
@smallexample
|
2953
|
-
(
|
2945
|
+
(byebug:7) info threads
|
2954
2946
|
1 #<Thread:0xb7d08704 sleep> ./test/thread1.rb:27
|
2955
2947
|
!2 #<Byebug::DebugThread:0xb7782e4c sleep>
|
2956
2948
|
3 #<Thread:0xb777e220 sleep> ./test/thread1.rb:11
|
@@ -2958,14 +2950,14 @@ an example:
|
|
2958
2950
|
5 #<Thread:0xb777e07c sleep> ./test/thread1.rb:11
|
2959
2951
|
6 #<Thread:0xb777dfb4 sleep> ./test/thread1.rb:11
|
2960
2952
|
+ 7 #<Thread:0xb777deec run> ./test/thread1.rb:14
|
2961
|
-
(
|
2953
|
+
(byebug:1)
|
2962
2954
|
@end smallexample
|
2963
2955
|
|
2964
2956
|
Thread 7 is the current thread since it has a plus sign in front. Thread 2 is
|
2965
2957
|
ignored since it has a @code{!}. A ``verbose'' listing of the above:
|
2966
2958
|
|
2967
2959
|
@smallexample
|
2968
|
-
(
|
2960
|
+
(byebug:7) info threads verbose
|
2969
2961
|
1 #<Thread:0xb7d08704 sleep>
|
2970
2962
|
#0 Integer.join at line test/thread1.rb:27
|
2971
2963
|
#1 at line test/thread1.rb:27
|
@@ -3037,7 +3029,7 @@ post-mortem debugging set the @code{post_mortem} key in
|
|
3037
3029
|
|
3038
3030
|
$ @b{ruby t.rb }
|
3039
3031
|
t.rb:8: raise 'test'
|
3040
|
-
(
|
3032
|
+
(byebug:post-mortem) @b{l=}
|
3041
3033
|
[3, 12] in t.rb
|
3042
3034
|
3
|
3043
3035
|
4 Byebug.start
|
@@ -3049,7 +3041,7 @@ post-mortem debugging set the @code{post_mortem} key in
|
|
3049
3041
|
10 def t2
|
3050
3042
|
11 t1
|
3051
3043
|
12 end
|
3052
|
-
(
|
3044
|
+
(byebug:post-mortem)
|
3053
3045
|
@end smallexample
|
3054
3046
|
|
3055
3047
|
Alternatively you can call @code{Byebug.post_mortem()} after byebug has
|
@@ -3080,7 +3072,7 @@ end
|
|
3080
3072
|
@end smallexample
|
3081
3073
|
|
3082
3074
|
Once inside byebug in post-mortem debugging, the prompt should
|
3083
|
-
be @code{(
|
3075
|
+
be @code{(byebug:post-mortem)}.
|
3084
3076
|
|
3085
3077
|
@node Byebug Module and Class
|
3086
3078
|
@chapter The Byebug Module and Class
|
@@ -3444,7 +3436,7 @@ And now an example of invoking it:
|
|
3444
3436
|
ruby /tmp/testit.rb:
|
3445
3437
|
/tmp/testit.rb:7
|
3446
3438
|
y=2
|
3447
|
-
(
|
3439
|
+
(byebug:1) help
|
3448
3440
|
byebug help v0.10.3
|
3449
3441
|
Type 'help <command-name>' for help on a specific command
|
3450
3442
|
Available commands:
|
@@ -3455,11 +3447,11 @@ condition down finish list pp restart step var
|
|
3455
3447
|
continue edit frame me ps save thread where
|
3456
3448
|
^^ This is you
|
3457
3449
|
|
3458
|
-
(
|
3450
|
+
(byebug:1) help me
|
3459
3451
|
This does whatever it is I want to do
|
3460
|
-
(
|
3452
|
+
(byebug:1) me
|
3461
3453
|
hi
|
3462
|
-
(
|
3454
|
+
(byebug:1)
|
3463
3455
|
@end smallexample
|
3464
3456
|
|
3465
3457
|
@node Kernel routines
|
@@ -3490,9 +3482,9 @@ y = 1
|
|
3490
3482
|
|
3491
3483
|
$ scope-test.rb:8
|
3492
3484
|
y = 1
|
3493
|
-
(
|
3485
|
+
(byebug:1) p a
|
3494
3486
|
NameError Exception: undefined local variable or method `a' for main:Object
|
3495
|
-
(
|
3487
|
+
(byebug:1)
|
3496
3488
|
@end smallexample
|
3497
3489
|
The byebug will get at the line event which follows @samp{a=1}. This
|
3498
3490
|
is outside the @code{do} block scope where @var{a} is defined. If
|
@@ -3512,15 +3504,15 @@ y = 1
|
|
3512
3504
|
$ scope-test.rb:8
|
3513
3505
|
../lib/byebug-base.rb:175
|
3514
3506
|
Byebug.current_context.stop_frame = 0
|
3515
|
-
(
|
3507
|
+
(byebug:1) where
|
3516
3508
|
--> #0 Kernel.byebug(steps#Fixnum) at line ../lib/byebug-base.rb:175
|
3517
3509
|
#1 at line scope-test.rb:6
|
3518
3510
|
#2 at line scope-test.rb:4
|
3519
|
-
(
|
3511
|
+
(byebug:1) up
|
3520
3512
|
#1 at line scope-test.rb:6
|
3521
|
-
(
|
3513
|
+
(byebug:1) p a
|
3522
3514
|
1
|
3523
|
-
(
|
3515
|
+
(byebug:1)
|
3524
3516
|
@end smallexample
|
3525
3517
|
As seen above you will have to position the frame up one to be back in
|
3526
3518
|
your debugged program rather than in byebug.
|