byebug 2.2.0 → 2.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +2 -3
- data/bin/byebug +1 -5
- data/ext/byebug/breakpoint.c +0 -27
- data/ext/byebug/byebug.c +12 -15
- data/ext/byebug/byebug.h +1 -1
- data/ext/byebug/context.c +51 -46
- data/ext/byebug/extconf.rb +1 -1
- data/lib/byebug.rb +8 -3
- data/lib/byebug/command.rb +13 -14
- data/lib/byebug/commands/finish.rb +1 -1
- data/lib/byebug/commands/frame.rb +7 -7
- data/lib/byebug/commands/set.rb +2 -3
- data/lib/byebug/commands/show.rb +3 -3
- data/lib/byebug/context.rb +7 -1
- data/lib/byebug/processor.rb +1 -7
- data/lib/byebug/version.rb +1 -1
- data/old_doc/byebug.texi +5 -7
- data/test/eval_test.rb +2 -2
- data/test/show_test.rb +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd86d998df7e4fd1df7269ddf72438a2623792b5
|
4
|
+
data.tar.gz: 0f125b6a5654b3ef774f0e009312024ce63df907
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3ea7b37bdb6e6376b0d1c1058e99c71a64106d5895147691f28f567fdc95b2c2eac506aeefe172af7e7c8b4c1c8dba3dd47e26a694655685f8a8f037cc372de
|
7
|
+
data.tar.gz: 15d579ce1035bcfa73390774839a6ff4e4eb4448a9bf17d6f9c245089fe5337baee132020adba790082713b85d22a88f490e70d82c26db32ce9b0d97cca2913c
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -125,11 +125,10 @@ Full lists of subcommands:
|
|
125
125
|
`variables`.
|
126
126
|
* set: `args`,`autoeval`,`autoirb`,`autolist`,`autoreload`,`basename`,
|
127
127
|
`callstyle`,`forcestep`,`fullpath`,`history`,`linetrace`,`linetrace_plus`,
|
128
|
-
`listsize`,`post_mortem`,`
|
128
|
+
`listsize`,`post_mortem`,`stack_on_error`,`testing`,`verbose`,`width`.
|
129
129
|
* show: `args`,`autoeval`,`autoirb`,`autolist`,`autoreload`,`basename`,
|
130
130
|
`callstyle`,`commands`,`forcestep`,`fullpath`,`history`,`linetrace`,
|
131
|
-
`linetrace_plus`, `listsize`,`post_mortem`,`
|
132
|
-
`width`.
|
131
|
+
`linetrace_plus`, `listsize`,`post_mortem`,`stack_on_error`,`verbose`, `width`.
|
133
132
|
|
134
133
|
|
135
134
|
## Getting Started
|
data/bin/byebug
CHANGED
data/ext/byebug/breakpoint.c
CHANGED
@@ -277,31 +277,6 @@ brkpt_initialize(VALUE self, VALUE source, VALUE pos, VALUE expr)
|
|
277
277
|
return Qnil;
|
278
278
|
}
|
279
279
|
|
280
|
-
static VALUE
|
281
|
-
brkpt_remove(VALUE self, VALUE breakpoints, VALUE id_value)
|
282
|
-
{
|
283
|
-
int i;
|
284
|
-
int id;
|
285
|
-
VALUE breakpoint_object;
|
286
|
-
breakpoint_t *breakpoint;
|
287
|
-
|
288
|
-
if (breakpoints == Qnil) return Qnil;
|
289
|
-
|
290
|
-
id = FIX2INT(id_value);
|
291
|
-
|
292
|
-
for(i = 0; i < RARRAY_LEN(breakpoints); i++)
|
293
|
-
{
|
294
|
-
breakpoint_object = rb_ary_entry(breakpoints, i);
|
295
|
-
Data_Get_Struct(breakpoint_object, breakpoint_t, breakpoint);
|
296
|
-
if(breakpoint->id == id)
|
297
|
-
{
|
298
|
-
rb_ary_delete_at(breakpoints, i);
|
299
|
-
return breakpoint_object;
|
300
|
-
}
|
301
|
-
}
|
302
|
-
return Qnil;
|
303
|
-
}
|
304
|
-
|
305
280
|
int
|
306
281
|
filename_cmp_impl(VALUE source, char *file)
|
307
282
|
{
|
@@ -512,8 +487,6 @@ Init_breakpoint(VALUE mByebug)
|
|
512
487
|
rb_define_alloc_func(cBreakpoint, brkpt_create);
|
513
488
|
rb_define_method(cBreakpoint, "initialize", brkpt_initialize, 3);
|
514
489
|
|
515
|
-
rb_define_singleton_method(cBreakpoint, "remove", brkpt_remove, 2);
|
516
|
-
|
517
490
|
rb_define_method(cBreakpoint, "enabled?" , brkpt_enabled , 0);
|
518
491
|
rb_define_method(cBreakpoint, "enabled=" , brkpt_set_enabled , 1);
|
519
492
|
rb_define_method(cBreakpoint, "expr" , brkpt_expr , 0);
|
data/ext/byebug/byebug.c
CHANGED
@@ -37,7 +37,7 @@ trace_print(rb_trace_arg_t *trace_arg, debug_context_t *dc)
|
|
37
37
|
VALUE line = rb_tracearg_lineno(trace_arg);
|
38
38
|
VALUE event = rb_tracearg_event(trace_arg);
|
39
39
|
VALUE mid = rb_tracearg_method_id(trace_arg);
|
40
|
-
for (i=0; i<dc->
|
40
|
+
for (i=0; i<dc->calced_stack_size; i++) putc('|', stderr);
|
41
41
|
fprintf(stderr, "[#%d] %s@%s:%d %s\n", dc->thnum,
|
42
42
|
rb_id2name(SYM2ID(event)), RSTRING_PTR(path), NUM2INT(line),
|
43
43
|
NIL_P(mid) ? "" : rb_id2name(SYM2ID(mid)));
|
@@ -194,7 +194,7 @@ line_event(VALUE trace_point, void *data)
|
|
194
194
|
|
195
195
|
EVENT_COMMON
|
196
196
|
|
197
|
-
if (dc->
|
197
|
+
if (dc->calced_stack_size == 0) dc->calced_stack_size++;
|
198
198
|
|
199
199
|
if (dc->last_line != rb_tracearg_lineno(trace_arg) ||
|
200
200
|
dc->last_file != rb_tracearg_path(trace_arg))
|
@@ -208,12 +208,12 @@ line_event(VALUE trace_point, void *data)
|
|
208
208
|
if (moved || !CTX_FL_TEST(dc, CTX_FL_FORCE_MOVE))
|
209
209
|
{
|
210
210
|
dc->steps = dc->steps <= 0 ? -1 : dc->steps - 1;
|
211
|
-
if (dc->
|
211
|
+
if (dc->calced_stack_size <= dc->dest_frame)
|
212
212
|
{
|
213
213
|
dc->lines = dc->lines <= 0 ? -1 : dc->lines - 1;
|
214
|
-
if (dc->
|
214
|
+
if (dc->calced_stack_size < dc->dest_frame)
|
215
215
|
{
|
216
|
-
dc->dest_frame = dc->
|
216
|
+
dc->dest_frame = dc->calced_stack_size;
|
217
217
|
rb_funcall(mByebug, rb_intern("print"), 1,
|
218
218
|
rb_str_new2("Next went up a frame because previous frame finished\n"));
|
219
219
|
}
|
@@ -238,7 +238,7 @@ call_event(VALUE trace_point, void *data)
|
|
238
238
|
|
239
239
|
EVENT_SETUP
|
240
240
|
|
241
|
-
dc->
|
241
|
+
dc->calced_stack_size++;
|
242
242
|
|
243
243
|
EVENT_COMMON
|
244
244
|
|
@@ -265,11 +265,11 @@ return_event(VALUE trace_point, void *data)
|
|
265
265
|
{
|
266
266
|
EVENT_SETUP
|
267
267
|
|
268
|
-
if (dc->
|
268
|
+
if (dc->calced_stack_size > 0) dc->calced_stack_size--;
|
269
269
|
|
270
270
|
EVENT_COMMON
|
271
271
|
|
272
|
-
if (dc->
|
272
|
+
if (dc->calced_stack_size + 1 == dc->before_frame)
|
273
273
|
{
|
274
274
|
VALUE file, line;
|
275
275
|
|
@@ -279,7 +279,7 @@ return_event(VALUE trace_point, void *data)
|
|
279
279
|
call_at_return(context, dc, file, line);
|
280
280
|
}
|
281
281
|
|
282
|
-
if (dc->
|
282
|
+
if (dc->calced_stack_size + 1 == dc->after_frame)
|
283
283
|
{
|
284
284
|
reset_stepping_stop_points(dc);
|
285
285
|
dc->steps = 1;
|
@@ -293,7 +293,7 @@ c_call_event(VALUE trace_point, void *data)
|
|
293
293
|
{
|
294
294
|
EVENT_SETUP
|
295
295
|
|
296
|
-
dc->
|
296
|
+
dc->calced_stack_size++;
|
297
297
|
|
298
298
|
EVENT_COMMON
|
299
299
|
|
@@ -305,7 +305,7 @@ c_return_event(VALUE trace_point, void *data)
|
|
305
305
|
{
|
306
306
|
EVENT_SETUP
|
307
307
|
|
308
|
-
if (dc->
|
308
|
+
if (dc->calced_stack_size > 0) dc->calced_stack_size--;
|
309
309
|
|
310
310
|
EVENT_COMMON
|
311
311
|
|
@@ -346,7 +346,7 @@ raise_event(VALUE trace_point, void *data)
|
|
346
346
|
|
347
347
|
expn_class = rb_obj_class(err);
|
348
348
|
|
349
|
-
if (catchpoints == Qnil || dc->
|
349
|
+
if (catchpoints == Qnil || dc->calced_stack_size == 0 ||
|
350
350
|
CTX_FL_TEST(dc, CTX_FL_CATCHING) ||
|
351
351
|
RHASH_TBL(catchpoints)->num_entries == 0)
|
352
352
|
{
|
@@ -607,9 +607,6 @@ bb_load(int argc, VALUE *argv, VALUE self)
|
|
607
607
|
|
608
608
|
if (RTEST(stop)) dc->steps = 1;
|
609
609
|
|
610
|
-
/* Reset stack size to ignore byebug's own frames */
|
611
|
-
dc->stack_size = 0;
|
612
|
-
|
613
610
|
/* Initializing $0 to the script's path */
|
614
611
|
ruby_script(RSTRING_PTR(file));
|
615
612
|
rb_load_protect(file, 0, &state);
|
data/ext/byebug/byebug.h
CHANGED
data/ext/byebug/context.c
CHANGED
@@ -55,15 +55,15 @@ context_create(VALUE thread)
|
|
55
55
|
{
|
56
56
|
debug_context_t *context = ALLOC(debug_context_t);
|
57
57
|
|
58
|
-
context->last_file
|
59
|
-
context->last_line
|
60
|
-
context->flags
|
61
|
-
context->
|
62
|
-
context->thnum
|
63
|
-
context->thread
|
58
|
+
context->last_file = Qnil;
|
59
|
+
context->last_line = Qnil;
|
60
|
+
context->flags = 0;
|
61
|
+
context->calced_stack_size = real_stack_size();
|
62
|
+
context->thnum = ++thnum_max;
|
63
|
+
context->thread = thread;
|
64
64
|
reset_stepping_stop_points(context);
|
65
|
-
context->stop_reason
|
66
|
-
context->backtrace
|
65
|
+
context->stop_reason = CTX_STOP_NONE;
|
66
|
+
context->backtrace = Qnil;
|
67
67
|
|
68
68
|
if (rb_obj_class(thread) == cDebugThread) CTX_FL_SET(context, CTX_FL_IGNORE);
|
69
69
|
|
@@ -192,16 +192,17 @@ call_with_debug_inspector(struct call_with_inspection_data *data)
|
|
192
192
|
#define FRAME_SETUP \
|
193
193
|
debug_context_t *context; \
|
194
194
|
VALUE frame_no; \
|
195
|
-
int frame_n;
|
195
|
+
int frame_n, stack_size; \
|
196
196
|
Data_Get_Struct(self, debug_context_t, context); \
|
197
197
|
if (!rb_scan_args(argc, argv, "01", &frame_no)) \
|
198
198
|
frame_n = 0; \
|
199
199
|
else \
|
200
200
|
frame_n = FIX2INT(frame_no); \
|
201
|
-
|
201
|
+
stack_size = real_stack_size(); \
|
202
|
+
if (frame_n < 0 || frame_n >= stack_size) \
|
202
203
|
{ \
|
203
204
|
rb_raise(rb_eArgError, "Invalid frame number %d, stack (0...%d)", \
|
204
|
-
frame_n,
|
205
|
+
frame_n, stack_size - 1); \
|
205
206
|
} \
|
206
207
|
|
207
208
|
/*
|
@@ -349,17 +350,20 @@ Context_resume(VALUE self)
|
|
349
350
|
|
350
351
|
/*
|
351
352
|
* call-seq:
|
352
|
-
* context.
|
353
|
+
* context.calced_stack_size-> int
|
353
354
|
*
|
354
|
-
* Returns the size of the context stack.
|
355
|
+
* Returns the calculated size of the context stack.
|
356
|
+
*
|
357
|
+
* NOTE: it shouldn't be necessary to expose this, this is only done to ease
|
358
|
+
* the detection of TracePoint API bugs.
|
355
359
|
*/
|
356
360
|
static inline VALUE
|
357
|
-
|
361
|
+
Context_calced_stack_size(VALUE self)
|
358
362
|
{
|
359
363
|
debug_context_t *context;
|
360
364
|
Data_Get_Struct(self, debug_context_t, context);
|
361
365
|
|
362
|
-
return INT2FIX(context->
|
366
|
+
return INT2FIX(context->calced_stack_size);
|
363
367
|
}
|
364
368
|
|
365
369
|
static VALUE
|
@@ -431,12 +435,13 @@ static VALUE
|
|
431
435
|
Context_step_out(VALUE self, VALUE frame)
|
432
436
|
{
|
433
437
|
debug_context_t *context;
|
438
|
+
|
434
439
|
Data_Get_Struct(self, debug_context_t, context);
|
435
440
|
|
436
|
-
if (FIX2INT(frame) < 0 || FIX2INT(frame) >= context->
|
441
|
+
if (FIX2INT(frame) < 0 || FIX2INT(frame) >= context->calced_stack_size)
|
437
442
|
rb_raise(rb_eRuntimeError, "Stop frame is out of range.");
|
438
443
|
|
439
|
-
context->after_frame = context->
|
444
|
+
context->after_frame = context->calced_stack_size - FIX2INT(frame);
|
440
445
|
|
441
446
|
return frame;
|
442
447
|
}
|
@@ -458,15 +463,15 @@ Context_step_over(int argc, VALUE *argv, VALUE self)
|
|
458
463
|
|
459
464
|
Data_Get_Struct(self, debug_context_t, context);
|
460
465
|
|
461
|
-
if (context->
|
466
|
+
if (context->calced_stack_size == 0)
|
462
467
|
rb_raise(rb_eRuntimeError, "No frames collected.");
|
463
468
|
|
464
469
|
rb_scan_args(argc, argv, "12", &lines, &frame, &force);
|
465
|
-
|
466
|
-
|
467
|
-
if (FIX2INT(frame) < 0 || FIX2INT(frame) >= context->stack_size)
|
470
|
+
if (FIX2INT(frame) < 0 || FIX2INT(frame) >= context->calced_stack_size)
|
468
471
|
rb_raise(rb_eRuntimeError, "Destination frame is out of range.");
|
469
|
-
|
472
|
+
|
473
|
+
context->lines = FIX2INT(lines);
|
474
|
+
context->dest_frame = context->calced_stack_size - FIX2INT(frame);
|
470
475
|
|
471
476
|
if (RTEST(force))
|
472
477
|
CTX_FL_SET(context, CTX_FL_FORCE_MOVE);
|
@@ -487,12 +492,12 @@ static VALUE
|
|
487
492
|
Context_stop_return(VALUE self, VALUE frame)
|
488
493
|
{
|
489
494
|
debug_context_t *context;
|
490
|
-
Data_Get_Struct(self, debug_context_t, context);
|
491
495
|
|
492
|
-
|
496
|
+
Data_Get_Struct(self, debug_context_t, context);
|
497
|
+
if (FIX2INT(frame) < 0 || FIX2INT(frame) >= context->calced_stack_size)
|
493
498
|
rb_raise(rb_eRuntimeError, "Stop frame is out of range.");
|
494
499
|
|
495
|
-
context->before_frame = context->
|
500
|
+
context->before_frame = context->calced_stack_size - FIX2INT(frame);
|
496
501
|
|
497
502
|
return frame;
|
498
503
|
}
|
@@ -628,27 +633,27 @@ Init_context(VALUE mByebug)
|
|
628
633
|
{
|
629
634
|
cContext = rb_define_class_under(mByebug, "Context", rb_cObject);
|
630
635
|
|
631
|
-
rb_define_method(cContext, "dead?"
|
632
|
-
rb_define_method(cContext, "frame_binding", Context_frame_binding, -1);
|
633
|
-
rb_define_method(cContext, "frame_class"
|
634
|
-
rb_define_method(cContext, "frame_file"
|
635
|
-
rb_define_method(cContext, "frame_line"
|
636
|
-
rb_define_method(cContext, "frame_method"
|
637
|
-
rb_define_method(cContext, "frame_self"
|
638
|
-
rb_define_method(cContext, "ignored?"
|
639
|
-
rb_define_method(cContext, "resume"
|
640
|
-
rb_define_method(cContext, "
|
641
|
-
rb_define_method(cContext, "step_into"
|
642
|
-
rb_define_method(cContext, "step_out"
|
643
|
-
rb_define_method(cContext, "step_over"
|
644
|
-
rb_define_method(cContext, "stop_return"
|
645
|
-
rb_define_method(cContext, "stop_reason"
|
646
|
-
rb_define_method(cContext, "suspend"
|
647
|
-
rb_define_method(cContext, "suspended?"
|
648
|
-
rb_define_method(cContext, "thnum"
|
649
|
-
rb_define_method(cContext, "thread"
|
650
|
-
rb_define_method(cContext, "tracing"
|
651
|
-
rb_define_method(cContext, "tracing="
|
636
|
+
rb_define_method(cContext, "dead?" , Context_dead , 0);
|
637
|
+
rb_define_method(cContext, "frame_binding" , Context_frame_binding , -1);
|
638
|
+
rb_define_method(cContext, "frame_class" , Context_frame_class , -1);
|
639
|
+
rb_define_method(cContext, "frame_file" , Context_frame_file , -1);
|
640
|
+
rb_define_method(cContext, "frame_line" , Context_frame_line , -1);
|
641
|
+
rb_define_method(cContext, "frame_method" , Context_frame_method , -1);
|
642
|
+
rb_define_method(cContext, "frame_self" , Context_frame_self , -1);
|
643
|
+
rb_define_method(cContext, "ignored?" , Context_ignored , 0);
|
644
|
+
rb_define_method(cContext, "resume" , Context_resume , 0);
|
645
|
+
rb_define_method(cContext, "calced_stack_size", Context_calced_stack_size, 0);
|
646
|
+
rb_define_method(cContext, "step_into" , Context_step_into , -1);
|
647
|
+
rb_define_method(cContext, "step_out" , Context_step_out , 1);
|
648
|
+
rb_define_method(cContext, "step_over" , Context_step_over , -1);
|
649
|
+
rb_define_method(cContext, "stop_return" , Context_stop_return , 1);
|
650
|
+
rb_define_method(cContext, "stop_reason" , Context_stop_reason , 0);
|
651
|
+
rb_define_method(cContext, "suspend" , Context_suspend , 0);
|
652
|
+
rb_define_method(cContext, "suspended?" , Context_is_suspended , 0);
|
653
|
+
rb_define_method(cContext, "thnum" , Context_thnum , 0);
|
654
|
+
rb_define_method(cContext, "thread" , Context_thread , 0);
|
655
|
+
rb_define_method(cContext, "tracing" , Context_tracing , 0);
|
656
|
+
rb_define_method(cContext, "tracing=" , Context_set_tracing , 1);
|
652
657
|
|
653
658
|
cDebugThread = rb_define_class_under(mByebug, "DebugThread", rb_cThread);
|
654
659
|
rb_define_singleton_method(cDebugThread, "inherited", DebugThread_inherited, 1);
|
data/ext/byebug/extconf.rb
CHANGED
data/lib/byebug.rb
CHANGED
@@ -65,8 +65,13 @@ module Byebug
|
|
65
65
|
breakpoint
|
66
66
|
end
|
67
67
|
|
68
|
+
#
|
69
|
+
# Remove a breakpoint
|
70
|
+
#
|
71
|
+
# @param [integer] breakpoint number
|
72
|
+
#
|
68
73
|
def remove_breakpoint(id)
|
69
|
-
|
74
|
+
breakpoints.delete_at(id)
|
70
75
|
end
|
71
76
|
|
72
77
|
def interface=(value)
|
@@ -190,7 +195,7 @@ module Byebug
|
|
190
195
|
end
|
191
196
|
|
192
197
|
def handle_post_mortem(exp)
|
193
|
-
return if !exp || !exp.__bb_context || exp.__bb_context.
|
198
|
+
return if !exp || !exp.__bb_context || !exp.__bb_context.calced_stack_size
|
194
199
|
orig_tracing = Byebug.tracing?
|
195
200
|
Byebug.tracing = false
|
196
201
|
Byebug.last_exception = exp
|
@@ -214,7 +219,7 @@ module Kernel
|
|
214
219
|
def byebug(steps_into = 1, steps_out = 2)
|
215
220
|
Byebug.start
|
216
221
|
Byebug.run_init_script(StringIO.new)
|
217
|
-
if Byebug.current_context.
|
222
|
+
if Byebug.current_context.calced_stack_size > 2
|
218
223
|
Byebug.current_context.stop_return steps_out if steps_out >= 1
|
219
224
|
end
|
220
225
|
Byebug.current_context.step_into steps_into if steps_into >= 0
|
data/lib/byebug/command.rb
CHANGED
@@ -168,7 +168,7 @@ module Byebug
|
|
168
168
|
register_setting_var(:forcestep, false)
|
169
169
|
register_setting_var(:fullpath, true)
|
170
170
|
register_setting_var(:listsize, 10)
|
171
|
-
register_setting_var(:
|
171
|
+
register_setting_var(:stack_on_error, false)
|
172
172
|
register_setting_var(:linetrace_plus, false)
|
173
173
|
cols = terminal_width || 160
|
174
174
|
register_setting_var(:width, cols > 10 ? cols : 160)
|
@@ -196,7 +196,7 @@ module Byebug
|
|
196
196
|
begin
|
197
197
|
eval(str, b)
|
198
198
|
rescue StandardError, ScriptError => e
|
199
|
-
if Command.settings[:
|
199
|
+
if Command.settings[:stack_on_error]
|
200
200
|
at = eval("Thread.current.backtrace_locations", b)
|
201
201
|
print "#{at.shift}: #{e.class} Exception(#{e.message})\n"
|
202
202
|
for i in at
|
@@ -241,18 +241,17 @@ module Byebug
|
|
241
241
|
# Use Byebug.settings[] and Byebug.settings[]= methods to query and set
|
242
242
|
# byebug settings. These settings are available:
|
243
243
|
#
|
244
|
-
# :autoeval
|
245
|
-
#
|
246
|
-
# :autoirb
|
247
|
-
# :autolist
|
248
|
-
# :autoreload
|
249
|
-
#
|
250
|
-
# :frame_class_names
|
251
|
-
#
|
252
|
-
# :
|
253
|
-
# :
|
254
|
-
#
|
255
|
-
# an exception
|
244
|
+
# :autoeval - evaluates input in the current binding if it's not
|
245
|
+
# recognized as a byebug command
|
246
|
+
# :autoirb - automatically calls 'irb' command on breakpoint
|
247
|
+
# :autolist - automatically calls 'list' command on breakpoint
|
248
|
+
# :autoreload - makes 'list' command always display up-to-date source
|
249
|
+
# code
|
250
|
+
# :frame_class_names - displays method's class name when showing frame stack
|
251
|
+
# :forcestep - stepping command always move to the new line
|
252
|
+
# :fullpath - displays full paths when showing frame stack
|
253
|
+
# :stack_on_error - shows full stack trace if eval command results in an
|
254
|
+
# exception
|
256
255
|
#
|
257
256
|
def self.settings
|
258
257
|
Command.settings
|
@@ -10,10 +10,10 @@ module Byebug
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def execute
|
13
|
-
max_frame = @state.context.stack_size - @state.frame_pos
|
14
13
|
if not @match[1]
|
15
14
|
frame_pos = @state.frame_pos
|
16
15
|
else
|
16
|
+
max_frame = Context.stack_size - @state.frame_pos
|
17
17
|
frame_pos = get_int(@match[1], "finish", 0, max_frame-1, 0)
|
18
18
|
return nil unless frame_pos
|
19
19
|
end
|
@@ -8,7 +8,7 @@ module Byebug
|
|
8
8
|
|
9
9
|
def switch_to_frame(frame_no)
|
10
10
|
if frame_no < 0
|
11
|
-
abs_frame_no =
|
11
|
+
abs_frame_no = Context.stack_size + frame_no
|
12
12
|
else
|
13
13
|
abs_frame_no = frame_no
|
14
14
|
end
|
@@ -20,7 +20,7 @@ module Byebug
|
|
20
20
|
step = jump_no/total_jumps
|
21
21
|
loop do
|
22
22
|
new_pos += step
|
23
|
-
return new_pos if new_pos < 0 || new_pos >=
|
23
|
+
return new_pos if new_pos < 0 || new_pos >= Context.stack_size
|
24
24
|
|
25
25
|
next if c_frame?(new_pos)
|
26
26
|
|
@@ -39,7 +39,7 @@ module Byebug
|
|
39
39
|
end
|
40
40
|
|
41
41
|
return errmsg "Can't navigate beyond the oldest frame\n" if
|
42
|
-
abs_frame_pos >=
|
42
|
+
abs_frame_pos >= Context.stack_size
|
43
43
|
return errmsg "Can't navigate beyond the newest frame\n" if
|
44
44
|
abs_frame_pos < 0
|
45
45
|
|
@@ -99,10 +99,10 @@ module Byebug
|
|
99
99
|
end
|
100
100
|
|
101
101
|
def print_backtrace
|
102
|
-
realsize = Context.
|
103
|
-
|
104
|
-
if
|
105
|
-
errmsg "Byebug's stacksize (#{
|
102
|
+
realsize = Context.stack_size
|
103
|
+
calcedsize = @state.context.calced_stack_size
|
104
|
+
if calcedsize != realsize
|
105
|
+
errmsg "Byebug's stacksize (#{calcedsize}) should be #{realsize}. " \
|
106
106
|
"This might be a bug in byebug or ruby's debugging API's\n"
|
107
107
|
end
|
108
108
|
(0...realsize).each do |idx|
|
data/lib/byebug/commands/set.rb
CHANGED
@@ -53,7 +53,7 @@ module Byebug
|
|
53
53
|
when /^post_mortem$/
|
54
54
|
Byebug.post_mortem = setting_value
|
55
55
|
when /^autoeval|autoreload|basename|forcestep|fullpath|linetrace_plus|
|
56
|
-
testing|
|
56
|
+
testing|stack_on_error$/x
|
57
57
|
Command.settings[setting_name.to_sym] = setting_value
|
58
58
|
else
|
59
59
|
return print "Unknown setting #{@match[1]}.\n"
|
@@ -61,7 +61,6 @@ module Byebug
|
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
|
-
|
65
64
|
# Implements byebug "set" command.
|
66
65
|
class SetCommand < Command
|
67
66
|
SubcmdStruct2 = Struct.new(:name,
|
@@ -91,7 +90,7 @@ module Byebug
|
|
91
90
|
'Set line execution tracing to show different lines'],
|
92
91
|
['listsize', 3, false, 'Set number of source lines to list by default'],
|
93
92
|
['post_mortem', 2, true, 'Enable post-mortem mode'],
|
94
|
-
['
|
93
|
+
['stack_on_error', 1, true,
|
95
94
|
'Display stack trace when "eval" raises exception'],
|
96
95
|
['verbose', 1, true,
|
97
96
|
'Enable verbose output of TracePoint API events is enabled'],
|
data/lib/byebug/commands/show.rb
CHANGED
@@ -128,8 +128,8 @@ module Byebug
|
|
128
128
|
when /^post_mortem$/
|
129
129
|
on_off = Byebug.post_mortem?
|
130
130
|
return "post-mortem mode is #{show_onoff(on_off)}"
|
131
|
-
when /^
|
132
|
-
on_off = Command.settings[:
|
131
|
+
when /^stack_on_error$/
|
132
|
+
on_off = Command.settings[:stack_on_error]
|
133
133
|
return "Displaying stack trace is #{show_onoff(on_off)}."
|
134
134
|
when /^verbose$/
|
135
135
|
on_off = Byebug.verbose
|
@@ -176,7 +176,7 @@ module Byebug
|
|
176
176
|
['listsize', 3, 'Show number of source lines to list by default'],
|
177
177
|
['post-mortem', 3, 'Show whether we should go into post-mortem ' \
|
178
178
|
'debugging on an uncaught exception'],
|
179
|
-
['
|
179
|
+
['stack_on_error', 1, 'Show whether a stack trace is displayed ' \
|
180
180
|
'when "eval" raises an exception'],
|
181
181
|
['verbose', 4, true,
|
182
182
|
'Show whether verbose output for debugging byebug itself is enabled'],
|
data/lib/byebug/context.rb
CHANGED
@@ -3,7 +3,7 @@ module Byebug
|
|
3
3
|
class Context
|
4
4
|
|
5
5
|
class << self
|
6
|
-
def
|
6
|
+
def stack_size
|
7
7
|
if backtrace = Thread.current.backtrace_locations
|
8
8
|
backtrace.drop_while { |l| ignored(l.path) || l.path == '(eval)' }
|
9
9
|
.take_while { |l| !ignored(l.path) }
|
@@ -11,6 +11,12 @@ module Byebug
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
+
def real_stack_size
|
15
|
+
if backtrace = Thread.current.backtrace_locations
|
16
|
+
backtrace.size
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
14
20
|
def ignored(path)
|
15
21
|
IGNORED_FILES.include?(path)
|
16
22
|
end
|
data/lib/byebug/processor.rb
CHANGED
@@ -87,13 +87,7 @@ module Byebug
|
|
87
87
|
file = CommandProcessor.canonic_file(context.frame_file(0))
|
88
88
|
line = context.frame_line(0)
|
89
89
|
print "Catchpoint at %s:%d: `%s' (%s)\n", file, line, excpt, excpt.class
|
90
|
-
|
91
|
-
tb = caller(0)[-fs..-1]
|
92
|
-
if tb
|
93
|
-
for i in tb
|
94
|
-
print "\tfrom %s\n", i
|
95
|
-
end
|
96
|
-
end
|
90
|
+
print_backtrace
|
97
91
|
end
|
98
92
|
protect :at_catchpoint
|
99
93
|
|
data/lib/byebug/version.rb
CHANGED
data/old_doc/byebug.texi
CHANGED
@@ -2882,12 +2882,10 @@ Return the filename of the location of the indicated frame position.
|
|
2882
2882
|
@vindex @code{Byebug.context.frame_method}
|
2883
2883
|
Symbol of the method name of the indicated frame position.
|
2884
2884
|
|
2885
|
-
@item Byebug.context.
|
2886
|
-
@vindex @code{Byebug.context.
|
2887
|
-
|
2888
|
-
that
|
2889
|
-
(@code{Byebug.start}) was turned on at after some blocks were added
|
2890
|
-
and not finished when the @code{Byebug.start} was issued.
|
2885
|
+
@item Byebug.context.calced_stack_size
|
2886
|
+
@vindex @code{Byebug.context.calced_stack_size}
|
2887
|
+
Returns the stack size calculated by byebug. This is initialized when byebug is
|
2888
|
+
started and after that is kept up-to-date using the TracePoint API events.
|
2891
2889
|
@end table
|
2892
2890
|
|
2893
2891
|
@node Byebug.settings
|
@@ -2926,7 +2924,7 @@ Boolean. @xref{Fullpath}.
|
|
2926
2924
|
Fixnum. Number of lines to show in a @code{list} command. @xref{Listsize}.
|
2927
2925
|
@item :autoreload
|
2928
2926
|
Boolean. True if we should reread the source every time it changes. @xref{Autoreload}.
|
2929
|
-
@item :
|
2927
|
+
@item :stack_on_error
|
2930
2928
|
Boolean. True if we should produce a stack trace on eval errors. @xref{Trace}.
|
2931
2929
|
@item :width
|
2932
2930
|
Fixnum. Number of characters byebug thinks are in a line. @xref{Width}.
|
data/test/eval_test.rb
CHANGED
@@ -53,7 +53,7 @@ class TestEval < TestDsl::TestCase
|
|
53
53
|
|
54
54
|
describe 'stack trace on error' do
|
55
55
|
describe 'when enabled' do
|
56
|
-
temporary_change_hash Byebug.settings, :
|
56
|
+
temporary_change_hash Byebug.settings, :stack_on_error, true
|
57
57
|
|
58
58
|
it 'must show a stack trace' do
|
59
59
|
enter 'eval 2 / 0'
|
@@ -64,7 +64,7 @@ class TestEval < TestDsl::TestCase
|
|
64
64
|
end
|
65
65
|
|
66
66
|
describe 'when disabled' do
|
67
|
-
temporary_change_hash Byebug.settings, :
|
67
|
+
temporary_change_hash Byebug.settings, :stack_on_error, false
|
68
68
|
|
69
69
|
it 'must only show exception' do
|
70
70
|
enter 'eval 2 / 0'
|
data/test/show_test.rb
CHANGED
@@ -115,9 +115,9 @@ class TestShow < TestDsl::TestCase
|
|
115
115
|
end
|
116
116
|
end
|
117
117
|
|
118
|
-
describe '
|
119
|
-
it 'must show
|
120
|
-
enter 'show
|
118
|
+
describe 'stack_on_error' do
|
119
|
+
it 'must show stack_on_error' do
|
120
|
+
enter 'show stack_on_error'
|
121
121
|
debug_file 'show'
|
122
122
|
check_output_includes 'Displaying stack trace is off.'
|
123
123
|
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: 2.2.
|
4
|
+
version: 2.2.1
|
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: 2013-09-
|
13
|
+
date: 2013-09-24 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: columnize
|