Class: Debugger::Breakpoint

Inherits:
Object
  • Object
show all
Defined in:
lib/debugger/test/breakpoint.rb,
ext/ruby_debug/192/breakpoint.c,
ext/ruby_debug/193/breakpoint.c,
ext/ruby_debug/200/breakpoint.c,
ext/ruby_debug/210/breakpoint.c

Instance Method Summary collapse

Instance Method Details

#enabled=(bool) ⇒ Object

Enables or disables breakpoint.



326
327
328
329
330
331
332
333
# File 'ext/ruby_debug/192/breakpoint.c', line 326

static VALUE
breakpoint_set_enabled(VALUE self, VALUE bool)
{
    debug_breakpoint_t *breakpoint;

    Data_Get_Struct(self, debug_breakpoint_t, breakpoint);
    return breakpoint->enabled = bool;
}

#enabled?Boolean

Returns whether breakpoint is enabled or not.

Returns:

  • (Boolean)


311
312
313
314
315
316
317
318
# File 'ext/ruby_debug/192/breakpoint.c', line 311

static VALUE
breakpoint_enabled(VALUE self)
{
    debug_breakpoint_t *breakpoint;

    Data_Get_Struct(self, debug_breakpoint_t, breakpoint);
    return breakpoint->enabled;
}

#exprString

Returns a codition expression when this breakpoint should be activated.

Returns:

  • (String)


411
412
413
414
415
416
417
418
# File 'ext/ruby_debug/192/breakpoint.c', line 411

static VALUE
breakpoint_expr(VALUE self)
{
    debug_breakpoint_t *breakpoint;

    Data_Get_Struct(self, debug_breakpoint_t, breakpoint);
    return breakpoint->expr;
}

#expr=(string) ⇒ Object

Sets the codition expression when this breakpoint should be activated.



426
427
428
429
430
431
432
433
434
# File 'ext/ruby_debug/192/breakpoint.c', line 426

static VALUE
breakpoint_set_expr(VALUE self, VALUE expr)
{
    debug_breakpoint_t *breakpoint;

    Data_Get_Struct(self, debug_breakpoint_t, breakpoint);
    breakpoint->expr = NIL_P(expr) ? expr: StringValue(expr);
    return expr;
}

#hit_conditionObject

Returns the hit condition of the breakpoint:

nil if it is an unconditional breakpoint, or :greater_or_equal, :equal, :modulo



506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
# File 'ext/ruby_debug/192/breakpoint.c', line 506

static VALUE
breakpoint_hit_condition(VALUE self)
{
    debug_breakpoint_t *breakpoint;

    Data_Get_Struct(self, debug_breakpoint_t, breakpoint);
    switch(breakpoint->hit_condition)
    {
        case HIT_COND_GE:
            return ID2SYM(rb_intern("greater_or_equal"));
        case HIT_COND_EQ:
            return ID2SYM(rb_intern("equal"));
        case HIT_COND_MOD:
            return ID2SYM(rb_intern("modulo"));
        case HIT_COND_NONE:
        default:
            return Qnil;
    }
}

#hit_condition=(symbol) ⇒ Object

Sets the hit condition of the breakpoint which must be one of the following values:

nil if it is an unconditional breakpoint, or :greater_or_equal(:ge), :equal(:eq), :modulo(:mod)



535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
# File 'ext/ruby_debug/192/breakpoint.c', line 535

static VALUE
breakpoint_set_hit_condition(VALUE self, VALUE value)
{
    debug_breakpoint_t *breakpoint;
    ID id_value;

    Data_Get_Struct(self, debug_breakpoint_t, breakpoint);
    id_value = rb_to_id(value);
    
    if(rb_intern("greater_or_equal") == id_value || rb_intern("ge") == id_value)
        breakpoint->hit_condition = HIT_COND_GE;
    else if(rb_intern("equal") == id_value || rb_intern("eq") == id_value)
        breakpoint->hit_condition = HIT_COND_EQ;
    else if(rb_intern("modulo") == id_value || rb_intern("mod") == id_value)
        breakpoint->hit_condition = HIT_COND_MOD;
    else
        rb_raise(rb_eArgError, "Invalid condition parameter");
    return value;
}

#hit_countInteger

Returns the hit count of the breakpoint.

