Module: Byebug

Defined in:
ext/byebug/byebug.c

Defined Under Namespace

Classes: Breakpoint

Class Method Summary collapse

Class Method Details

._startObject



428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
# File 'ext/byebug/byebug.c', line 428

static VALUE
Byebug_start(VALUE self)
{
  VALUE result;

  if (BYEBUG_STARTED)
    result = Qfalse;
  else
  {
    Byebug_setup_tracepoints(self);
    result = Qtrue;
  }

  if (rb_block_given_p())
    rb_ensure(rb_yield, self, Byebug_stop, self);

  return result;
}

.add_catchpoint(value) ⇒ Object



566
567
568
569
570
571
572
573
574
# File 'ext/byebug/byebug.c', line 566

static VALUE
Byebug_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(catchpoints, rb_str_dup(value), INT2FIX(0));
  return value;
}

.breakpointsObject



554
555
556
557
558
# File 'ext/byebug/byebug.c', line 554

static VALUE
Byebug_breakpoints(VALUE self)
{
  return breakpoints;
}

.catchpointsObject



560
561
562
563
564
# File 'ext/byebug/byebug.c', line 560

static VALUE
Byebug_catchpoints(VALUE self)
{
  return catchpoints;
}

.contextObject



53
54
55
56
57
# File 'ext/byebug/byebug.c', line 53

static VALUE
Byebug_context(VALUE self)
{
  return context;
}

.debug_at_exitObject



518
519
520
521
522
523
524
525
526
# File 'ext/byebug/byebug.c', line 518

static VALUE
Byebug_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(*args) ⇒ Object



462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
# File 'ext/byebug/byebug.c', line 462

static VALUE
Byebug_load(int argc, VALUE *argv, VALUE self)
{
  VALUE file, stop, context_obj;
  debug_context_t *dc;
  VALUE status = Qnil;
  int state = 0;

  if (rb_scan_args(argc, argv, "11", &file, &stop) == 1)
  {
    stop = Qfalse;
  }

  Byebug_start(self);

  context_obj = Byebug_context(self);
  Data_Get_Struct(context_obj, debug_context_t, dc);
  if (RTEST(stop)) dc->steps = 1;

  /* Reset stack size to ignore byebug's own frames */
  dc->stack_size = 0;

  /* Initializing $0 to the script's path */
  ruby_script(RSTRING_PTR(file));
  rb_load_protect(file, 0, &state);
  if (0 != state)
  {
    status = rb_errinfo();
    reset_stepping_stop_points(dc);
  }

  /* 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 status;
}

.post_mortem=(value) ⇒ Object



547
548
549
550
551
552
# File 'ext/byebug/byebug.c', line 547

static VALUE
Byebug_set_post_mortem(VALUE self, VALUE value)
{
  post_mortem = RTEST(value) ? Qtrue : Qfalse;
  return value;
}

.post_mortem?Boolean

Returns:

  • (Boolean)


541
542
543
544
545
# File 'ext/byebug/byebug.c', line 541

static VALUE
Byebug_post_mortem(VALUE self)
{
  return post_mortem;
}

.remove_tracepointsObject



394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
# File 'ext/byebug/byebug.c', line 394

static VALUE
Byebug_remove_tracepoints(VALUE self)
{
  rb_tracepoint_disable(tpRaise);
  rb_tracepoint_disable(tpCReturn);
  rb_tracepoint_disable(tpReturn);
  rb_tracepoint_disable(tpCCall);
  rb_tracepoint_disable(tpCall);
  rb_tracepoint_disable(tpLine);

  context = Qnil;
  breakpoints = Qnil;
  catchpoints = Qnil;

  return Qnil;
}

.setup_tracepointsObject



351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
# File 'ext/byebug/byebug.c', line 351

static VALUE
Byebug_setup_tracepoints(VALUE self)
{
  if (catchpoints != Qnil) return Qnil;

  breakpoints = rb_ary_new();
  catchpoints = rb_hash_new();
  context = context_create();

  tpLine = rb_tracepoint_new(Qnil,
    RUBY_EVENT_LINE,
    process_line_event, NULL);

  tpCall = rb_tracepoint_new(Qnil,
    RUBY_EVENT_CALL | RUBY_EVENT_B_CALL | RUBY_EVENT_CLASS,
    process_call_event, NULL);

  tpCCall = rb_tracepoint_new(Qnil,
    RUBY_EVENT_C_CALL,
    process_c_call_event, NULL);

  tpReturn = rb_tracepoint_new(Qnil,
    RUBY_EVENT_RETURN | RUBY_EVENT_B_RETURN | RUBY_EVENT_END,
    process_return_event, NULL);

  tpCReturn = rb_tracepoint_new(Qnil,
    RUBY_EVENT_C_RETURN,
    process_c_return_event, NULL);

  tpRaise = rb_tracepoint_new(Qnil,
    RUBY_EVENT_RAISE,
    process_raise_event, NULL);

  rb_tracepoint_enable(tpLine);
  rb_tracepoint_enable(tpCall);
  rb_tracepoint_enable(tpCCall);
  rb_tracepoint_enable(tpReturn);
  rb_tracepoint_enable(tpCReturn);
  rb_tracepoint_enable(tpRaise);

  return Qnil;
}

.started?Boolean

Returns:

  • (Boolean)


411
412
413
414
415
# File 'ext/byebug/byebug.c', line 411

static VALUE
Byebug_started(VALUE self)
{
  return BYEBUG_STARTED;
}

.tracing=(value) ⇒ Object



534
535
536
537
538
539
# File 'ext/byebug/byebug.c', line 534

static VALUE
Byebug_set_tracing(VALUE self, VALUE value)
{
  tracing = RTEST(value) ? Qtrue : Qfalse;
  return value;
}

.tracing?Boolean

Returns:

  • (Boolean)


528
529
530
531
532
# File 'ext/byebug/byebug.c', line 528

static VALUE
Byebug_tracing(VALUE self)
{
  return tracing;
}