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 hash.
-
.breakpoints ⇒ Array
Returns an array of breakpoints.
-
.catchpoints ⇒ Hash
Returns the catchpoints hash.
-
.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.
-
.lock ⇒ Thread.current
Locks global switch to reserve execution to current thread exclusively.
-
.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 ⇒ Boolean
The return value is the value of !Byebug.started? before issuing the
start
; That is,true
is returned, unless byebug was previously started. -
.started? ⇒ Boolean
Returns
true
byebug is started. -
.stop ⇒ Boolean
This method disables byebug.
- .stoppable? ⇒ Boolean
-
.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. -
.unlock ⇒ nil
Unlocks global switch so other threads can run.
-
.verbose=(bool) ⇒ Object
Sets the global verbose flag for TracePoint API events is enabled.
-
.verbose? ⇒ Boolean
Returns
true
if global verbose flag for TracePoint API events is enabled.
Class Method Details
.add_catchpoint(exception) ⇒ Exception
Adds a new exception to the catchpoints hash.
849 850 851 852 853 854 855 856 857 858 859 |
# File 'ext/byebug/byebug.c', line 849
static VALUE
Add_catchpoint(VALUE self, VALUE value)
{
UNUSED(self);
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 35 36 |
# File 'ext/byebug/byebug.c', line 27
static VALUE
Breakpoints(VALUE self)
{
UNUSED(self);
if (NIL_P(breakpoints))
breakpoints = rb_ary_new();
return breakpoints;
}
|
.catchpoints ⇒ Hash
Returns the catchpoints hash.
44 45 46 47 48 49 50 |
# File 'ext/byebug/byebug.c', line 44
static VALUE
Catchpoints(VALUE self)
{
UNUSED(self);
return catchpoints;
}
|
.contexts ⇒ Array
Returns an array of all contexts.
545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 |
# File 'ext/byebug/byebug.c', line 545
static VALUE
Contexts(VALUE self)
{
volatile VALUE list;
volatile VALUE new_list;
VALUE context;
threads_table_t *t_tbl;
debug_context_t *dc;
int i;
UNUSED(self);
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
610 611 612 613 614 615 616 617 618 619 620 |
# File 'ext/byebug/byebug.c', line 610
static VALUE
Current_context(VALUE self)
{
VALUE context;
UNUSED(self);
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
723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 |
# File 'ext/byebug/byebug.c', line 723
static VALUE
Debug_load(int argc, VALUE * argv, VALUE self)
{
VALUE file, stop, context;
debug_context_t *dc;
VALUE status = Qnil;
int state = 0;
UNUSED(self);
if (rb_scan_args(argc, argv, "11", &file, &stop) == 1)
stop = Qfalse;
Start(self);
context = Current_context(self);
Data_Get_Struct(context, debug_context_t, dc);
dc->calced_stack_size = 1;
if (RTEST(stop))
dc->steps = 1;
rb_load_protect(file, 0, &state);
if (0 != state)
{
status = rb_errinfo();
reset_stepping_stop_points(dc);
}
return status;
}
|
.lock ⇒ Thread.current
Locks global switch to reserve execution to current thread exclusively.
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 |
# File 'ext/byebug/threads.c', line 196
static VALUE
Lock(VALUE self)
{
debug_context_t *dc;
VALUE context;
UNUSED(self);
if (!is_living_thread(rb_thread_current()))
rb_raise(rb_eRuntimeError, "Current thread is dead!");
thread_context_lookup(rb_thread_current(), &context);
Data_Get_Struct(context, debug_context_t, dc);
acquire_lock(dc);
return locker;
}
|
.post_mortem=(bool) ⇒ Object
Sets post-moterm flag.
834 835 836 837 838 839 840 841 |
# File 'ext/byebug/byebug.c', line 834
static VALUE
Set_post_mortem(VALUE self, VALUE value)
{
UNUSED(self);
post_mortem = RTEST(value) ? Qtrue : Qfalse;
return value;
}
|
.post_mortem? ⇒ Boolean
Returns true
if post-mortem debugging is enabled.
820 821 822 823 824 825 826 |
# File 'ext/byebug/byebug.c', line 820
static VALUE
Post_mortem(VALUE self)
{
UNUSED(self);
return post_mortem;
}
|
.raised_exception ⇒ Exception
Returns raised exception when in post_mortem mode.
58 59 60 61 62 63 64 |
# File 'ext/byebug/byebug.c', line 58
static VALUE
Raised_exception(VALUE self)
{
UNUSED(self);
return raised_exception;
}
|
.start ⇒ Boolean
The return value is the value of !Byebug.started? before issuing the start
; That is, true
is returned, unless byebug was previously started.
701 702 703 704 705 706 707 708 709 710 711 712 713 714 |
# File 'ext/byebug/byebug.c', line 701
static VALUE
Start(VALUE self)
{
if (IS_STARTED)
return Qfalse;
catchpoints = rb_hash_new();
threads = create_threads_table();
register_tracepoints(self);
return Qtrue;
}
|
.started? ⇒ Boolean
Returns true
byebug is started.
628 629 630 631 632 633 634 |
# File 'ext/byebug/byebug.c', line 628
static VALUE
Started(VALUE self)
{
UNUSED(self);
return IS_STARTED ? Qtrue : Qfalse;
}
|
.stop ⇒ Boolean
This method disables byebug. It returns true
if byebug was already disabled, otherwise it returns false
.
643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 |
# File 'ext/byebug/byebug.c', line 643
static VALUE
Stop(VALUE self)
{
UNUSED(self);
if (IS_STARTED)
{
clear_tracepoints(self);
breakpoints = Qnil;
catchpoints = Qnil;
return Qfalse;
}
return Qtrue;
}
|
.stoppable? ⇒ Boolean
661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 |
# File 'ext/byebug/byebug.c', line 661
static VALUE
Stoppable(VALUE self)
{
VALUE context;
debug_context_t *dc;
if (!IS_STARTED)
return Qfalse;
if (!NIL_P(breakpoints) && rb_funcall(breakpoints, idEmpty, 0) == Qfalse)
return Qfalse;
if (!NIL_P(catchpoints) && rb_funcall(catchpoints, idEmpty, 0) == Qfalse)
return Qfalse;
if (post_mortem == Qtrue)
return Qfalse;
if (RTEST(tracing))
return Qfalse;
context = Current_context(self);
if (!NIL_P(context))
{
Data_Get_Struct(context, debug_context_t, dc);
if (dc->steps > 0)
return Qfalse;
}
return Qtrue;
}
|
.thread_context(thread) ⇒ Object
Returns context of the thread passed as an argument.
589 590 591 592 593 594 595 596 597 598 599 600 601 |
# File 'ext/byebug/byebug.c', line 589
static VALUE
Thread_context(VALUE self, VALUE thread)
{
VALUE context;
UNUSED(self);
check_started();
thread_context_lookup(thread, &context);
return context;
}
|
.tracing=(bool) ⇒ Object
Sets the global tracing flag.
776 777 778 779 780 781 782 783 |
# File 'ext/byebug/byebug.c', line 776
static VALUE
Set_tracing(VALUE self, VALUE value)
{
UNUSED(self);
tracing = RTEST(value) ? Qtrue : Qfalse;
return value;
}
|
.tracing? ⇒ Boolean
Returns true
if global tracing is enabled.
762 763 764 765 766 767 768 |
# File 'ext/byebug/byebug.c', line 762
static VALUE
Tracing(VALUE self)
{
UNUSED(self);
return tracing;
}
|
.unlock ⇒ nil
Unlocks global switch so other threads can run.
180 181 182 183 184 185 186 187 188 |
# File 'ext/byebug/threads.c', line 180
static VALUE
Unlock(VALUE self)
{
UNUSED(self);
release_lock();
return locker;
}
|
.verbose=(bool) ⇒ Object
Sets the global verbose flag for TracePoint API events is enabled.
805 806 807 808 809 810 811 812 |
# File 'ext/byebug/byebug.c', line 805
static VALUE
Set_verbose(VALUE self, VALUE value)
{
UNUSED(self);
verbose = RTEST(value) ? Qtrue : Qfalse;
return value;
}
|
.verbose? ⇒ Boolean
Returns true
if global verbose flag for TracePoint API events is enabled.
791 792 793 794 795 796 797 |
# File 'ext/byebug/byebug.c', line 791
static VALUE
Verbose(VALUE self)
{
UNUSED(self);
return verbose;
}
|