Module: Debugger
- Defined in:
- ext/ruby_debug/ruby_debug.c
Constant Summary collapse
- VERSION =
rb_str_new2(DEBUG_VERSION)
Class Method Summary collapse
-
.add_breakpoint(source, pos, condition = nil) ⇒ Object
Adds a new breakpoint.
-
.catchpoint(string) ⇒ String
Sets catchpoint.
-
.breakpoints ⇒ Array
Returns an array of breakpoints.
-
.catchall ⇒ Object
:nodoc:.
-
.catchall=(value) ⇒ Object
:nodoc:.
-
.catchpoints ⇒ Hash
Returns a current catchpoints, which is a hash exception names that will trigger a debugger when raised.
-
.contexts ⇒ Array
Returns an array of all contexts.
-
.current_context ⇒ Object
Returns current context.
-
.debug ⇒ Object
:nodoc:.
-
.debug=(value) ⇒ Object
:nodoc:.
-
.debug_at_exit { ... } ⇒ Proc
Register
at_exit
hook which is escaped from the debugger. -
.debug_load(file, stop = false, increment_start = false) ⇒ nil
Same as Kernel#load but resets current context’s frames.
-
.last_interrupted ⇒ Object
Returns last debugged context.
-
.remove_breakpoint(id) ⇒ Object
Removes breakpoint by its id.
-
.resume ⇒ Debugger
Resumes all contexts.
-
.skip { ... } ⇒ Object?
The code inside of the block is escaped from the debugger.
-
.skip_next_exception ⇒ Object
:nodoc:.
-
.start_ ⇒ Object
Deprecated.
-
.started? ⇒ Boolean
Returns
true
the debugger is started. -
.stop ⇒ Boolean
Deprecated.
-
.suspend ⇒ Debugger
Suspends all contexts.
-
.thread_context(thread) ⇒ Object
Returns context of the thread passed as an argument.
-
.tracing ⇒ Boolean
Returns
true
if the global tracing is activated. -
.tracing=(bool) ⇒ Object
Sets the global tracing flag.
Class Method Details
.add_breakpoint(source, pos, condition = nil) ⇒ Object
Adds a new breakpoint. source is a name of a file or a class. pos is a line number or a method name if source is a class name. condition is a string which is evaluated to true
when this breakpoint is activated.
2433 2434 2435 2436 2437 2438 2439 2440 2441 |
# File 'ext/ruby_debug/ruby_debug.c', line 2433
static VALUE
debug_add_breakpoint(int argc, VALUE *argv, VALUE self)
{
VALUE result;
result = create_breakpoint_from_args(argc, argv, ++bkp_count);
rb_ary_push(rdebug_breakpoints, result);
return result;
}
|
.catchpoint(string) ⇒ String
Sets catchpoint. Returns the string passed.
247 248 249 250 251 252 253 254 255 |
# File 'ext/ruby_debug/breakpoint.c', line 247
VALUE
rdebug_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(rdebug_catchpoints, rb_str_dup(value), INT2FIX(0));
return value;
}
|
.breakpoints ⇒ Array
Returns an array of breakpoints.
2417 2418 2419 2420 2421 |
# File 'ext/ruby_debug/ruby_debug.c', line 2417
static VALUE
debug_breakpoints(VALUE self)
{
return rdebug_breakpoints;
}
|
.catchall ⇒ Object
:nodoc:
1537 1538 1539 1540 1541 |
# File 'ext/ruby_debug/ruby_debug.c', line 1537
static VALUE
debug_catchall(VALUE self)
{
return catchall;
}
|
.catchall=(value) ⇒ Object
:nodoc:
1544 1545 1546 1547 1548 1549 |
# File 'ext/ruby_debug/ruby_debug.c', line 1544
static VALUE
debug_set_catchall(VALUE self, VALUE value)
{
catchall = RTEST(value) ? Qtrue : Qfalse;
return value;
}
|
.catchpoints ⇒ Hash
Returns a current catchpoints, which is a hash exception names that will trigger a debugger when raised. The values are the number of times taht catchpoint was hit, initially 0.
235 236 237 238 239 |
# File 'ext/ruby_debug/breakpoint.c', line 235
VALUE
debug_catchpoints(VALUE self)
{
return rdebug_catchpoints;
}
|
.contexts ⇒ Array
Returns an array of all contexts.
1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 |
# File 'ext/ruby_debug/ruby_debug.c', line 1406
static VALUE
debug_contexts(VALUE self)
{
volatile VALUE list;
volatile VALUE new_list;
VALUE thread, context;
threads_table_t *threads_table;
debug_context_t *debug_context;
int i;
new_list = rb_ary_new();
list = rb_funcall(rb_cThread, idList, 0);
for(i = 0; i < RARRAY_LEN(list); i++)
{
thread = rb_ary_entry(list, i);
thread_context_lookup(thread, &context, NULL, 1);
rb_ary_push(new_list, context);
}
threads_table_clear(rdebug_threads_tbl);
Data_Get_Struct(rdebug_threads_tbl, threads_table_t, threads_table);
for(i = 0; i < RARRAY_LEN(new_list); i++)
{
context = rb_ary_entry(new_list, i);
Data_Get_Struct(context, debug_context_t, debug_context);
st_insert(threads_table->tbl, debug_context->thread_id, context);
}
return new_list;
}
|
.current_context ⇒ Object
Returns current context. Note: Debugger.current_context.thread == Thread.current
1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 |
# File 'ext/ruby_debug/ruby_debug.c', line 1374
static VALUE
debug_current_context(VALUE self)
{
VALUE thread, context;
thread = rb_thread_current();
thread_context_lookup(thread, &context, NULL, 1);
return context;
}
|
.debug ⇒ Object
:nodoc:
1522 1523 1524 1525 1526 |
# File 'ext/ruby_debug/ruby_debug.c', line 1522
static VALUE
debug_debug(VALUE self)
{
return debug_flag;
}
|
.debug=(value) ⇒ Object
:nodoc:
1529 1530 1531 1532 1533 1534 |
# File 'ext/ruby_debug/ruby_debug.c', line 1529
static VALUE
debug_set_debug(VALUE self, VALUE value)
{
debug_flag = RTEST(value) ? Qtrue : Qfalse;
return value;
}
|
.debug_at_exit { ... } ⇒ Proc
Register at_exit
hook which is escaped from the debugger. FOR INTERNAL USE ONLY.
1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 |
# File 'ext/ruby_debug/ruby_debug.c', line 1666
static VALUE
debug_at_exit(VALUE self)
{
VALUE proc;
if (!rb_block_given_p())
rb_raise(rb_eArgError, "called without a block");
proc = rb_block_proc();
rb_set_end_proc(debug_at_exit_i, proc);
return proc;
}
|
.debug_load(file, stop = false, increment_start = false) ⇒ nil
Same as Kernel#load but resets current context’s frames. stop
parameter forces the debugger to stop at the first line of code in the file
increment_start
determines if start_count should be incremented. When
control threads are used, they have to be set up before loading the
debugger; so here +increment_start+ will be false.
FOR INTERNAL USE ONLY.
1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 |
# File 'ext/ruby_debug/ruby_debug.c', line 1577
static VALUE
debug_debug_load(int argc, VALUE *argv, VALUE self)
{
VALUE file, stop, context, increment_start;
debug_context_t *debug_context;
int state = 0;
if(rb_scan_args(argc, argv, "12", &file, &stop, &increment_start) == 1)
{
stop = Qfalse;
increment_start = Qtrue;
}
context = debug_current_context(self);
Data_Get_Struct(context, debug_context_t, debug_context);
debug_context->start_cfp = NULL;
debug_context->top_cfp = GET_THREAD()->cfp;
if(RTEST(stop))
debug_context->stop_next = 1;
/* Initializing $0 to the script's path */
ruby_script(RSTRING_PTR(file));
rb_load_protect(file, 0, &state);
if (0 != state)
{
VALUE errinfo = rb_errinfo();
debug_suspend(self);
reset_stepping_stop_points(debug_context);
rb_set_errinfo(Qnil);
return errinfo;
}
/* 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 Qnil;
}
|
.last_interrupted ⇒ Object
Returns last debugged context.
1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 |
# File 'ext/ruby_debug/ruby_debug.c', line 1355
static VALUE
debug_last_interrupted(VALUE self)
{
VALUE result = Qnil;
threads_table_t *threads_table;
Data_Get_Struct(rdebug_threads_tbl, threads_table_t, threads_table);
st_foreach(threads_table->tbl, find_last_context_func, (st_data_t)&result);
return result;
}
|
.remove_breakpoint(id) ⇒ Object
Removes breakpoint by its id. id is an identificator of a breakpoint.
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 |
# File 'ext/ruby_debug/breakpoint.c', line 204
VALUE
rdebug_remove_breakpoint(VALUE self, VALUE id_value)
{
int i;
int id;
VALUE breakpoint;
debug_breakpoint_t *debug_breakpoint;
id = FIX2INT(id_value);
for( i = 0; i < RARRAY_LEN(rdebug_breakpoints); i += 1 )
{
breakpoint = rb_ary_entry(rdebug_breakpoints, i);
Data_Get_Struct(breakpoint, debug_breakpoint_t, debug_breakpoint);
if(debug_breakpoint->id == id)
{
rb_ary_delete_at(rdebug_breakpoints, i);
return breakpoint;
}
}
return Qnil;
}
|
.resume ⇒ Debugger
Resumes all contexts.
1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 |
# File 'ext/ruby_debug/ruby_debug.c', line 1471
static VALUE
debug_resume(VALUE self)
{
VALUE current, context;
VALUE context_list;
debug_context_t *debug_context;
int i;
context_list = debug_contexts(self);
thread_context_lookup(rb_thread_current(), ¤t, NULL, 1);
for(i = 0; i < RARRAY_LEN(context_list); i++)
{
context = rb_ary_entry(context_list, i);
if(current == context)
continue;
Data_Get_Struct(context, debug_context_t, debug_context);
context_resume_0(debug_context);
}
rb_thread_schedule();
return self;
}
|
.skip { ... } ⇒ Object?
The code inside of the block is escaped from the debugger.
1636 1637 1638 1639 1640 1641 1642 1643 1644 |
# File 'ext/ruby_debug/ruby_debug.c', line 1636
static VALUE
debug_skip(VALUE self)
{
if (!rb_block_given_p()) {
rb_raise(rb_eArgError, "called without a block");
}
set_current_skipped_status(Qtrue);
return rb_ensure(rb_yield, Qnil, set_current_skipped_status, Qfalse);
}
|
.skip_next_exception ⇒ Object
:nodoc:
1552 1553 1554 1555 1556 1557 |
# File 'ext/ruby_debug/ruby_debug.c', line 1552
static VALUE
debug_skip_next_exception(VALUE self)
{
skip_next_exception = Qtrue;
return(Qtrue);
}
|
.start_ ⇒ Boolean .start_ { ... } ⇒ Boolean
Deprecated.
1312 1313 1314 1315 1316 1317 |
# File 'ext/ruby_debug/ruby_debug.c', line 1312
static VALUE
debug_start(VALUE self)
{
hook_off = Qfalse;
return(Qtrue);
}
|
.started? ⇒ Boolean
Returns true
the debugger is started. Deprecated.
548 549 550 551 552 |
# File 'ext/ruby_debug/ruby_debug.c', line 548
static VALUE
debug_is_started(VALUE self)
{
return Qtrue;
}
|
.stop ⇒ Boolean
Deprecated.
1325 1326 1327 1328 1329 1330 |
# File 'ext/ruby_debug/ruby_debug.c', line 1325
static VALUE
debug_stop(VALUE self)
{
hook_off = Qtrue;
return Qtrue;
}
|
.suspend ⇒ Debugger
Suspends all contexts.
1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 |
# File 'ext/ruby_debug/ruby_debug.c', line 1442
static VALUE
debug_suspend(VALUE self)
{
VALUE current, context;
VALUE context_list;
debug_context_t *debug_context;
int i;
context_list = debug_contexts(self);
thread_context_lookup(rb_thread_current(), ¤t, NULL, 1);
for(i = 0; i < RARRAY_LEN(context_list); i++)
{
context = rb_ary_entry(context_list, i);
if(current == context)
continue;
Data_Get_Struct(context, debug_context_t, debug_context);
context_suspend_0(debug_context);
}
return self;
}
|
.thread_context(thread) ⇒ Object
Returns context of the thread passed as an argument.
1391 1392 1393 1394 1395 1396 1397 1398 |
# File 'ext/ruby_debug/ruby_debug.c', line 1391
static VALUE
debug_thread_context(VALUE self, VALUE thread)
{
VALUE context;
thread_context_lookup(thread, &context, NULL, 1);
return context;
}
|
.tracing ⇒ Boolean
Returns true
if the global tracing is activated.
1502 1503 1504 1505 1506 |
# File 'ext/ruby_debug/ruby_debug.c', line 1502
static VALUE
debug_tracing(VALUE self)
{
return tracing;
}
|
.tracing=(bool) ⇒ Object
Sets the global tracing flag.
1514 1515 1516 1517 1518 1519 |
# File 'ext/ruby_debug/ruby_debug.c', line 1514
static VALUE
debug_set_tracing(VALUE self, VALUE value)
{
tracing = RTEST(value) ? Qtrue : Qfalse;
return value;
}
|