Class: Debugger::Context
- Inherits:
-
Object
- Object
- Debugger::Context
- Defined in:
- lib/ruby-debug.rb,
ext/ruby_debug.c
Instance Method Summary collapse
-
#dead?( = bool) ⇒ Boolean
Returns
true
if context doesn’t represent a live context and is created during post-mortem exception handling. -
#frame_binding(frame) ⇒ Binding
Returns frame’s binding.
-
#frame_file(frame) ⇒ String
Returns the name of the file.
-
#frame_id(frame) ⇒ Object
Returns the sym of the called method.
-
#frame_line(frame) ⇒ Integer
Returns the line number in the file.
-
#frame_locals(frame) ⇒ Hash
Returns frame’s local variables.
-
#frame_self(frame) ⇒ Object
Returns self object of the frame.
-
#ignore ⇒ Boolean
Returns the ignore flag for the current context.
-
#tracking=(bool) ⇒ Object
Controls the ignore flag for this context.
- #interrupt ⇒ Object
-
#resume ⇒ nil
Resumes the thread from the suspended mode.
-
#stack_size ⇒ Object
Returns the size of the context stack.
-
#step_over(steps) ⇒ Object
Steps over a
steps
number of times. -
#stop_frame(frame) ⇒ Object
Stops when a frame with number
frame
is activated. -
#stop_next=(steps) ⇒ Object
Stops the current context after a number
steps
are made. -
#suspend ⇒ nil
Suspends the thread when it is running.
-
#suspended? ⇒ Boolean
Returns
true
if the thread is suspended by debugger. -
#thnum ⇒ Integer
Returns the context’s number.
-
#thread ⇒ Object
Returns a thread this context is associated with.
-
#tracing ⇒ Boolean
Returns the tracing flag for the current context.
-
#tracking=(bool) ⇒ Object
Controls the tracing for this context.
Instance Method Details
#dead?( = bool) ⇒ Boolean
Returns true
if context doesn’t represent a live context and is created during post-mortem exception handling.
1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 |
# File 'ext/ruby_debug.c', line 1966
static VALUE
context_dead(VALUE self)
{
debug_context_t *debug_context;
debug_check_started();
Data_Get_Struct(self, debug_context_t, debug_context);
return CTX_FL_TEST(debug_context, CTX_FL_DEAD) ? Qtrue : Qfalse;
}
|
#frame_binding(frame) ⇒ Binding
Returns frame’s binding.
1618 1619 1620 1621 1622 1623 1624 1625 1626 |
# File 'ext/ruby_debug.c', line 1618
static VALUE
context_frame_binding(VALUE self, VALUE frame)
{
debug_context_t *debug_context;
debug_check_started();
Data_Get_Struct(self, debug_context_t, debug_context);
return GET_FRAME->binding;
}
|
#frame_file(frame) ⇒ String
Returns the name of the file.
1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 |
# File 'ext/ruby_debug.c', line 1671
static VALUE
context_frame_file(VALUE self, VALUE frame)
{
debug_context_t *debug_context;
debug_check_started();
Data_Get_Struct(self, debug_context_t, debug_context);
return rb_str_new2(GET_FRAME->file);
}
|
#frame_id(frame) ⇒ Object
Returns the sym of the called method.
1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 |
# File 'ext/ruby_debug.c', line 1634
static VALUE
context_frame_id(VALUE self, VALUE frame)
{
debug_context_t *debug_context;
ID id;
debug_check_started();
Data_Get_Struct(self, debug_context_t, debug_context);
id = GET_FRAME->id;
return id ? ID2SYM(id): Qnil;
}
|
#frame_line(frame) ⇒ Integer
Returns the line number in the file.
1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 |
# File 'ext/ruby_debug.c', line 1654
static VALUE
context_frame_line(VALUE self, VALUE frame)
{
debug_context_t *debug_context;
debug_check_started();
Data_Get_Struct(self, debug_context_t, debug_context);
return INT2FIX(GET_FRAME->line);
}
|
#frame_locals(frame) ⇒ Hash
Returns frame’s local variables.
1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 |
# File 'ext/ruby_debug.c', line 1718
static VALUE
context_frame_locals(VALUE self, VALUE frame)
{
debug_context_t *debug_context;
debug_frame_t *debug_frame;
debug_check_started();
Data_Get_Struct(self, debug_context_t, debug_context);
debug_frame = GET_FRAME;
if(debug_frame->dead)
return debug_frame->info.copy.locals;
else
return context_copy_locals(debug_frame);
}
|
#frame_self(frame) ⇒ Object
Returns self object of the frame.
1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 |
# File 'ext/ruby_debug.c', line 1740
static VALUE
context_frame_self(VALUE self, VALUE frame)
{
debug_context_t *debug_context;
debug_frame_t *debug_frame;
debug_check_started();
Data_Get_Struct(self, debug_context_t, debug_context);
debug_frame = GET_FRAME;
return debug_frame->self;
}
|
#ignore ⇒ Boolean
Returns the ignore flag for the current context.
1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 |
# File 'ext/ruby_debug.c', line 1927
static VALUE
context_ignore(VALUE self)
{
debug_context_t *debug_context;
debug_check_started();
Data_Get_Struct(self, debug_context_t, debug_context);
return CTX_FL_TEST(debug_context, CTX_FL_IGNORE) ? Qtrue : Qfalse;
}
|
#tracking=(bool) ⇒ Object
Controls the ignore flag for this context.
1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 |
# File 'ext/ruby_debug.c', line 1944
static VALUE
context_set_ignore(VALUE self, VALUE value)
{
debug_context_t *debug_context;
debug_check_started();
Data_Get_Struct(self, debug_context_t, debug_context);
if(RTEST(value))
CTX_FL_SET(debug_context, CTX_FL_IGNORE);
else
CTX_FL_UNSET(debug_context, CTX_FL_IGNORE);
return value;
}
|
#interrupt ⇒ Object
18 19 20 |
# File 'lib/ruby-debug.rb', line 18 def interrupt self.stop_next = 1 end |
#resume ⇒ nil
Resumes the thread from the suspended mode.
1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 |
# File 'ext/ruby_debug.c', line 1869
static VALUE
context_resume(VALUE self)
{
debug_context_t *debug_context;
debug_check_started();
Data_Get_Struct(self, debug_context_t, debug_context);
if(!CTX_FL_TEST(debug_context, CTX_FL_SUSPEND))
rb_raise(rb_eRuntimeError, "Thread is not suspended.");
context_resume_0(debug_context);
return Qnil;
}
|
#stack_size ⇒ Object
Returns the size of the context stack.
1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 |
# File 'ext/ruby_debug.c', line 1759
static VALUE
context_stack_size(VALUE self)
{
debug_context_t *debug_context;
debug_check_started();
Data_Get_Struct(self, debug_context_t, debug_context);
return INT2FIX(debug_context->stack_size);
}
|
#step_over(steps) ⇒ Object
Steps over a steps
number of times.
1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 |
# File 'ext/ruby_debug.c', line 1553
static VALUE
context_step_over(int argc, VALUE *argv, VALUE self)
{
VALUE lines, frame;
debug_context_t *debug_context;
debug_check_started();
Data_Get_Struct(self, debug_context_t, debug_context);
if(debug_context->stack_size == 0)
rb_raise(rb_eRuntimeError, "No frames collected.");
rb_scan_args(argc, argv, "11", &lines, &frame);
debug_context->stop_line = FIX2INT(lines);
if(argc == 1)
{
debug_context->dest_frame = debug_context->stack_size;
}
else
{
if(FIX2INT(frame) < 0 && FIX2INT(frame) >= debug_context->stack_size)
rb_raise(rb_eRuntimeError, "Destination frame is out of range.");
debug_context->dest_frame = debug_context->stack_size - FIX2INT(frame);
}
return Qnil;
}
|
#stop_frame(frame) ⇒ Object
Stops when a frame with number frame
is activated. Implements up
and down
commands.
1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 |
# File 'ext/ruby_debug.c', line 1586
static VALUE
context_stop_frame(VALUE self, VALUE frame)
{
debug_context_t *debug_context;
debug_check_started();
Data_Get_Struct(self, debug_context_t, debug_context);
if(FIX2INT(frame) < 0 && FIX2INT(frame) >= debug_context->stack_size)
rb_raise(rb_eRuntimeError, "Stop frame is out of range.");
debug_context->stop_frame = debug_context->stack_size - FIX2INT(frame);
return frame;
}
|
#stop_next=(steps) ⇒ Object
Stops the current context after a number steps
are made.
1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 |
# File 'ext/ruby_debug.c', line 1533
static VALUE
context_stop_next(VALUE self, VALUE steps)
{
debug_context_t *debug_context;
debug_check_started();
Data_Get_Struct(self, debug_context_t, debug_context);
if(FIX2INT(steps) < 0)
rb_raise(rb_eRuntimeError, "Steps argument can't be negative.");
debug_context->stop_next = FIX2INT(steps);
return steps;
}
|
#suspend ⇒ nil
Suspends the thread when it is running.
1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 |
# File 'ext/ruby_debug.c', line 1832
static VALUE
context_suspend(VALUE self)
{
debug_context_t *debug_context;
debug_check_started();
Data_Get_Struct(self, debug_context_t, debug_context);
if(CTX_FL_TEST(debug_context, CTX_FL_SUSPEND))
rb_raise(rb_eRuntimeError, "Already suspended.");
context_suspend_0(debug_context);
return Qnil;
}
|
#suspended? ⇒ Boolean
Returns true
if the thread is suspended by debugger.
1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 |
# File 'ext/ruby_debug.c', line 1852
static VALUE
context_is_suspended(VALUE self)
{
debug_context_t *debug_context;
debug_check_started();
Data_Get_Struct(self, debug_context_t, debug_context);
return CTX_FL_TEST(debug_context, CTX_FL_SUSPEND) ? Qtrue : Qfalse;
}
|
#thnum ⇒ Integer
Returns the context’s number.
1792 1793 1794 1795 1796 1797 1798 1799 |
# File 'ext/ruby_debug.c', line 1792
static VALUE
context_thnum(VALUE self)
{
debug_context_t *debug_context;
Data_Get_Struct(self, debug_context_t, debug_context);
return INT2FIX(debug_context->thnum);
}
|
#thread ⇒ Object
Returns a thread this context is associated with.
1776 1777 1778 1779 1780 1781 1782 1783 1784 |
# File 'ext/ruby_debug.c', line 1776
static VALUE
context_thread(VALUE self)
{
debug_context_t *debug_context;
debug_check_started();
Data_Get_Struct(self, debug_context_t, debug_context);
return context_thread_0(debug_context);
}
|
#tracing ⇒ Boolean
Returns the tracing flag for the current context.
1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 |
# File 'ext/ruby_debug.c', line 1889
static VALUE
context_tracing(VALUE self)
{
debug_context_t *debug_context;
debug_check_started();
Data_Get_Struct(self, debug_context_t, debug_context);
return CTX_FL_TEST(debug_context, CTX_FL_TRACING) ? Qtrue : Qfalse;
}
|
#tracking=(bool) ⇒ Object
Controls the tracing for this context.
1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 |
# File 'ext/ruby_debug.c', line 1906
static VALUE
context_set_tracing(VALUE self, VALUE value)
{
debug_context_t *debug_context;
debug_check_started();
Data_Get_Struct(self, debug_context_t, debug_context);
if(RTEST(value))
CTX_FL_SET(debug_context, CTX_FL_TRACING);
else
CTX_FL_UNSET(debug_context, CTX_FL_TRACING);
return value;
}
|