byebug 1.5.0 → 1.6.0
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/.gitignore +2 -0
- data/.travis.yml +0 -1
- data/CHANGELOG.md +8 -0
- data/GUIDE.md +52 -32
- data/README.md +6 -0
- data/ext/byebug/byebug.c +19 -3
- data/ext/byebug/byebug.h +4 -3
- data/ext/byebug/context.c +21 -5
- data/lib/byebug.rb +5 -14
- data/lib/byebug/command.rb +1 -1
- data/lib/byebug/commands/frame.rb +28 -44
- data/lib/byebug/commands/info.rb +2 -1
- data/lib/byebug/commands/list.rb +1 -1
- data/lib/byebug/commands/repl.rb +7 -21
- data/lib/byebug/commands/set.rb +4 -9
- data/lib/byebug/commands/trace.rb +2 -2
- data/lib/byebug/context.rb +7 -16
- data/lib/byebug/processor.rb +16 -18
- data/lib/byebug/version.rb +1 -1
- data/old_doc/byebug.texi +12 -17
- data/test/breakpoints_test.rb +75 -61
- data/test/conditions_test.rb +7 -7
- data/test/continue_test.rb +5 -5
- data/test/display_test.rb +6 -6
- data/test/edit_test.rb +2 -2
- data/test/examples/{breakpoint1.rb → breakpoint.rb} +0 -0
- data/test/examples/breakpoint_deep.rb +24 -0
- data/test/finish_test.rb +5 -5
- data/test/frame_test.rb +27 -38
- data/test/jump_test.rb +6 -7
- data/test/list_test.rb +1 -1
- data/test/post_mortem_test.rb +1 -1
- data/test/repl_test.rb +4 -40
- data/test/set_test.rb +3 -3
- data/test/show_test.rb +1 -1
- data/test/stepping_test.rb +15 -16
- data/test/support/test_dsl.rb +9 -16
- data/test/trace_test.rb +2 -2
- metadata +6 -6
- data/test/support/mocha_extensions.rb +0 -71
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 21d46be2dda181855988404a2aff8d7bc0c01873
|
4
|
+
data.tar.gz: 51485fdf716aec89695f1b6bff72dfab4d326ebd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e59c28c8f7ded85eaca1a7ef0af86c3226ac2db743c30f8b14326efa4584c9b4f5708c5b6019dff559e69a9b51d139504cf2b4bdaecbb0f93f69446bd33a32cd
|
7
|
+
data.tar.gz: ae2afdb68a86af438860f730477ee2af4a5ecb7b65c07171f27cc40028ecfcc664d526f9bcf964148b4bb38b864daee5ff369cf480612a949f6c4817c37a599f
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
## 1.6.0
|
2
|
+
|
3
|
+
* `byebug` placed at the end of a block or method call now works as expected
|
4
|
+
* Don't autolist when ruby '-e' option is used
|
5
|
+
* Fixes callstyles. From now on, use 'long' for detailed frames in callstack and
|
6
|
+
'short' for more concise frames
|
7
|
+
|
8
|
+
|
1
9
|
## 1.5.0
|
2
10
|
|
3
11
|
* No more Byebug.start to get correct callstack information! Dropping `byebug`
|
data/GUIDE.md
CHANGED
@@ -5,7 +5,7 @@ Below we will debug a simple Ruby program to solve the classic Towers of Hanoi
|
|
5
5
|
puzzle. It is augmented by the bane of programming: some command-parameter
|
6
6
|
processing with error checking.
|
7
7
|
|
8
|
-
```
|
8
|
+
```bash
|
9
9
|
$ byebug hanoi.rb
|
10
10
|
[1, 10] in /home/davidr/Proyectos/byebug/old_doc/hanoi.rb
|
11
11
|
1: # Solves the classic Towers of Hanoi puzzle.
|
@@ -25,7 +25,7 @@ Recall in the first section iwe said that before the `def` is run, the method it
|
|
25
25
|
names is undefined. Let's check that out. First let's see what private methods
|
26
26
|
we can call before running `def hanoi`.
|
27
27
|
|
28
|
-
```
|
28
|
+
```bash
|
29
29
|
(byebug) private_methods
|
30
30
|
[:public, :private, :include, :using, :define_method, :default_src_encoding, ...
|
31
31
|
```
|
@@ -39,7 +39,7 @@ whether `hanoi` method is in the list. Fortunately, byebug has nice formatting
|
|
39
39
|
features: we can sort the output and put it into columns list using the print
|
40
40
|
command `ps`.
|
41
41
|
|
42
|
-
```
|
42
|
+
```bash
|
43
43
|
(byebug) ps private_methods
|
44
44
|
Array debug_program open sprintf
|
45
45
|
Complex default_src_encoding p srand
|
@@ -71,7 +71,7 @@ dbg_puts method_missing spawn
|
|
71
71
|
|
72
72
|
Now let's see what happens after stepping:
|
73
73
|
|
74
|
-
```
|
74
|
+
```bash
|
75
75
|
(byebug) private_methods.member?(:hanoi)
|
76
76
|
false
|
77
77
|
(byebug:1) step
|
@@ -93,7 +93,7 @@ true
|
|
93
93
|
|
94
94
|
Okay, lets go on and talk about program arguments.
|
95
95
|
|
96
|
-
```
|
96
|
+
```bash
|
97
97
|
(byebug) ARGV
|
98
98
|
[]
|
99
99
|
```
|
@@ -101,7 +101,7 @@ Okay, lets go on and talk about program arguments.
|
|
101
101
|
Ooops. We forgot to specify any parameters to this program. Let's try again. We
|
102
102
|
can use the `restart` command here.
|
103
103
|
|
104
|
-
```
|
104
|
+
```bash
|
105
105
|
(byebug) restart 3
|
106
106
|
Re exec'ing:
|
107
107
|
/home/davidr/.rvm/gems/ruby-2.0.0-p195@byebug/gems/byebug-1.1.1/bin/byebug /home/davidr/Proyectos/byebug/old_doc/hanoi.rb 3
|
@@ -202,7 +202,7 @@ trace (see [callstyle]()).
|
|
202
202
|
|
203
203
|
Now let's move around the callstack.
|
204
204
|
|
205
|
-
```
|
205
|
+
```bash
|
206
206
|
(byebug) undisplay
|
207
207
|
Clear all expressions? (y/n) y
|
208
208
|
(byebug:1) i_args
|
@@ -253,7 +253,7 @@ look at the file, I have an example of how to run it. Therefore we will
|
|
253
253
|
conditionally run this line if that file is invoked directly, but skip it if it
|
254
254
|
is not. _NOTE: `byebug` resets `$0` to try to make things like this work._
|
255
255
|
|
256
|
-
```
|
256
|
+
```ruby
|
257
257
|
if __FILE__ == $0
|
258
258
|
t = triangle(3)
|
259
259
|
puts t
|
@@ -292,7 +292,8 @@ def test_basic
|
|
292
292
|
```
|
293
293
|
|
294
294
|
Now we run the program, requiring `byebug`
|
295
|
-
|
295
|
+
|
296
|
+
```bash
|
296
297
|
$ ruby -rbyebug test-triangle.rb
|
297
298
|
Run options: --seed 13073
|
298
299
|
|
@@ -316,7 +317,8 @@ and we see that we are stopped at line 7 just before the initialization of the
|
|
316
317
|
list `solutions`.
|
317
318
|
|
318
319
|
Now let's see where we are...
|
319
|
-
|
320
|
+
|
321
|
+
```bash
|
320
322
|
(byebug) set nofullpath
|
321
323
|
Displaying frame's full file names is off.
|
322
324
|
(byebug) bt
|
@@ -366,7 +368,7 @@ Of course, inside the block you will probably want to enter the byebug using
|
|
366
368
|
`Byebug.byebug()`, otherwise there would be little point in using the `start`.
|
367
369
|
For example, you can do this in `irb`:
|
368
370
|
|
369
|
-
```
|
371
|
+
```bash
|
370
372
|
$ irb
|
371
373
|
2.0.0p195 :001 > require 'byebug'
|
372
374
|
=> true
|
@@ -424,7 +426,6 @@ not necessarily go to the first statement after the method header. It's possible
|
|
424
426
|
that the call will continue after a `yield` statement from a prior call.
|
425
427
|
|
426
428
|
```ruby
|
427
|
-
|
428
429
|
# Enumerator for primes
|
429
430
|
class SievePrime
|
430
431
|
@@odd_primes = []
|
@@ -452,7 +453,7 @@ SievePrime.next_prime do |prime|
|
|
452
453
|
end
|
453
454
|
```
|
454
455
|
|
455
|
-
```
|
456
|
+
```bash
|
456
457
|
$ byebug primes.rb
|
457
458
|
[1, 10] in /home/davidr/Proyectos/byebug/old_doc/primes.rb
|
458
459
|
1: # Enumerator for primes
|
@@ -554,7 +555,7 @@ To be continued...
|
|
554
555
|
There is a wrapper script called `byebug` which basically `require`'s the gem
|
555
556
|
then loads `byebug` before its argument (the program to be debugged) is started.
|
556
557
|
|
557
|
-
```
|
558
|
+
```bash
|
558
559
|
byebug [byebug-options] [--] ruby-script ruby-script-arguments
|
559
560
|
```
|
560
561
|
|
@@ -562,7 +563,7 @@ If you don't need to pass dash options to your program, which might be confused
|
|
562
563
|
with byebug options, then you don't need to add the `--`. To get a brief list of
|
563
564
|
options and descriptions, use the `--help` option.
|
564
565
|
|
565
|
-
```
|
566
|
+
```bash
|
566
567
|
$ byebug --help
|
567
568
|
byebug 1.4.0
|
568
569
|
Usage: byebug [options] <script.rb> -- <script.rb parameters>
|
@@ -616,7 +617,7 @@ already a debugger. This option is compatible with Ruby's.
|
|
616
617
|
<rubyscript>.rb`. If all you want to do however is get a linetrace, `tracer` is
|
617
618
|
most likely faster than `byebug`
|
618
619
|
|
619
|
-
```
|
620
|
+
```bash
|
620
621
|
$ time ruby -rtracer old_doc/gcd.rb 24 31 >/dev/null
|
621
622
|
|
622
623
|
real 0m0.066s
|
@@ -657,7 +658,7 @@ Here are the default values in `options`
|
|
657
658
|
stop=true, tracing=false, verbose_long=false>
|
658
659
|
```
|
659
660
|
|
660
|
-
|
661
|
+
### Command Files
|
661
662
|
|
662
663
|
A command file is a file of lines that are `byebug` commands. Comments (lines
|
663
664
|
starting with `#`) may also be included. An empty line in a command file does
|
@@ -679,14 +680,18 @@ directory where you invoke `byebug`.
|
|
679
680
|
You can also request the execution of a command file with the `source` command
|
680
681
|
(see [Source]()).
|
681
682
|
|
682
|
-
## Quitting byebug
|
683
683
|
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
684
|
+
### Quitting byebug
|
685
|
+
|
686
|
+
To exit `byebug`, use the `quit` command (abbreviated `q` and aliased `exit`).
|
687
|
+
Normally if you are in an interactive session, this command will prompt to ask
|
688
|
+
if you really want to quit. If you don't want any questions asked, enter
|
689
|
+
`quit unconditionally` (abbreviated `q!`). Another way to terminate byebug is to
|
690
|
+
use the `kill` command. This does the more forceful `kill -9`. It can be used in
|
691
|
+
cases where `quit` doesn't work (I haven't seen those yet).
|
692
|
+
|
688
693
|
|
689
|
-
|
694
|
+
### Calling byebug from inside your program
|
690
695
|
|
691
696
|
Running a program from byebug adds a bit of overhead and slows it down a little.
|
692
697
|
Furthermore, by necessity, debuggers change the operation of the program they
|
@@ -724,9 +729,23 @@ possible to enclose it in a conditional expression, for example
|
|
724
729
|
byebug if 'bar' == foo and 20 == iter_count
|
725
730
|
```
|
726
731
|
|
732
|
+
### Restarting Byebug
|
733
|
+
|
734
|
+
You can restart the program using `restart [program args]`. This is a re-exec -
|
735
|
+
all byebug state is lost. If command arguments are passed, those are used.
|
736
|
+
Otherwise program arguments from the last invocation are used.
|
737
|
+
|
738
|
+
You won't be able to restart your program in all cases. First, the program
|
739
|
+
should have been invoked at the outset rather than having been called from
|
740
|
+
inside your program or invoked as a result of post-mortem handling.
|
741
|
+
|
742
|
+
Also, since this relies on the OS `exec` call, this command is available only if
|
743
|
+
your OS supports `exec`.
|
744
|
+
|
745
|
+
|
727
746
|
## Byebug Command Reference
|
728
747
|
|
729
|
-
|
748
|
+
### Command Syntax
|
730
749
|
Usually a command is put on a single line. There is no limit on how long it can be.
|
731
750
|
It starts with a command name, which is followed by arguments whose meaning depends
|
732
751
|
on the command name. For example, the command `step` accepts an argument which is the
|
@@ -740,7 +759,7 @@ backslash.
|
|
740
759
|
For example, if you have [autoeval]() set, which is the default, you might want to
|
741
760
|
enter the following code to compute the 5th Fibonacci number.
|
742
761
|
|
743
|
-
```
|
762
|
+
```bash
|
744
763
|
(byebug) fib1=0; fib2=1; 5.times {|temp| temp=fib1; fib1=fib2; fib2 += temp }
|
745
764
|
0
|
746
765
|
1
|
@@ -784,13 +803,14 @@ location position, it will generally preface the message with `***`. However if
|
|
784
803
|
annotation mode is on then the message is put in a `begin-error` annotation and no
|
785
804
|
`***` appears.
|
786
805
|
|
787
|
-
### Help
|
806
|
+
### Command Help
|
807
|
+
|
788
808
|
Once inside `byebug` you can always ask it for information on its commands using the
|
789
809
|
`help` command. You can use `help` (abbreviated `h`) with no arguments to display a
|
790
810
|
short list of named classes of commands
|
791
811
|
|
792
|
-
```
|
793
|
-
(byebug)
|
812
|
+
```bash
|
813
|
+
(byebug) help
|
794
814
|
Type "help <command-name>" for help on a specific command
|
795
815
|
|
796
816
|
Available commands:
|
@@ -805,7 +825,7 @@ var
|
|
805
825
|
With a command name as `help` argument, `byebug` displays short information on how to
|
806
826
|
use that command.
|
807
827
|
|
808
|
-
```
|
828
|
+
```bash
|
809
829
|
(byebug) help list
|
810
830
|
l[ist] list forward
|
811
831
|
l[ist] - list backward
|
@@ -827,7 +847,7 @@ letters to make that subcommand distinct from others will do. For example,
|
|
827
847
|
|
828
848
|
Some examples follow.
|
829
849
|
|
830
|
-
```
|
850
|
+
```bash
|
831
851
|
(byebug) help info
|
832
852
|
info[ subcommand]
|
833
853
|
|
@@ -854,14 +874,14 @@ info variables -- Local and instance variables of the current stack
|
|
854
874
|
frame
|
855
875
|
```
|
856
876
|
|
857
|
-
```
|
877
|
+
```bash
|
858
878
|
(byebug) help info breakpoints
|
859
879
|
Status of user-settable breakpoints.
|
860
880
|
Without argument, list info about all breakpoints.
|
861
881
|
With an integer argument, list info on that breakpoint.
|
862
882
|
```
|
863
883
|
|
864
|
-
```
|
884
|
+
```bash
|
865
885
|
(byebug) help info br
|
866
886
|
Status of user-settable breakpoints.
|
867
887
|
Without argument, list info about all breakpoints.
|
data/README.md
CHANGED
@@ -32,6 +32,10 @@ in your Gemfile and run
|
|
32
32
|
|
33
33
|
bundle install
|
34
34
|
|
35
|
+
**Please upgrade your ruby to 2.0.0-p247 or higher** - a bug in ruby core was
|
36
|
+
directly affecting byebug and a fix for it has been released with this
|
37
|
+
patchlevel (see [#5](https://github.com/deivid-rodriguez/byebug/issues/5) for
|
38
|
+
more information)
|
35
39
|
|
36
40
|
## Usage
|
37
41
|
|
@@ -73,6 +77,8 @@ because it is a default option in byebug.
|
|
73
77
|
- Colon delimited include paths.
|
74
78
|
- Nice markdow guide.
|
75
79
|
- Ruby 2.0 support.
|
80
|
+
- where/bt does not in fact give a backtrace.
|
81
|
+
- `byebug` can now be placed at the end of a block or method call.
|
76
82
|
* Very actively mantained.
|
77
83
|
* Editor agnostic: no external editor built-in support.
|
78
84
|
* No thread support as not supported by the new API yet (I hope it will come
|
data/ext/byebug/byebug.c
CHANGED
@@ -117,6 +117,14 @@ call_at_catchpoint(VALUE context_obj, debug_context_t *dc, VALUE exp)
|
|
117
117
|
return call_at(context_obj, dc, rb_intern("at_catchpoint"), 1, exp, 0);
|
118
118
|
}
|
119
119
|
|
120
|
+
static VALUE
|
121
|
+
call_at_return(VALUE context_obj, debug_context_t *dc, VALUE file, VALUE line)
|
122
|
+
{
|
123
|
+
dc->stop_reason = CTX_STOP_BREAKPOINT;
|
124
|
+
return call_at(context_obj, dc, rb_intern("at_return"), 2, file, line);
|
125
|
+
|
126
|
+
}
|
127
|
+
|
120
128
|
static void
|
121
129
|
call_at_line_check(VALUE context_obj, debug_context_t *dc,
|
122
130
|
VALUE breakpoint, VALUE file, VALUE line)
|
@@ -226,10 +234,18 @@ process_return_event(VALUE trace_point, void *data)
|
|
226
234
|
if (dc->stack_size > 0) dc->stack_size--;
|
227
235
|
EVENT_COMMON();
|
228
236
|
|
229
|
-
if (dc->stack_size + 1 == dc->
|
237
|
+
if (dc->stack_size + 1 == dc->before_frame)
|
230
238
|
{
|
231
|
-
dc
|
232
|
-
|
239
|
+
reset_stepping_stop_points(dc);
|
240
|
+
VALUE file = rb_tracearg_path(trace_arg);
|
241
|
+
VALUE line = rb_tracearg_lineno(trace_arg);
|
242
|
+
call_at_return(context, dc, file, line);
|
243
|
+
}
|
244
|
+
|
245
|
+
if (dc->stack_size + 1 == dc->after_frame)
|
246
|
+
{
|
247
|
+
reset_stepping_stop_points(dc);
|
248
|
+
dc->steps = 1;
|
233
249
|
}
|
234
250
|
|
235
251
|
cleanup(dc);
|
data/ext/byebug/byebug.h
CHANGED
@@ -32,9 +32,10 @@ typedef struct {
|
|
32
32
|
ctx_stop_reason stop_reason;
|
33
33
|
|
34
34
|
int dest_frame;
|
35
|
-
int lines; /* # of lines in dest_frame before stopping
|
36
|
-
int steps; /* # of steps before stopping
|
37
|
-
int
|
35
|
+
int lines; /* # of lines in dest_frame before stopping */
|
36
|
+
int steps; /* # of steps before stopping */
|
37
|
+
int after_frame; /* stop rigth after returning from this frame */
|
38
|
+
int before_frame; /* stop right before returning from this frame */
|
38
39
|
|
39
40
|
VALUE last_file;
|
40
41
|
VALUE last_line;
|
data/ext/byebug/context.c
CHANGED
@@ -7,10 +7,11 @@ static VALUE cContext;
|
|
7
7
|
extern void
|
8
8
|
reset_stepping_stop_points(debug_context_t *context)
|
9
9
|
{
|
10
|
-
context->dest_frame
|
11
|
-
context->lines
|
12
|
-
context->steps
|
13
|
-
context->
|
10
|
+
context->dest_frame = -1;
|
11
|
+
context->lines = -1;
|
12
|
+
context->steps = -1;
|
13
|
+
context->after_frame = -1;
|
14
|
+
context->before_frame = -1;
|
14
15
|
}
|
15
16
|
|
16
17
|
static inline VALUE
|
@@ -384,7 +385,21 @@ Context_step_out(VALUE self, VALUE frame)
|
|
384
385
|
if (FIX2INT(frame) < 0 || FIX2INT(frame) >= context->stack_size)
|
385
386
|
rb_raise(rb_eRuntimeError, "Stop frame is out of range.");
|
386
387
|
|
387
|
-
context->
|
388
|
+
context->after_frame = context->stack_size - FIX2INT(frame);
|
389
|
+
|
390
|
+
return frame;
|
391
|
+
}
|
392
|
+
|
393
|
+
static VALUE
|
394
|
+
Context_stop_return(VALUE self, VALUE frame)
|
395
|
+
{
|
396
|
+
debug_context_t *context;
|
397
|
+
Data_Get_Struct(self, debug_context_t, context);
|
398
|
+
|
399
|
+
if (FIX2INT(frame) < 0 || FIX2INT(frame) >= context->stack_size)
|
400
|
+
rb_raise(rb_eRuntimeError, "Stop frame is out of range.");
|
401
|
+
|
402
|
+
context->before_frame = context->stack_size - FIX2INT(frame);
|
388
403
|
|
389
404
|
return frame;
|
390
405
|
}
|
@@ -414,6 +429,7 @@ Init_context(VALUE mByebug)
|
|
414
429
|
rb_define_method(cContext, "step_into", Context_step_into, -1);
|
415
430
|
rb_define_method(cContext, "step_over", Context_step_over, -1);
|
416
431
|
rb_define_method(cContext, "step_out", Context_step_out, 1);
|
432
|
+
rb_define_method(cContext, "stop_return", Context_stop_return, 1);
|
417
433
|
|
418
434
|
return cContext;
|
419
435
|
}
|
data/lib/byebug.rb
CHANGED
@@ -246,22 +246,13 @@ end
|
|
246
246
|
|
247
247
|
module Kernel
|
248
248
|
##
|
249
|
-
# Enters byebug after
|
249
|
+
# Enters byebug after _steps_into_ line events and _steps_out_ return events
|
250
|
+
# occur. Before entering byebug startup, the init script is read.
|
250
251
|
#
|
251
|
-
|
252
|
-
# 0 will cause a break in byebug's subroutine and not wait for a line event to
|
253
|
-
# occur. You will have to go "up 1" in order to be back to your debugged
|
254
|
-
# program from byebug. Setting _steps_ to 0 could be useful if you want to
|
255
|
-
# stop right after the last statement in some scope, because the next step
|
256
|
-
# will take you out of some scope.
|
257
|
-
def byebug(steps = 1)
|
252
|
+
def byebug(steps_into = 1, steps_out = 2)
|
258
253
|
Byebug.start
|
259
254
|
Byebug.run_init_script(StringIO.new)
|
260
|
-
if
|
261
|
-
|
262
|
-
else
|
263
|
-
Byebug.context.step_into steps
|
264
|
-
end
|
255
|
+
Byebug.context.stop_return steps_out if steps_out >= 1
|
256
|
+
Byebug.context.step_into steps_into if steps_into >= 0
|
265
257
|
end
|
266
|
-
alias breakpoint byebug unless respond_to?(:breakpoint)
|
267
258
|
end
|
data/lib/byebug/command.rb
CHANGED
@@ -152,7 +152,7 @@ module Byebug
|
|
152
152
|
|
153
153
|
# Register default settings
|
154
154
|
register_setting_var(:basename, false)
|
155
|
-
register_setting_var(:callstyle, :
|
155
|
+
register_setting_var(:callstyle, :long)
|
156
156
|
register_setting_var(:testing, false)
|
157
157
|
register_setting_var(:force_stepping, false)
|
158
158
|
register_setting_var(:frame_fullpath, true)
|