Returns:

  • (Integer)


457
458
459
460
461
462
463
464
# File 'ext/ruby_debug/192/breakpoint.c', line 457

static VALUE
breakpoint_hit_count(VALUE self)
{
    debug_breakpoint_t *breakpoint;

    Data_Get_Struct(self, debug_breakpoint_t, breakpoint);
    return INT2FIX(breakpoint->hit_count);
}

#hit_valueInteger

Returns the hit value of the breakpoint.

Returns:

  • (Integer)


472
473
474
475
476
477
478
479
# File 'ext/ruby_debug/192/breakpoint.c', line 472

static VALUE
breakpoint_hit_value(VALUE self)
{
    debug_breakpoint_t *breakpoint;

    Data_Get_Struct(self, debug_breakpoint_t, breakpoint);
    return INT2FIX(breakpoint->hit_value);
}

#hit_value=(int) ⇒ Object

Sets the hit value of the breakpoint.



487
488
489
490
491
492
493
494
495
# File 'ext/ruby_debug/192/breakpoint.c', line 487

static VALUE
breakpoint_set_hit_value(VALUE self, VALUE value)
{
    debug_breakpoint_t *breakpoint;

    Data_Get_Struct(self, debug_breakpoint_t, breakpoint);
    breakpoint->hit_value = FIX2INT(value);
    return value;
}

#idInteger

Returns id of the breakpoint.

Returns:

  • (Integer)


442
443
444
445
446
447
448
449
# File 'ext/ruby_debug/192/breakpoint.c', line 442

static VALUE
breakpoint_id(VALUE self)
{
    debug_breakpoint_t *breakpoint;

    Data_Get_Struct(self, debug_breakpoint_t, breakpoint);
    return INT2FIX(breakpoint->id);
}

#inspectObject



4
5
6
7
8
9
# File 'lib/debugger/test/breakpoint.rb', line 4

def inspect
  values = %w{id pos source expr hit_condition hit_count hit_value enabled?}.map do |field|
    "#{field}: #{send(field)}"
  end.join(", ")
  "#<Debugger::Breakpoint #{values}>"
end

#posString, Integer

Returns the position of this breakpoint.

Returns:

  • (String, Integer)


372
373
374
375
376
377
378
379
380
381
382
# File 'ext/ruby_debug/192/breakpoint.c', line 372

static VALUE
breakpoint_pos(VALUE self)
{
    debug_breakpoint_t *breakpoint;

    Data_Get_Struct(self, debug_breakpoint_t, breakpoint);
    if(breakpoint->type == BP_METHOD_TYPE)
        return rb_str_new2(rb_id2name(breakpoint->pos.mid));
    else
        return INT2FIX(breakpoint->pos.line);
}

#pos=(string) ⇒ Object

Sets the position of this breakpoint.



390
391
392
393
394
395
396
397
398
399
400
401
402
403
# File 'ext/ruby_debug/192/breakpoint.c', line 390

static VALUE
breakpoint_set_pos(VALUE self, VALUE value)
{
    debug_breakpoint_t *breakpoint;

    Data_Get_Struct(self, debug_breakpoint_t, breakpoint);
    if(breakpoint->type == BP_METHOD_TYPE)
    {
        breakpoint->pos.mid = rb_to_id(StringValue(value));
    }
    else
        breakpoint->pos.line = FIX2INT(value);
    return value;
}

#sourceString

Returns a source of the breakpoint.

Returns:

  • (String)


341
342
343
344
345
346
347
348
# File 'ext/ruby_debug/192/breakpoint.c', line 341

static VALUE
breakpoint_source(VALUE self)
{
    debug_breakpoint_t *breakpoint;

    Data_Get_Struct(self, debug_breakpoint_t, breakpoint);
    return breakpoint->source;
}

#source=(string) ⇒ Object

Sets the source of the breakpoint.



356
357
358
359
360
361
362
363
364
# File 'ext/ruby_debug/192/breakpoint.c', line 356

static VALUE
breakpoint_set_source(VALUE self, VALUE value)
{
    debug_breakpoint_t *breakpoint;

    Data_Get_Struct(self, debug_breakpoint_t, breakpoint);
    breakpoint->source = StringValue(value);
    return value;
}