Sha256: e2e4ea2eda0e42bdf237c30c49d85acab877c3827af1bb81531a1646286e6943

Contents?: true

Size: 1.03 KB

Versions: 2

Compression:

Stored size: 1.03 KB

Contents

#include "attach.h"

/*
We need to prevent compiler from optimizing this function calls. For more details
see "noinline" section here: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html
*/
static void
__attribute__ ((noinline))
__func_to_set_breakpoint_at()
{
    asm("");
}

static void
__catch_line_event(rb_event_flag_t evflag, VALUE data, VALUE self, ID mid, VALUE klass)
{
    (void)sizeof(evflag);
    (void)sizeof(self);
    (void)sizeof(mid);
    (void)sizeof(klass);

    rb_remove_event_hook(__catch_line_event);
    if (rb_during_gc())
        return;
    __func_to_set_breakpoint_at();
}

int
debase_start_attach()
{
    if (rb_during_gc())
        return 1;
    rb_add_event_hook(__catch_line_event, RUBY_EVENT_LINE, (VALUE) NULL);
    return 0;
}

void
debase_rb_eval(const char *string_to_eval)
{
    rb_eval_string_protect(string_to_eval, NULL);
}

void
Init_attach()
{
  /*
  The only purpose of this library is to be dlopen'ed inside
  gdb/lldb. So no initialization here, you should directly
  call functions above.
  */
}

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
debase-0.2.2.beta10 ext/attach/attach.c
debase-0.2.2.beta9 ext/attach/attach.c