Class: Debugger::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-debug.rb,
ext/ruby_debug.c

Defined Under Namespace

Classes: Frame

Instance Method Summary collapse

Instance Method Details

#framesArray

Returns an array of frames.

Returns:

  • (Array)


1472
1473
1474
1475
1476
1477
1478
1479
# File 'ext/ruby_debug.c', line 1472

static VALUE
context_frames(VALUE self)
{
    debug_context_t *debug_context;

    Data_Get_Struct(self, debug_context_t, debug_context);
    return debug_context->frames;
}

#ignoreBoolean

Returns the ignore flag for the current context.

Returns:

  • (Boolean)


1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
# File 'ext/ruby_debug.c', line 1596

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.



1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
# File 'ext/ruby_debug.c', line 1613

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;
}

#interruptObject



17
18
19
# File 'lib/ruby-debug.rb', line 17

def interrupt
  self.stop_next = 1
end

#resumenil

Resumes the thread from the suspended mode.

Returns:

  • (nil)


1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
# File 'ext/ruby_debug.c', line 1537

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.");
    CTX_FL_UNSET(debug_context, CTX_FL_SUSPEND);
    rb_thread_run(context_thread_0(debug_context));
    return Qnil;
}

#step_over(steps) ⇒ Object

Steps over a steps number of times.



1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
# File 'ext/ruby_debug.c', line 1417

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(RARRAY(debug_context->frames)->len == 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 = RARRAY(debug_context->frames)->len;
    }
    else
    {
        if(FIX2INT(frame) < 0 && FIX2INT(frame) >= RARRAY(debug_context->frames)->len)
            rb_raise(rb_eRuntimeError, "Destination frame is out of range.");
        debug_context->dest_frame = FIX2INT(frame);
    }

    return Qnil;
}

#stop_frame(frame) ⇒ Object

Stops when a frame with number frame is activated. Implements up and down commands.



1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
# File 'ext/ruby_debug.c', line 1451

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) >= RARRAY(debug_context->frames)->len)
        rb_raise(rb_eRuntimeError, "Stop frame is out of range.");
    debug_context->stop_frame = FIX2INT(frame);

    return frame;
}

#stop_next=(steps) ⇒ Object

Stops the current context after a number steps are made.



1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
# File 'ext/ruby_debug.c', line 1396

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;
}

#suspendnil

Suspends the thread when it is running.

Returns:

  • (nil)


1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
# File 'ext/ruby_debug.c', line 1517

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.");
    CTX_FL_SET(debug_context, CTX_FL_SUSPEND);
    return Qnil;
}

#thnumInteger

Returns the context’s number.

Returns:

  • (Integer)


1502
1503
1504
1505
1506
1507
1508
1509
# File 'ext/ruby_debug.c', line 1502

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);
}

#threadObject

Returns a thread this context is associated with.



1487
1488
1489
1490
1491
1492
1493
1494
# File 'ext/ruby_debug.c', line 1487

static VALUE
context_thread(VALUE self)
{
    debug_context_t *debug_context;

    Data_Get_Struct(self, debug_context_t, debug_context);
    return context_thread_0(debug_context);
}

#tracingBoolean

Returns the tracing flag for the current context.

Returns:

  • (Boolean)


1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
# File 'ext/ruby_debug.c', line 1558

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.



1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
# File 'ext/ruby_debug.c', line 1575

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;
}