Module: Byebug
- Defined in:
- ext/byebug/byebug.c
Defined Under Namespace
Classes: DebugThread, ThreadsTable
Class Method Summary collapse
-
.add_catchpoint(exception) ⇒ Exception
Adds a new exception to the catchpoints array.
-
.breakpoints ⇒ Array
Returns an array of breakpoints.
-
.catchpoints ⇒ Array
Returns an array of catchpoints.
-
.contexts ⇒ Array
Returns an array of all contexts.
-
.current_context ⇒ Object
Returns the current context.
-
.debug_load(file, stop = false) ⇒ nil
Same as Kernel#load but resets current context’s frames.
-
.post_mortem=(bool) ⇒ Object
Sets post-moterm flag.
-
.post_mortem? ⇒ Boolean
Returns
true
if post-mortem debugging is enabled. -
.raised_exception ⇒ Exception
Returns raised exception when in post_mortem mode.
-
.start ⇒ Object
If a block is given, it starts byebug and yields block.
-
.started? ⇒ Boolean
Returns
true
byebug is started. -
.stop ⇒ Boolean
This method disables byebug.
-
.thread_context(thread) ⇒ Object
Returns context of the thread passed as an argument.
-
.tracing=(bool) ⇒ Object
Sets the global tracing flag.
-
.tracing? ⇒ Boolean
Returns
true
if global tracing is enabled. -
.verbose=(bool) ⇒ Object
Enable verbose output of every TracePoint API events, useful for debugging byebug.
-
.verbose? ⇒ Boolean
Returns
true
if verbose output of TracePoint API events is enabled.
Class Method Details
.add_catchpoint(exception) ⇒ Exception
Adds a new exception to the catchpoints array.
761 762 763 764 765 766 767 768 769 |
# File 'ext/byebug/byebug.c', line 761
static VALUE
bb_add_catchpoint(VALUE self, VALUE value)
{
if (TYPE(value) != T_STRING)
rb_raise(rb_eTypeError, "value of a catchpoint must be String");
rb_hash_aset(catchpoints, rb_str_dup(value), INT2FIX(0));
return value;
}
|
.breakpoints ⇒ Array
Returns an array of breakpoints.
27 28 29 30 31 32 33 34 |
# File 'ext/byebug/byebug.c', line 27
static VALUE
bb_breakpoints(VALUE self)
{
if (NIL_P(breakpoints))
breakpoints = rb_ary_new();
return breakpoints;
}
|
.catchpoints ⇒ Array
Returns an array of catchpoints.
42 43 44 45 46 |
# File 'ext/byebug/byebug.c', line 42
static VALUE
bb_catchpoints(VALUE self)
{
return catchpoints;
}
|
.contexts ⇒ Array
Returns an array of all contexts.
490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 |
# File 'ext/byebug/byebug.c', line 490
static VALUE
bb_contexts(VALUE self)
{
volatile VALUE list;
volatile VALUE new_list;
VALUE context;
threads_table_t *t_tbl;
debug_context_t *dc;
int i;
check_started();
new_list = rb_ary_new();
list = rb_funcall(rb_cThread, rb_intern("list"), 0);
for (i = 0; i < RARRAY_LENINT(list); i++)
{
VALUE thread = rb_ary_entry(list, i);
thread_context_lookup(thread, &context);
rb_ary_push(new_list, context);
}
Data_Get_Struct(threads, threads_table_t, t_tbl);
st_clear(t_tbl->tbl);
for (i = 0; i < RARRAY_LENINT(new_list); i++)
{
context = rb_ary_entry(new_list, i);
Data_Get_Struct(context, debug_context_t, dc);
st_insert(t_tbl->tbl, dc->thread, context);
}
return new_list;
}
|
.current_context ⇒ Object
Returns the current context.
<i>Note:</i> Byebug.current_context.thread == Thread.current
550 551 552 553 554 555 556 557 558 559 560 |
# File 'ext/byebug/byebug.c', line 550
static VALUE
bb_current_context(VALUE self)
{
VALUE context;
check_started();
thread_context_lookup(rb_thread_current(), &context);
return context;
}
|
.debug_load(file, stop = false) ⇒ nil
Same as Kernel#load but resets current context’s frames. stop
parameter forces byebug to stop at the first line of code in file
641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 |
# File 'ext/byebug/byebug.c', line 641
static VALUE
bb_load(int argc, VALUE *argv, VALUE self)
{
VALUE file, stop, context;
debug_context_t *dc;
VALUE status = Qnil;
int state = 0;
if (rb_scan_args(argc, argv, "11", &file, &stop) == 1)
{
stop = Qfalse;
}
bb_start(self);
context = bb_current_context(self);
Data_Get_Struct(context, debug_context_t, dc);
dc->calced_stack_size = 1;
if (RTEST(stop)) dc->steps = 1;
/* Initializing $0 to the script's path */
ruby_script(RSTRING_PTR(file));
rb_load_protect(file, 0, &state);
if (0 != state)
{
status = rb_errinfo();
reset_stepping_stop_points(dc);
}
/* We should run all at_exit handler's in order to provide, for instance, a
* chance to run all defined test cases */
rb_exec_end_proc();
return status;
}
|
.post_mortem=(bool) ⇒ Object
Sets post-moterm flag.
748 749 750 751 752 753 |
# File 'ext/byebug/byebug.c', line 748
static VALUE
bb_set_post_mortem(VALUE self, VALUE value)
{
post_mortem = RTEST(value) ? Qtrue : Qfalse;
return value;
}
|
.post_mortem? ⇒ Boolean
Returns true
if post-mortem debugging is enabled.
736 737 738 739 740 |
# File 'ext/byebug/byebug.c', line 736
static VALUE
bb_post_mortem(VALUE self)
{
return post_mortem;
}
|
.raised_exception ⇒ Exception
Returns raised exception when in post_mortem mode.
54 55 56 57 58 |
# File 'ext/byebug/byebug.c', line 54
static VALUE
bb_raised_exception(VALUE self)
{
return raised_exception;
}
|
.start ⇒ Boolean .start { ... } ⇒ Boolean
If a block is given, it starts byebug and yields block. After the block is executed it stops byebug with Byebug.stop method. Inside the block you will probably want to have a call to Byebug.byebug. For example:
Byebug.start { byebug; foo } # Stop inside of foo
The return value is the value of !Byebug.started? before issuing the start
; That is, true
is returned, unless byebug was previously started.
611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 |
# File 'ext/byebug/byebug.c', line 611
static VALUE
bb_start(VALUE self)
{
VALUE result;
if (IS_STARTED)
result = Qfalse;
else
{
locker = Qnil;
catchpoints = rb_hash_new();
threads = create_threads_table();
register_tracepoints(self);
result = Qtrue;
}
if (rb_block_given_p())
rb_ensure(rb_yield, self, bb_stop, self);
return result;
}
|
.started? ⇒ Boolean
Returns true
byebug is started.
568 569 570 571 572 |
# File 'ext/byebug/byebug.c', line 568
static VALUE
bb_started(VALUE self)
{
return IS_STARTED;
}
|
.stop ⇒ Boolean
This method disables byebug. It returns true
if byebug was already disabled, otherwise it returns false
.
581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 |
# File 'ext/byebug/byebug.c', line 581
static VALUE
bb_stop(VALUE self)
{
if (IS_STARTED)
{
clear_tracepoints(self);
breakpoints = Qnil;
catchpoints = Qnil;
threads = Qnil;
return Qfalse;
}
return Qtrue;
}
|
.thread_context(thread) ⇒ Object
Returns context of the thread passed as an argument.
531 532 533 534 535 536 537 538 539 540 541 |
# File 'ext/byebug/byebug.c', line 531
static VALUE
bb_thread_context(VALUE self, VALUE thread)
{
VALUE context;
check_started();
thread_context_lookup(thread, &context);
return context;
}
|
.tracing=(bool) ⇒ Object
Sets the global tracing flag.
723 724 725 726 727 728 |
# File 'ext/byebug/byebug.c', line 723
static VALUE
bb_set_tracing(VALUE self, VALUE value)
{
tracing = RTEST(value) ? Qtrue : Qfalse;
return value;
}
|
.tracing? ⇒ Boolean
Returns true
if global tracing is enabled.
711 712 713 714 715 |
# File 'ext/byebug/byebug.c', line 711
static VALUE
bb_tracing(VALUE self)
{
return tracing;
}
|
.verbose=(bool) ⇒ Object
Enable verbose output of every TracePoint API events, useful for debugging byebug.
698 699 700 701 702 703 |
# File 'ext/byebug/byebug.c', line 698
static VALUE
bb_set_verbose(VALUE self, VALUE value)
{
verbose = RTEST(value) ? Qtrue : Qfalse;
return value;
}
|
.verbose? ⇒ Boolean
Returns true
if verbose output of TracePoint API events is enabled.
685 686 687 688 689 |
# File 'ext/byebug/byebug.c', line 685
static VALUE
bb_verbose(VALUE self)
{
return verbose;
}
|