byebug 6.0.2 → 7.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9bd941f093c6a49a371dfefe4cb06d9285eb5154
4
- data.tar.gz: cc056395c95ece29b62647a4875d759ac18708c6
3
+ metadata.gz: 075e48a583d6bdc5ec0cd4ce6cf195412476d722
4
+ data.tar.gz: 8e755e6afcc87f2fb06109c9fdc0dd8e052a1736
5
5
  SHA512:
6
- metadata.gz: 092d68626a8dc9190494a66d84405c5e36b709e1ca2548eb4b76e7b949aa1605548e3cc7a19aeb5988cc1480adfc21619f5603dce31471020ef2c04c83c287e7
7
- data.tar.gz: e6d15db6847705de02000c299a1ca7be98d63e4f15ac306348a82d19d9667f90451c01dbee66c12744d4166f558bffbb1cf9f3ac7f46861b3cbde8257cda2576
6
+ metadata.gz: def5daed567d526f9cf7ad3af964a997e18aeedaf9349f23c5e9e25534c9c3711a6e1688efbfc317da99b83508035ff9db4a9d64f12ba56fb671422044a8103b
7
+ data.tar.gz: bac9c0be89f64f58403218158b92686734bcf7a5771f4d6eac6e9c7cd4a91ebcf28d476d3e8c3e447c4bf01ba534a60651ce33dec7e04ad81edc4372ff89110a
@@ -1,3 +1,33 @@
1
+ ## 7.0.0 - 2015-11-04
2
+ ### Fixed
3
+ * [#177](https://github.com/deivid-rodriguez/byebug/issues/177). Some issues
4
+ with formatting results of evaluations.
5
+ * [#144](https://github.com/deivid-rodriguez/byebug/issues/144). Ruby process
6
+ after using byebug does no longer get slow.
7
+ * [#121](https://github.com/deivid-rodriguez/byebug/issues/121). `byebug`
8
+ commands inside code evaluated from debugger's prompt are now properly working.
9
+ * Another evaluation bug in autocommands.
10
+ * `finish 0` command would sometimes fail to stop right before exiting the
11
+ current frame.
12
+ * Runner's `--[no-]stop` option now works (thanks @windwiny).
13
+ * Change variable name `bool`, avoid conflict clang's predefined macro
14
+
15
+ ### Removed
16
+ * `ps` command.
17
+
18
+ ### Changed
19
+ * [#166](https://github.com/deivid-rodriguez/byebug/issues/166). Don't load
20
+ the entire library on require, but only when a `byebug` call is issued. Thanks
21
+ @bquorning.
22
+ * The above fix to the `finish 0` command cause `byebug`'s entrypoint to
23
+ require 3 steps out instead of 2. In general, plugins using
24
+ `Byebug::Context.step_out` will need to be changed to consider "c return events"
25
+ as well.
26
+
27
+ ### Added
28
+ * `autopry` setting that calls `pry` on every stop.
29
+ * Return value information to debugger's output when `finish 0` is used.
30
+
1
31
  ## 6.0.2 - 2015-08-20
2
32
  ### Fixed
3
33
  * The user should always be given back a prompt unless (s)he explicitly states
@@ -1,4 +1,18 @@
1
- ## Getting started
1
+ ## Contributing to Byebug
2
+
3
+ ### Bug Reports
4
+
5
+ * Try to reproduce the issue against the latest revision. There might be
6
+ unrealeased work that fixes your problem!
7
+
8
+ * Ensure that your issue has not already been reported.
9
+
10
+ * Include the steps you carried out to produce the problem. If we can't
11
+ reproduce it, we can't fix it.
12
+
13
+ * Include the behavior you observed along with the behavior you expected,
14
+ and why you expected it.
15
+
2
16
 
3
17
  ### Development dependencies
4
18
 
@@ -25,16 +39,20 @@ test`.
25
39
  * If you want to run specific tests, use the provided test runner, like so:
26
40
 
27
41
  - Specific test files. For example,
28
- `script/minitest_runner test/commands/break_test.rb`
42
+ `script/minitest_runner.rb test/commands/break_test.rb`
29
43
 
30
44
  - Specific test classes. For example,
31
- `script/minitest_runner Byebug::BreakAtLinesTestCase`
45
+ `script/minitest_runner.rb Byebug::BreakAtLinesTestCase`
32
46
 
33
47
  - Specific tests. For example,
34
- `script/minitest_runner test_catch_removes_specific_catchpoint`
48
+ `script/minitest_runner.rb test_catch_removes_specific_catchpoint`
49
+
50
+ - Specific fully qualified tests. For example,
51
+ `script/minitest_runner.rb
52
+ BreakAtLinesTest#test_setting_breakpoint_sets_correct_fields`
35
53
 
36
54
  - You can combine any of them and you will get the union of all filters. For
37
- example: `script/minitest_runner Byebug::BreakAtLinesTestCase
55
+ example: `script/minitest_runner.rb Byebug::BreakAtLinesTestCase
38
56
  test_catch_removes_specific_catchpoint`
39
57
 
40
58
 
data/GUIDE.md CHANGED
@@ -297,98 +297,7 @@ false
297
297
  `private_methods` is not a byebug command but a Ruby feature. By default, when
298
298
  `byebug` doesn't understand a command, it will evaluate it as if it was a Ruby
299
299
  command. You can use any Ruby to inspect your program's state at the place it
300
- is stopped. Additional, `byebug` provides a specific evaluation command, `ps`
301
- that automatically enhances the evaluated results a bit. For example, it
302
- automatically sorts arrays.
303
-
304
- ```
305
- [:Array,
306
- :Complex,
307
- :DelegateClass,
308
- :Digest,
309
- :Float,
310
- :Hash,
311
- :Integer,
312
- :Pathname,
313
- :Rational,
314
- :String,
315
- :URI,
316
- :__callee__,
317
- :__dir__,
318
- :__method__,
319
- :`,
320
- :abort,
321
- :at_exit,
322
- :autoload,
323
- :autoload?,
324
- :binding,
325
- :block_given?,
326
- :caller,
327
- :caller_locations,
328
- :catch,
329
- :default_src_encoding,
330
- :define_method,
331
- :eval,
332
- :exec,
333
- :exit,
334
- :exit!,
335
- :fail,
336
- :fork,
337
- :format,
338
- :gem_original_require,
339
- :gets,
340
- :global_variables,
341
- :include,
342
- :initialize,
343
- :initialize_clone,
344
- :initialize_copy,
345
- :initialize_dup,
346
- :iterator?,
347
- :lambda,
348
- :load,
349
- :local_variables,
350
- :loop,
351
- :method_missing,
352
- :open,
353
- :p,
354
- :pp,
355
- :print,
356
- :printf,
357
- :private,
358
- :proc,
359
- :public,
360
- :putc,
361
- :puts,
362
- :raise,
363
- :rand,
364
- :readline,
365
- :readlines,
366
- :require,
367
- :require_relative,
368
- :respond_to_missing?,
369
- :rubygems_require,
370
- :select,
371
- :set_trace_func,
372
- :singleton_method_added,
373
- :singleton_method_removed,
374
- :singleton_method_undefined,
375
- :sleep,
376
- :spawn,
377
- :sprintf,
378
- :srand,
379
- :syscall,
380
- :system,
381
- :test,
382
- :throw,
383
- :timeout,
384
- :trace_var,
385
- :trap,
386
- :untrace_var,
387
- :using,
388
- :warn,
389
- :y]
390
-
391
- ```
300
+ is stopped.
392
301
 
393
302
  Now let's see what happens after stepping:
394
303
 
@@ -766,7 +675,7 @@ $ byebug primes.rb
766
675
  8:
767
676
  9: def self.next_prime(&block)
768
677
  10: candidate = 2
769
- (byebug) set tracing
678
+ (byebug) set linetrace
770
679
  line tracing is on.
771
680
  (byebug) set basename
772
681
  basename in on.
@@ -1553,7 +1462,6 @@ short list of named classes of commands
1553
1462
  method -- Shows methods of an object, class or module
1554
1463
  next -- Runs one or more lines of code
1555
1464
  pry -- Starts a Pry session
1556
- ps -- Evaluates an expression and prettyprints & sort the result
1557
1465
  quit -- Exits byebug
1558
1466
  restart -- Restarts the debugged program
1559
1467
  save -- Saves current byebug session to a file
@@ -1768,10 +1676,10 @@ basically listing `<object>.instance_variables`.
1768
1676
  * `var global`. Show global variables.
1769
1677
  * `var all`. Show local, global and instance and class variables of `self`.
1770
1678
  * `method instance <object>`. Show methods of `<object>`. Basically this is the
1771
- same as running `ps <object>.instance_methods(false)`.
1679
+ same as running `<object>.instance_methods(false)`.
1772
1680
  * `method <class-or-module>`. Show methods of the class or module
1773
- `<class-or-module>`. Basically this is the same as running `ps
1774
- <class-or-module>.methods`.
1681
+ `<class-or-module>`. Basically this is the same as running
1682
+ `<class-or-module>.methods`.
1775
1683
 
1776
1684
  ### Examining Program Source Files: list
1777
1685
 
data/README.md CHANGED
@@ -1,19 +1,22 @@
1
1
  # Byebug
2
2
 
3
- [![Ver][gem]][gem_url]
4
- [![Gpa][gpa]][gpa_url]
5
- [![Cov][cov]][cov_url]
6
- [![Git][tip]][tip_url]
3
+ [![Version][gem]][gem_url]
4
+ [![Quality][gpa]][gpa_url]
5
+ [![Coverage][cov]][cov_url]
6
+ [![Gratipay][tip]][tip_url]
7
+ [![Gitter][irc]][irc_url]
7
8
 
8
9
  [gem]: https://img.shields.io/gem/v/byebug.svg
9
10
  [gpa]: https://img.shields.io/codeclimate/github/deivid-rodriguez/byebug.svg
10
11
  [cov]: https://img.shields.io/codeclimate/coverage/github/deivid-rodriguez/byebug.svg
11
12
  [tip]: https://img.shields.io/gittip/deivid-rodriguez.svg
13
+ [irc]: https://img.shields.io/badge/IRC%20(gitter)-devs%20%26%20users-brightgreen.svg
12
14
 
13
15
  [gem_url]: https://rubygems.org/gems/byebug
14
16
  [gpa_url]: https://codeclimate.com/github/deivid-rodriguez/byebug
15
17
  [cov_url]: https://codeclimate.com/github/deivid-rodriguez/byebug
16
18
  [tip_url]: https://www.gittip.com/deivid-rodriguez
19
+ [irc_url]: https://gitter.im/deivid-rodriguez/byebug
17
20
 
18
21
  _Debugging in Ruby 2_
19
22
 
@@ -99,12 +102,11 @@ are debugging rails, start the server and once the execution gets to your
99
102
  `method` | | `instance`
100
103
  `next` | |
101
104
  `pry` | |
102
- `ps` | |
103
105
  `quit` | |
104
106
  `restart` | |
105
107
  `save` | |
106
- `set` | | `autoirb` `autolist` `autosave` `basename` `callstyle` `fullpath` `histfile` `histsize` `linetrace` `listsize` `post_mortem` `savefile` `stack_on_error` `width`
107
- `show` | | `autoirb` `autolist` `autosave` `basename` `callstyle` `fullpath` `histfile` `histsize` `linetrace` `listsize` `post_mortem` `savefile` `stack_on_error` `width`
108
+ `set` | | `autoirb` `autolist` `autopry` `autosave` `basename` `callstyle` `fullpath` `histfile` `histsize` `linetrace` `listsize` `post_mortem` `savefile` `stack_on_error` `width`
109
+ `show` | | `autoirb` `autolist` `autopry` `autosave` `basename` `callstyle` `fullpath` `histfile` `histsize` `linetrace` `listsize` `post_mortem` `savefile` `stack_on_error` `width`
108
110
  `source` | |
109
111
  `step` | |
110
112
  `thread` | | `current` `list` `resume` `stop` `switch`
@@ -38,17 +38,17 @@ brkpt_enabled(VALUE self)
38
38
 
39
39
  /*
40
40
  * call-seq:
41
- * breakpoint.enabled = bool
41
+ * breakpoint.enabled = true | false
42
42
  *
43
43
  * Enables or disables breakpoint.
44
44
  */
45
45
  static VALUE
46
- brkpt_set_enabled(VALUE self, VALUE bool)
46
+ brkpt_set_enabled(VALUE self, VALUE enabled)
47
47
  {
48
48
  breakpoint_t *breakpoint;
49
49
 
50
50
  Data_Get_Struct(self, breakpoint_t, breakpoint);
51
- return breakpoint->enabled = bool;
51
+ return breakpoint->enabled = enabled;
52
52
  }
53
53
 
54
54
  /*
@@ -13,6 +13,7 @@ static VALUE tracepoints = Qnil;
13
13
  static VALUE raised_exception = Qnil;
14
14
 
15
15
  static ID idPuts;
16
+ static ID idEmpty;
16
17
 
17
18
  /* Hash table with active threads and their associated contexts */
18
19
  VALUE threads = Qnil;
@@ -63,6 +64,7 @@ Raised_exception(VALUE self)
63
64
  }
64
65
 
65
66
  #define IS_STARTED (catchpoints != Qnil)
67
+
66
68
  static void
67
69
  check_started()
68
70
  {
@@ -157,20 +159,32 @@ cleanup(debug_context_t * dc)
157
159
  trace_print(trace_arg, dc, 0, 0); \
158
160
 
159
161
 
162
+ #define CALL_EVENT_SETUP \
163
+ dc->calced_stack_size++; \
164
+ dc->steps_out = dc->steps_out < 0 ? -1 : dc->steps_out + 1;
165
+
166
+ #define RETURN_EVENT_SETUP \
167
+ dc->calced_stack_size--; \
168
+ \
169
+ if (dc->steps_out == 1) \
170
+ dc->steps = 1;
171
+
172
+ #define RETURN_EVENT_TEARDOWN \
173
+ dc->steps_out = dc->steps_out <= 0 ? -1 : dc->steps_out - 1;
174
+
175
+
160
176
  /* Functions that return control to byebug after the different events */
161
177
 
162
178
  static VALUE
163
- call_at(VALUE context_obj, debug_context_t * dc, ID mid, int argc, VALUE a0,
164
- VALUE a1)
179
+ call_at(VALUE ctx, debug_context_t * dc, ID mid, int argc, VALUE arg)
165
180
  {
166
181
  struct call_with_inspection_data cwi;
167
- VALUE argv[2];
182
+ VALUE argv[1];
168
183
 
169
- argv[0] = a0;
170
- argv[1] = a1;
184
+ argv[0] = arg;
171
185
 
172
186
  cwi.dc = dc;
173
- cwi.context_obj = context_obj;
187
+ cwi.ctx = ctx;
174
188
  cwi.id = mid;
175
189
  cwi.argc = argc;
176
190
  cwi.argv = &argv[0];
@@ -179,49 +193,52 @@ call_at(VALUE context_obj, debug_context_t * dc, ID mid, int argc, VALUE a0,
179
193
  }
180
194
 
181
195
  static VALUE
182
- call_at_line(VALUE context_obj, debug_context_t * dc, VALUE file, VALUE line)
196
+ call_at_line(VALUE ctx, debug_context_t * dc)
183
197
  {
184
- return call_at(context_obj, dc, rb_intern("at_line"), 2, file, line);
198
+ return call_at(ctx, dc, rb_intern("at_line"), 0, Qnil);
185
199
  }
186
200
 
187
201
  static VALUE
188
- call_at_tracing(VALUE context_obj, debug_context_t * dc, VALUE file, VALUE line)
202
+ call_at_tracing(VALUE ctx, debug_context_t * dc)
189
203
  {
190
- return call_at(context_obj, dc, rb_intern("at_tracing"), 2, file, line);
204
+ return call_at(ctx, dc, rb_intern("at_tracing"), 0, Qnil);
191
205
  }
192
206
 
193
207
  static VALUE
194
- call_at_breakpoint(VALUE context_obj, debug_context_t * dc, VALUE breakpoint)
208
+ call_at_breakpoint(VALUE ctx, debug_context_t * dc, VALUE breakpoint)
195
209
  {
196
210
  dc->stop_reason = CTX_STOP_BREAKPOINT;
197
- return call_at(context_obj, dc, rb_intern("at_breakpoint"), 1, breakpoint, 0);
211
+
212
+ return call_at(ctx, dc, rb_intern("at_breakpoint"), 1, breakpoint);
198
213
  }
199
214
 
200
215
  static VALUE
201
- call_at_catchpoint(VALUE context_obj, debug_context_t * dc, VALUE exp)
216
+ call_at_catchpoint(VALUE ctx, debug_context_t * dc, VALUE exp)
202
217
  {
203
218
  dc->stop_reason = CTX_STOP_CATCHPOINT;
204
- return call_at(context_obj, dc, rb_intern("at_catchpoint"), 1, exp, 0);
219
+
220
+ return call_at(ctx, dc, rb_intern("at_catchpoint"), 1, exp);
205
221
  }
206
222
 
207
223
  static VALUE
208
- call_at_return(VALUE context_obj, debug_context_t * dc, VALUE file, VALUE line)
224
+ call_at_return(VALUE ctx, debug_context_t * dc, VALUE return_value)
209
225
  {
210
226
  dc->stop_reason = CTX_STOP_BREAKPOINT;
211
- return call_at(context_obj, dc, rb_intern("at_return"), 2, file, line);
227
+
228
+ return call_at(ctx, dc, rb_intern("at_return"), 1, return_value);
212
229
  }
213
230
 
214
231
  static void
215
- call_at_line_check(VALUE context_obj, debug_context_t * dc, VALUE breakpoint,
216
- VALUE file, VALUE line)
232
+ call_at_line_check(VALUE ctx, debug_context_t * dc, VALUE breakpoint)
217
233
  {
218
234
  dc->stop_reason = CTX_STOP_STEP;
219
235
 
220
236
  if (breakpoint != Qnil)
221
- call_at_breakpoint(context_obj, dc, breakpoint);
237
+ call_at_breakpoint(ctx, dc, breakpoint);
222
238
 
223
239
  reset_stepping_stop_points(dc);
224
- call_at_line(context_obj, dc, file, line);
240
+
241
+ call_at_line(ctx, dc);
225
242
  }
226
243
 
227
244
 
@@ -239,7 +256,7 @@ line_event(VALUE trace_point, void *data)
239
256
  binding = rb_tracearg_binding(trace_arg);
240
257
 
241
258
  if (RTEST(tracing))
242
- call_at_tracing(context, dc, file, line);
259
+ call_at_tracing(context, dc);
243
260
 
244
261
  if (!CTX_FL_TEST(dc, CTX_FL_IGNORE_STEPS))
245
262
  dc->steps = dc->steps <= 0 ? -1 : dc->steps - 1;
@@ -253,7 +270,7 @@ line_event(VALUE trace_point, void *data)
253
270
  }
254
271
 
255
272
  if (dc->steps == 0 || dc->lines == 0)
256
- call_at_line_check(context, dc, Qnil, file, line);
273
+ call_at_line_check(context, dc, Qnil);
257
274
 
258
275
  brkpnt = Qnil;
259
276
 
@@ -261,7 +278,7 @@ line_event(VALUE trace_point, void *data)
261
278
  brkpnt = find_breakpoint_by_pos(breakpoints, file, line, binding);
262
279
 
263
280
  if (!NIL_P(brkpnt))
264
- call_at_line_check(context, dc, brkpnt, file, line);
281
+ call_at_line_check(context, dc, brkpnt);
265
282
 
266
283
  EVENT_TEARDOWN;
267
284
  }
@@ -269,16 +286,14 @@ line_event(VALUE trace_point, void *data)
269
286
  static void
270
287
  call_event(VALUE trace_point, void *data)
271
288
  {
272
- VALUE brkpnt, klass, msym, mid, binding, self, file, line;
289
+ VALUE brkpnt, klass, msym, mid, binding, self;
273
290
 
274
291
  EVENT_SETUP;
275
292
 
276
293
  if (dc->calced_stack_size <= dc->dest_frame)
277
294
  CTX_FL_UNSET(dc, CTX_FL_IGNORE_STEPS);
278
295
 
279
- dc->calced_stack_size++;
280
-
281
- dc->steps_out = dc->steps_out <= 0 ? -1 : dc->steps_out + 1;
296
+ CALL_EVENT_SETUP;
282
297
 
283
298
  /* nil method_id means we are at top level so there can't be a method
284
299
  * breakpoint here. Just leave then. */
@@ -293,8 +308,6 @@ call_event(VALUE trace_point, void *data)
293
308
  klass = rb_tracearg_defined_class(trace_arg);
294
309
  binding = rb_tracearg_binding(trace_arg);
295
310
  self = rb_tracearg_self(trace_arg);
296
- file = rb_tracearg_path(trace_arg);
297
- line = rb_tracearg_lineno(trace_arg);
298
311
 
299
312
  brkpnt = Qnil;
300
313
 
@@ -304,7 +317,7 @@ call_event(VALUE trace_point, void *data)
304
317
  if (!NIL_P(brkpnt))
305
318
  {
306
319
  call_at_breakpoint(context, dc, brkpnt);
307
- call_at_line(context, dc, file, line);
320
+ call_at_line(context, dc);
308
321
  }
309
322
 
310
323
  EVENT_TEARDOWN;
@@ -313,23 +326,26 @@ call_event(VALUE trace_point, void *data)
313
326
  static void
314
327
  return_event(VALUE trace_point, void *data)
315
328
  {
329
+ VALUE return_value;
330
+
316
331
  EVENT_SETUP;
317
332
 
318
- dc->calced_stack_size--;
333
+ RETURN_EVENT_SETUP;
319
334
 
320
- if (dc->steps_out == 1)
321
- dc->steps = 1;
322
- else if ((dc->steps_out == 0) && (CTX_FL_TEST(dc, CTX_FL_STOP_ON_RET)))
335
+ if ((dc->steps_out == 0) && (CTX_FL_TEST(dc, CTX_FL_STOP_ON_RET)))
323
336
  {
324
- VALUE file, line;
325
-
326
337
  reset_stepping_stop_points(dc);
327
- file = rb_tracearg_path(trace_arg);
328
- line = rb_tracearg_lineno(trace_arg);
329
- call_at_return(context, dc, file, line);
338
+
339
+ if (rb_tracearg_event_flag(trace_arg) &
340
+ (RUBY_EVENT_RETURN | RUBY_EVENT_B_RETURN))
341
+ return_value = rb_tracearg_return_value(trace_arg);
342
+ else
343
+ return_value = Qnil;
344
+
345
+ call_at_return(context, dc, return_value);
330
346
  }
331
347
 
332
- dc->steps_out = dc->steps_out <= 0 ? -1 : dc->steps_out - 1;
348
+ RETURN_EVENT_TEARDOWN;
333
349
 
334
350
  EVENT_TEARDOWN;
335
351
  }
@@ -339,7 +355,7 @@ raw_call_event(VALUE trace_point, void *data)
339
355
  {
340
356
  EVENT_SETUP;
341
357
 
342
- dc->calced_stack_size++;
358
+ CALL_EVENT_SETUP;
343
359
 
344
360
  EVENT_TEARDOWN;
345
361
  }
@@ -349,7 +365,9 @@ raw_return_event(VALUE trace_point, void *data)
349
365
  {
350
366
  EVENT_SETUP;
351
367
 
352
- dc->calced_stack_size--;
368
+ RETURN_EVENT_SETUP;
369
+
370
+ RETURN_EVENT_TEARDOWN;
353
371
 
354
372
  EVENT_TEARDOWN;
355
373
  }
@@ -357,14 +375,12 @@ raw_return_event(VALUE trace_point, void *data)
357
375
  static void
358
376
  raise_event(VALUE trace_point, void *data)
359
377
  {
360
- VALUE expn_class, ancestors, path, lineno, pm_context;
378
+ VALUE expn_class, ancestors, pm_context;
361
379
  int i;
362
380
  debug_context_t *new_dc;
363
381
 
364
382
  EVENT_SETUP;
365
383
 
366
- path = rb_tracearg_path(trace_arg);
367
- lineno = rb_tracearg_lineno(trace_arg);
368
384
  raised_exception = rb_tracearg_raised_exception(trace_arg);
369
385
 
370
386
  if (post_mortem == Qtrue)
@@ -397,8 +413,10 @@ raise_event(VALUE trace_point, void *data)
397
413
  if (hit_count != Qnil)
398
414
  {
399
415
  rb_hash_aset(catchpoints, module_name, INT2FIX(FIX2INT(hit_count) + 1));
416
+
400
417
  call_at_catchpoint(context, dc, raised_exception);
401
- call_at_line(context, dc, path, lineno);
418
+ call_at_line(context, dc);
419
+
402
420
  break;
403
421
  }
404
422
  }
@@ -540,8 +558,6 @@ Current_context(VALUE self)
540
558
 
541
559
  UNUSED(self);
542
560
 
543
- check_started();
544
-
545
561
  thread_context_lookup(rb_thread_current(), &context);
546
562
 
547
563
  return context;
@@ -579,7 +595,6 @@ Stop(VALUE self)
579
595
 
580
596
  breakpoints = Qnil;
581
597
  catchpoints = Qnil;
582
- threads = Qnil;
583
598
 
584
599
  return Qfalse;
585
600
  }
@@ -587,6 +602,36 @@ Stop(VALUE self)
587
602
  return Qtrue;
588
603
  }
589
604
 
605
+ static VALUE
606
+ Stoppable(VALUE self)
607
+ {
608
+ VALUE context;
609
+ debug_context_t *dc;
610
+
611
+ if (!IS_STARTED)
612
+ return Qfalse;
613
+
614
+ if (breakpoints != Qnil && rb_funcall(breakpoints, idEmpty, 0) == Qfalse)
615
+ return Qfalse;
616
+
617
+ if (catchpoints != Qnil && rb_funcall(catchpoints, idEmpty, 0) == Qfalse)
618
+ return Qfalse;
619
+
620
+ if (post_mortem == Qtrue)
621
+ return Qfalse;
622
+
623
+ context = Current_context(self);
624
+ if (context != Qnil)
625
+ {
626
+ Data_Get_Struct(context, debug_context_t, dc);
627
+
628
+ if (dc->steps > 0)
629
+ return Qfalse;
630
+ }
631
+
632
+ return Qtrue;
633
+ }
634
+
590
635
  /*
591
636
  * call-seq:
592
637
  * Byebug.start -> bool
@@ -750,6 +795,7 @@ Init_byebug()
750
795
  rb_define_module_function(mByebug, "start", Start, 0);
751
796
  rb_define_module_function(mByebug, "started?", Started, 0);
752
797
  rb_define_module_function(mByebug, "stop", Stop, 0);
798
+ rb_define_module_function(mByebug, "stoppable?", Stoppable, 0);
753
799
  rb_define_module_function(mByebug, "thread_context", Thread_context, 1);
754
800
  rb_define_module_function(mByebug, "tracing?", Tracing, 0);
755
801
  rb_define_module_function(mByebug, "tracing=", Set_tracing, 1);
@@ -765,4 +811,5 @@ Init_byebug()
765
811
  rb_global_variable(&threads);
766
812
 
767
813
  idPuts = rb_intern("puts");
814
+ idEmpty = rb_intern("empty?");
768
815
  }
@@ -54,7 +54,7 @@ typedef enum {
54
54
 
55
55
  struct call_with_inspection_data {
56
56
  debug_context_t *dc;
57
- VALUE context_obj;
57
+ VALUE ctx;
58
58
  ID id;
59
59
  int argc;
60
60
  VALUE *argv;
@@ -168,7 +168,7 @@ open_debug_inspector_i(const rb_debug_inspector_t * inspector, void *data)
168
168
 
169
169
  cwi->dc->backtrace = load_backtrace(inspector);
170
170
 
171
- return rb_funcall2(cwi->context_obj, cwi->id, cwi->argc, cwi->argv);
171
+ return rb_funcall2(cwi->ctx, cwi->id, cwi->argc, cwi->argv);
172
172
  }
173
173
 
174
174
  static VALUE
@@ -344,7 +344,7 @@ Context_resume(VALUE self)
344
344
 
345
345
  /*
346
346
  * call-seq:
347
- * context.backtrace-> int
347
+ * context.backtrace-> Array
348
348
  *
349
349
  * Returns the frame stack of a context.
350
350
  */
@@ -1,2 +1 @@
1
- require 'byebug/core'
2
1
  require 'byebug/attacher'
@@ -7,6 +7,8 @@ module Byebug
7
7
  # events occur. Before entering byebug the init script is read.
8
8
  #
9
9
  def self.attach
10
+ require 'byebug/core'
11
+
10
12
  unless started?
11
13
  self.mode = :attached
12
14
 
@@ -14,7 +16,7 @@ module Byebug
14
16
  run_init_script
15
17
  end
16
18
 
17
- current_context.step_out(2, true)
19
+ current_context.step_out(3, true)
18
20
  end
19
21
  end
20
22
 
@@ -20,7 +20,6 @@ require 'byebug/commands/list'
20
20
  require 'byebug/commands/method'
21
21
  require 'byebug/commands/next'
22
22
  require 'byebug/commands/pry'
23
- require 'byebug/commands/ps'
24
23
  require 'byebug/commands/quit'
25
24
  require 'byebug/commands/restart'
26
25
  require 'byebug/commands/save'
@@ -41,6 +41,8 @@ module Byebug
41
41
  end
42
42
 
43
43
  processor.proceed!
44
+
45
+ Byebug.stop if Byebug.stoppable?
44
46
  end
45
47
  end
46
48
  end
@@ -16,7 +16,7 @@ module Byebug
16
16
 
17
17
  def self.description
18
18
  <<-EOD
19
- hist[ory] [num_cmds]
19
+ hist[ory][ num_cmds]
20
20
 
21
21
  #{short_description}
22
22
  EOD
@@ -29,10 +29,7 @@ module Byebug
29
29
  def execute
30
30
  history = processor.interface.history
31
31
 
32
- if @match[:num_cmds]
33
- size, err = get_int(@match[:num_cmds], 'history', 1, history.size)
34
- return errmsg(err) unless size
35
- end
32
+ size, = get_int(@match[:num_cmds], 'history', 1) if @match[:num_cmds]
36
33
 
37
34
  puts history.to_s(size)
38
35
  end
@@ -54,7 +54,7 @@ module Byebug
54
54
  return unless hits > 0
55
55
 
56
56
  s = (hits > 1) ? 's' : ''
57
- puts "\tbreakpoint already hit #{hits} time#{s}"
57
+ puts " breakpoint already hit #{hits} time#{s}"
58
58
  end
59
59
  end
60
60
  end
@@ -89,35 +89,35 @@ module Byebug
89
89
  end
90
90
 
91
91
  def at_breakpoint(breakpoint)
92
- new_processor.at_breakpoint(breakpoint)
92
+ processor.at_breakpoint(breakpoint)
93
93
  end
94
94
 
95
95
  def at_catchpoint(exception)
96
- new_processor.at_catchpoint(exception)
96
+ processor.at_catchpoint(exception)
97
97
  end
98
98
 
99
- def at_tracing(file, _line)
99
+ def at_tracing
100
100
  return if ignored_file?(file)
101
101
 
102
- new_processor.at_tracing
102
+ processor.at_tracing
103
103
  end
104
104
 
105
- def at_line(file, _l)
105
+ def at_line
106
106
  self.frame = 0
107
107
  return if ignored_file?(file)
108
108
 
109
- new_processor.at_line
109
+ processor.at_line
110
110
  end
111
111
 
112
- def at_return(file, _line)
112
+ def at_return(return_value)
113
113
  return if ignored_file?(file)
114
114
 
115
- new_processor.at_return
115
+ processor.at_return(return_value)
116
116
  end
117
117
 
118
118
  private
119
119
 
120
- def new_processor
120
+ def processor
121
121
  @processor ||= self.class.processor.new(self)
122
122
  end
123
123
  end
@@ -64,7 +64,7 @@ module Byebug
64
64
  at = e.backtrace
65
65
 
66
66
  locations = ["#{at.shift}: #{warning_msg(e)}"]
67
- locations += at.map { |path| "\tfrom #{path}" }
67
+ locations += at.map { |path| " from #{path}" }
68
68
  locations.join("\n")
69
69
  end
70
70
 
@@ -80,11 +80,26 @@ module Byebug
80
80
  # will get blocked by byebug's main thread.
81
81
  #
82
82
  def allowing_other_threads
83
+ res = nil
83
84
  Byebug.unlock
84
- res = yield
85
+
86
+ Thread.new { res = yield }.join
87
+
85
88
  Byebug.lock
86
89
  res
87
90
  end
91
+
92
+ def safe_inspect(var)
93
+ var.inspect
94
+ rescue
95
+ safe_to_s(var)
96
+ end
97
+
98
+ def safe_to_s(var)
99
+ var.to_s
100
+ rescue
101
+ '*Error in evaluation*'
102
+ end
88
103
  end
89
104
  end
90
105
  end
@@ -47,20 +47,6 @@ module Byebug
47
47
  locals = all_locals.select { |k, _| arg_values.include?(k) }
48
48
  puts prv(locals.keys.sort.map { |k| [k, locals[k]] }, 'instance')
49
49
  end
50
-
51
- private
52
-
53
- def safe_inspect(var)
54
- var.inspect
55
- rescue
56
- safe_to_s(var)
57
- end
58
-
59
- def safe_to_s(var)
60
- var.to_s
61
- rescue
62
- '*Error in evaluation*'
63
- end
64
50
  end
65
51
  end
66
52
  end
@@ -3,6 +3,8 @@ module Byebug
3
3
  # Interface class for standard byebug use.
4
4
  #
5
5
  class LocalInterface < Interface
6
+ EOF_ALIAS = 'continue'
7
+
6
8
  def initialize
7
9
  super()
8
10
  @input = STDIN
@@ -13,12 +15,12 @@ module Byebug
13
15
  #
14
16
  # Reads a single line of input using Readline. If Ctrl-C is pressed in the
15
17
  # middle of input, the line is reset to only the prompt and we ask for input
16
- # again.
18
+ # again. If Ctrl-D is pressed, it returns "continue".
17
19
  #
18
20
  # @param prompt Prompt to be displayed.
19
21
  #
20
22
  def readline(prompt)
21
- Readline.readline(prompt, false)
23
+ Readline.readline(prompt, false) || EOF_ALIAS
22
24
  rescue Interrupt
23
25
  puts('^C')
24
26
  retry
@@ -13,15 +13,15 @@ module Byebug
13
13
  end
14
14
 
15
15
  def errmsg(message)
16
- error.concat(message.to_s.split("\n"))
16
+ error.concat(prepare(message))
17
17
  end
18
18
 
19
19
  def print(message)
20
- output.concat(message.to_s.split("\n"))
20
+ output.concat(prepare(message))
21
21
  end
22
22
 
23
23
  def puts(message)
24
- output.concat(message.to_s.split("\n"))
24
+ output.concat(prepare(message))
25
25
  end
26
26
 
27
27
  def read_command(prompt)
@@ -54,5 +54,13 @@ module Byebug
54
54
  cmd = input.shift
55
55
  cmd.is_a?(Proc) ? cmd.call : cmd
56
56
  end
57
+
58
+ private
59
+
60
+ def prepare(message)
61
+ return message.map(&:to_s) if message.respond_to?(:map)
62
+
63
+ message.to_s.split("\n")
64
+ end
57
65
  end
58
66
  end
@@ -31,7 +31,7 @@ module Byebug
31
31
  end
32
32
 
33
33
  def include_flag
34
- @opts.on('-I', '--include list', 'Add to paths to $LOAD_PATH') do |list|
34
+ @opts.on '-I', '--include list', 'Add to paths to $LOAD_PATH' do |list|
35
35
  $LOAD_PATH.push(list.split(':')).flatten!
36
36
  end
37
37
  end
@@ -85,7 +85,7 @@ module Byebug
85
85
  end
86
86
 
87
87
  def help
88
- @opts.on('-h', '--help', 'Display this message') do
88
+ @opts.on '-h', '--help', 'Display this message' do
89
89
  @runner.help = @opts.help
90
90
  end
91
91
  end
@@ -15,7 +15,7 @@ method:
15
15
  methods: "{name}|c"
16
16
 
17
17
  restart:
18
- success: "Re exec'ing:\n\t{cmd}"
18
+ success: "Re exec'ing:\n {cmd}"
19
19
 
20
20
  thread:
21
21
  context: "{status_flag}{debug_flag}{id} {thread} {file_line}"
@@ -26,7 +26,7 @@ module Byebug
26
26
  end
27
27
 
28
28
  def interface
29
- @interface ||= context.class.interface
29
+ @interface ||= Context.interface
30
30
  end
31
31
 
32
32
  def printer
@@ -68,14 +68,16 @@ module Byebug
68
68
  def at_tracing
69
69
  puts "Tracing: #{context.full_location}"
70
70
 
71
- run_auto_commands(2)
71
+ run_auto_cmds(2)
72
72
  end
73
73
 
74
74
  def at_line
75
75
  process_commands
76
76
  end
77
77
 
78
- def at_return
78
+ def at_return(return_value)
79
+ puts "Return value is: #{safe_inspect(return_value)}"
80
+
79
81
  process_commands
80
82
  end
81
83
 
@@ -108,22 +110,24 @@ module Byebug
108
110
 
109
111
  private
110
112
 
111
- def auto_commands_for(run_level)
113
+ def auto_cmds_for(run_level)
112
114
  command_list.select { |cmd| cmd.always_run >= run_level }
113
115
  end
114
116
 
115
117
  #
116
118
  # Run permanent commands.
117
119
  #
118
- def run_auto_commands(run_level)
119
- auto_commands_for(run_level).each { |cmd| cmd.new(self).execute }
120
+ def run_auto_cmds(run_level)
121
+ safely do
122
+ auto_cmds_for(run_level).each { |cmd| cmd.new(self).execute }
123
+ end
120
124
  end
121
125
 
122
126
  def before_repl
123
127
  @proceed = false
124
128
  @prev_line = nil
125
129
 
126
- run_auto_commands(1)
130
+ run_auto_cmds(1)
127
131
  interface.autorestore
128
132
  end
129
133
 
@@ -152,10 +156,16 @@ module Byebug
152
156
  # command is not found, it evaluates the unknown input.
153
157
  #
154
158
  def run_cmd(input)
155
- command = command_list.match(input)
156
- return command.new(self, input).execute if command
159
+ safely do
160
+ command = command_list.match(input)
161
+ return command.new(self, input).execute if command
162
+
163
+ puts safe_inspect(thread_safe_eval(input))
164
+ end
165
+ end
157
166
 
158
- puts thread_safe_eval(input)
167
+ def safely
168
+ yield
159
169
  rescue => e
160
170
  errmsg(e.message)
161
171
  end
@@ -3,6 +3,10 @@ module Byebug
3
3
  # Processes commands when there's not program running
4
4
  #
5
5
  class ControlProcessor < CommandProcessor
6
+ def initialize(context = nil)
7
+ @context = context
8
+ end
9
+
6
10
  #
7
11
  # Available commands
8
12
  #
@@ -27,7 +27,7 @@ module Byebug
27
27
  rescue
28
28
  without_exceptions do
29
29
  puts "INTERNAL ERROR!!! #{$ERROR_INFO}"
30
- puts $ERROR_INFO.backtrace.map { |l| "\t#{l}" }.join("\n")
30
+ puts $ERROR_INFO.backtrace.map { |l| " #{l}" }.join("\n")
31
31
  end
32
32
  end
33
33
 
@@ -62,7 +62,7 @@ module Byebug
62
62
  while (session = server.accept)
63
63
  Context.interface = RemoteInterface.new(session)
64
64
 
65
- ControlCommandProcessor.new(Byebug.current_context).process_commands
65
+ ControlProcessor.new(Byebug.current_context).process_commands
66
66
  end
67
67
  end
68
68
 
@@ -38,6 +38,11 @@ module Byebug
38
38
  #
39
39
  attr_accessor :quit
40
40
 
41
+ #
42
+ # Signals that we should stop before program starts
43
+ #
44
+ attr_accessor :stop
45
+
41
46
  #
42
47
  # @param stop [Boolean] Whether the runner should stop right before
43
48
  # starting the program.
@@ -102,6 +107,8 @@ module Byebug
102
107
  end
103
108
  end
104
109
 
110
+ attr_writer :interface
111
+
105
112
  def interface
106
113
  @interface ||= LocalInterface.new
107
114
  end
@@ -139,7 +146,7 @@ module Byebug
139
146
  ok = syntax_valid?(File.read($PROGRAM_NAME))
140
147
  fail(InvalidScript, 'The script has incorrect syntax') unless ok
141
148
 
142
- error = Byebug.debug_load($PROGRAM_NAME, @stop)
149
+ error = Byebug.debug_load($PROGRAM_NAME, stop)
143
150
  puts "#{error}\n#{error.backtrace}" if error
144
151
  end
145
152
 
@@ -0,0 +1,27 @@
1
+ require 'byebug/setting'
2
+ require 'byebug/commands/pry'
3
+
4
+ module Byebug
5
+ #
6
+ # Setting for automatically invoking Pry on every stop.
7
+ #
8
+ class AutoprySetting < Setting
9
+ DEFAULT = 0
10
+
11
+ def initialize
12
+ PryCommand.always_run = DEFAULT
13
+ end
14
+
15
+ def banner
16
+ 'Invoke Pry on every stop'
17
+ end
18
+
19
+ def value=(v)
20
+ PryCommand.always_run = v ? 1 : 0
21
+ end
22
+
23
+ def value
24
+ PryCommand.always_run == 1
25
+ end
26
+ end
27
+ end
@@ -2,5 +2,5 @@
2
2
  # Reopen main module to define the library version
3
3
  #
4
4
  module Byebug
5
- VERSION = '6.0.2'
5
+ VERSION = '7.0.0'
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: byebug
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.2
4
+ version: 7.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Rodriguez
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-08-20 00:00:00.000000000 Z
13
+ date: 2015-11-04 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -94,7 +94,6 @@ files:
94
94
  - lib/byebug/commands/method.rb
95
95
  - lib/byebug/commands/next.rb
96
96
  - lib/byebug/commands/pry.rb
97
- - lib/byebug/commands/ps.rb
98
97
  - lib/byebug/commands/quit.rb
99
98
  - lib/byebug/commands/restart.rb
100
99
  - lib/byebug/commands/save.rb
@@ -154,6 +153,7 @@ files:
154
153
  - lib/byebug/setting.rb
155
154
  - lib/byebug/settings/autoirb.rb
156
155
  - lib/byebug/settings/autolist.rb
156
+ - lib/byebug/settings/autopry.rb
157
157
  - lib/byebug/settings/autosave.rb
158
158
  - lib/byebug/settings/basename.rb
159
159
  - lib/byebug/settings/callstyle.rb
@@ -1,42 +0,0 @@
1
- require 'English'
2
- require 'pp'
3
- require 'byebug/command'
4
- require 'byebug/helpers/eval'
5
-
6
- module Byebug
7
- #
8
- # Enhanced evaluation of expressions from byebug's prompt. Besides
9
- # evaluating, it sorts and pretty prints arrays.
10
- #
11
- class PsCommand < Command
12
- include Helpers::EvalHelper
13
-
14
- self.allow_in_post_mortem = true
15
-
16
- def self.regexp
17
- /^\s* ps (\s+ (.+)) \s*$/x
18
- end
19
-
20
- def self.description
21
- <<-EOD
22
- ps <expression>
23
-
24
- #{short_description}
25
- EOD
26
- end
27
-
28
- def self.short_description
29
- 'Evaluates an expression and prettyprints & sort the result'
30
- end
31
-
32
- def execute
33
- return puts(help) unless @match[1]
34
-
35
- res = thread_safe_eval(@match[1])
36
- res = res.sort if res.respond_to?(:sort)
37
-
38
- out = PP.pp(res, StringIO.new, Setting[:width])
39
- print pr('eval.result', expr: @match[1], result: out.string)
40
- end
41
- end
42
- end