byebug 1.5.0 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c4921997bbc597c75dbd51c1a5abde4fa366ce05
4
- data.tar.gz: e56edf6e9529823d52edfe543ed9f450258bf893
3
+ metadata.gz: 21d46be2dda181855988404a2aff8d7bc0c01873
4
+ data.tar.gz: 51485fdf716aec89695f1b6bff72dfab4d326ebd
5
5
  SHA512:
6
- metadata.gz: 69d7c6ffe0e19f58695bc007a1b44b44e743cd669939a53b0c491d209d417f4f963ca18085d07c5b7ca5a9fe7820ca59455bd2ec269c9a6963d3bdfe0a75bffe
7
- data.tar.gz: ce3049894fe8169c214ce6953dd468a3343caa1e45971f093d9a73e5f3c6b778d4fa51b0ecbdb3806094b776fb4adecb4965c77689e5470a2a7fed5503dc5fce
6
+ metadata.gz: e59c28c8f7ded85eaca1a7ef0af86c3226ac2db743c30f8b14326efa4584c9b4f5708c5b6019dff559e69a9b51d139504cf2b4bdaecbb0f93f69446bd33a32cd
7
+ data.tar.gz: ae2afdb68a86af438860f730477ee2af4a5ecb7b65c07171f27cc40028ecfcc664d526f9bcf964148b4bb38b864daee5ff369cf480612a949f6c4817c37a599f
data/.gitignore CHANGED
@@ -9,6 +9,8 @@ doc
9
9
  .gdb_history
10
10
  .bundle
11
11
  .tags
12
+ .ackrc
13
+ .jrubyrc
12
14
 
13
15
  Gemfile.lock
14
16
 
@@ -1,4 +1,3 @@
1
- before_install: gem install bundler
2
1
  before_script: rake compile
3
2
  rvm:
4
3
  - 2.0.0
@@ -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
- ## Command Files
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
- Inside a byebug interpreter, use `quit` command to finish execution. Another way
685
- to terminate byebug is to use the `kill` command. This does the more forceful
686
- `kill -9`. It can be used in cases where `quit` doesn't work (I haven't seen it
687
- yet).
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
- ## Calling byebug from inside your program
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
- ## Command Syntax
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) `help`
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
@@ -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->stop_frame)
237
+ if (dc->stack_size + 1 == dc->before_frame)
230
238
  {
231
- dc->steps = 1;
232
- dc->stop_frame = -1;
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);
@@ -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 stop_frame; /* frame number after which we must stop */
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;
@@ -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 = -1;
11
- context->lines = -1;
12
- context->steps = -1;
13
- context->stop_frame = -1;
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->stop_frame = context->stack_size - FIX2INT(frame);
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
  }
@@ -246,22 +246,13 @@ end
246
246
 
247
247
  module Kernel
248
248
  ##
249
- # Enters byebug after _steps_ line events occur.
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
- # Before entering byebug startup, the init script is read. Setting _steps_ to
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 0 == steps
261
- Byebug.context.step_out
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
@@ -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, :last)
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)