Module: Byebug

Defined in:
ext/byebug/byebug.c

Defined Under Namespace

Classes: Breakpoint

Class Method Summary collapse

Class Method Details

._startObject



413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
# File 'ext/byebug/byebug.c', line 413

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



553
554
555
556
557
558
559
560
561
# File 'ext/byebug/byebug.c', line 553

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



539
540
541
542
543
# File 'ext/byebug/byebug.c', line 539

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

.catchpointsObject



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

static VALUE
Byebug_catchpoints(VALUE self)
{
  if (catchpoints == Qnil)
    rb_raise(rb_eRuntimeError, "Byebug.start is not called yet.");
  return catchpoints;
}

.contextObject



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

static VALUE
Byebug_context(VALUE self)
{
  if (context == Qnil) {
    context = context_create();
  }
  return context;
}

.debug_at_exitObject



503
504
505
506
507
508
509
510
511
# File 'ext/byebug/byebug.c', line 503

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



447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
# File 'ext/byebug/byebug.c', line 447

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;

  /* Resetting stack size */
  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



532
533
534
535
536
537
# File 'ext/byebug/byebug.c', line 532

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

.post_mortem?Boolean

Returns:

  • (Boolean)


526
527
528
529
530
# File 'ext/byebug/byebug.c', line 526

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

.remove_tracepointsObject



378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
# File 'ext/byebug/byebug.c', line 378

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



336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
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
# File 'ext/byebug/byebug.c', line 336

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

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

  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)


396
397
398
399
400
# File 'ext/byebug/byebug.c', line 396

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

.tracing=(value) ⇒ Object



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

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

.tracing?Boolean

Returns:

  • (Boolean)


513
514
515
516
517
# File 'ext/byebug/byebug.c', line 513

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