Module: Byebug

Defined in:
ext/byebug/byebug.c

Defined Under Namespace

Classes: Breakpoint

Class Method Summary collapse

Class Method Details

._startObject



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

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



550
551
552
553
554
555
556
557
558
# File 'ext/byebug/byebug.c', line 550

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



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

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

.catchpointsObject



544
545
546
547
548
# File 'ext/byebug/byebug.c', line 544

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



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

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



446
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
# File 'ext/byebug/byebug.c', line 446

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



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

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

.post_mortem?Boolean

Returns:

  • (Boolean)


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

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



335
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 335

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)


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

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

.tracing=(value) ⇒ Object



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

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

.tracing?Boolean

Returns:

  • (Boolean)


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

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