Module: Byebug

Defined in:
ext/byebug/byebug.c

Defined Under Namespace

Classes: Breakpoint

Class Method Summary collapse

Class Method Details

._startObject



384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
# File 'ext/byebug/byebug.c', line 384

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



524
525
526
527
528
529
530
531
532
# File 'ext/byebug/byebug.c', line 524

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



510
511
512
513
514
# File 'ext/byebug/byebug.c', line 510

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

.catchpointsObject



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

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

.contextObject



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

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

.debug_at_exitObject



474
475
476
477
478
479
480
481
482
# File 'ext/byebug/byebug.c', line 474

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



418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
# File 'ext/byebug/byebug.c', line 418

static VALUE
Byebug_load(int argc, VALUE *argv, VALUE self)
{
    VALUE file, stop, context_object;
    debug_context_t *context;
    int state = 0;

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

    Byebug_start(self);

    context_object = Byebug_context(self);
    Data_Get_Struct(context_object, debug_context_t, context);
    context->stack_size = 0;
    if (RTEST(stop)) context->steps = 1;

    /* Initializing $0 to the script's path */
    ruby_script(RSTRING_PTR(file));
    rb_load_protect(file, 0, &state);
    if (0 != state)
    {
        VALUE errinfo = rb_errinfo();
        //debug_suspend(self);
        reset_stepping_stop_points(context);
        rb_set_errinfo(Qnil);
        return errinfo;
    }

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

.post_mortem=(value) ⇒ Object



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

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

.post_mortem?Boolean

Returns:

  • (Boolean)


497
498
499
500
501
# File 'ext/byebug/byebug.c', line 497

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

.remove_tracepointsObject



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

static VALUE
Byebug_remove_tracepoints(VALUE self)
{
  context = Qnil;
  breakpoints = Qnil;
  catchpoints = Qnil;

  if (tpLine != Qnil) {
    rb_tracepoint_disable(tpLine);
    tpLine = Qnil;
  }
  if (tpCall != Qnil) {
    rb_tracepoint_disable(tpCall);
    tpCall = Qnil;
  }
  if (tpCCall != Qnil) {
    rb_tracepoint_disable(tpCCall);
    tpCCall = Qnil;
  }
  if (tpReturn != Qnil) {
    rb_tracepoint_disable(tpReturn);
    tpReturn = Qnil;
  }
  if (tpCReturn != Qnil) {
    rb_tracepoint_disable(tpCReturn);
    tpCReturn = Qnil;
  }
  if (tpRaise != Qnil) {
    rb_tracepoint_disable(tpRaise);
    tpRaise = Qnil;
  }
  return Qnil;
}

.setup_tracepointsObject



290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
# File 'ext/byebug/byebug.c', line 290

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)


367
368
369
370
371
# File 'ext/byebug/byebug.c', line 367

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

.tracing=(value) ⇒ Object



490
491
492
493
494
495
# File 'ext/byebug/byebug.c', line 490

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

.tracing?Boolean

Returns:

  • (Boolean)


484
485
486
487
488
# File 'ext/byebug/byebug.c', line 484

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