Feature #13133 ยป 0001-add-a-tracepoint-for-constant-access.patch
include/ruby/ruby.h | ||
---|---|---|
#define RUBY_EVENT_THREAD_BEGIN 0x0400
|
||
#define RUBY_EVENT_THREAD_END 0x0800
|
||
#define RUBY_EVENT_FIBER_SWITCH 0x1000
|
||
#define RUBY_EVENT_CONSTANT_ACCESS 0x2000
|
||
#define RUBY_EVENT_TRACEPOINT_ALL 0xffff
|
||
/* special events */
|
insns.def | ||
---|---|---|
{
|
||
VM_ASSERT(ic->ic_value.value != Qundef);
|
||
ic->ic_value.value = val;
|
||
EXEC_EVENT_HOOK(GET_THREAD(), RUBY_EVENT_CONSTANT_ACCESS, GET_SELF(), 0, 0, 0, val);
|
||
ic->ic_serial = GET_GLOBAL_CONSTANT_STATE() - ruby_vm_const_missing_count;
|
||
ic->ic_cref = vm_get_const_key_cref(GET_EP());
|
||
ruby_vm_const_missing_count = 0;
|
vm_trace.c | ||
---|---|---|
C(thread_end, THREAD_END);
|
||
C(fiber_switch, FIBER_SWITCH);
|
||
C(specified_line, SPECIFIED_LINE);
|
||
C(constant_access, CONSTANT_ACCESS);
|
||
case RUBY_EVENT_LINE | RUBY_EVENT_SPECIFIED_LINE: CONST_ID(id, "line"); return id;
|
||
#undef C
|
||
default:
|
||
... | ... | |
C(specified_line, SPECIFIED_LINE);
|
||
C(a_call, A_CALL);
|
||
C(a_return, A_RETURN);
|
||
C(constant_access, CONSTANT_ACCESS);
|
||
#undef C
|
||
rb_raise(rb_eArgError, "unknown event: %"PRIsVALUE, rb_sym2str(sym));
|
||
}
|
||
... | ... | |
}
|
||
VALUE
|
||
rb_tracearg_constant_value(rb_trace_arg_t *trace_arg)
|
||
{
|
||
if (trace_arg->event & (RUBY_EVENT_CONSTANT_ACCESS)) {
|
||
/* ok */
|
||
}
|
||
else {
|
||
rb_raise(rb_eRuntimeError, "not supported by this event");
|
||
}
|
||
if (trace_arg->data == Qundef) {
|
||
rb_bug("tp_attr_constant_value_m: unreachable");
|
||
}
|
||
return trace_arg->data;
|
||
}
|
||
VALUE
|
||
rb_tracearg_raised_exception(rb_trace_arg_t *trace_arg)
|
||
{
|
||
if (trace_arg->event & (RUBY_EVENT_RAISE)) {
|
||
... | ... | |
}
|
||
/*
|
||
* Return value from +:constant_access+ event
|
||
*/
|
||
static VALUE
|
||
tracepoint_attr_constant_value(VALUE tpval)
|
||
{
|
||
return rb_tracearg_constant_value(get_trace_arg());
|
||
}
|
||
/*
|
||
* Value from exception raised on the +:raise+ event
|
||
*/
|
||
static VALUE
|
||
... | ... | |
rb_define_method(rb_cTracePoint, "binding", tracepoint_attr_binding, 0);
|
||
rb_define_method(rb_cTracePoint, "self", tracepoint_attr_self, 0);
|
||
rb_define_method(rb_cTracePoint, "return_value", tracepoint_attr_return_value, 0);
|
||
rb_define_method(rb_cTracePoint, "constant_value", tracepoint_attr_constant_value, 0);
|
||
rb_define_method(rb_cTracePoint, "raised_exception", tracepoint_attr_raised_exception, 0);
|
||
rb_define_singleton_method(rb_cTracePoint, "stat", tracepoint_stat_s, 0);
|