42 #define MAX_EVENT_NUM 32 69 ruby_event_flag_count[i]++;
85 ruby_event_flag_count[i]--;
117 recalc_add_ruby_vm_event_flags(hook->
events);
138 connect_event_hook(&
GET_VM()->event_hooks, hook);
144 rb_threadptr_add_event_hook(rb_thread_ptr(thval), func, events, data, hook_flags);
150 rb_event_hook_t *hook = alloc_event_hook(func, events, data, hook_flags);
151 connect_event_hook(&
GET_VM()->event_hooks, hook);
184 return rb_threadptr_remove_event_hook(rb_thread_ptr(thval), func,
Qundef);
190 return rb_threadptr_remove_event_hook(rb_thread_ptr(thval), func, data);
196 return remove_event_hook(&
GET_VM()->event_hooks, func,
Qundef);
202 return remove_event_hook(&
GET_VM()->event_hooks, func, data);
212 rb_threadptr_remove_event_hook(th, 0,
Qundef);
227 while ((hook = *nextp) != 0) {
230 recalc_remove_ruby_vm_event_flags(hook->
events);
245 for (hook = list->
hooks; hook; hook = hook->
next) {
272 if (exec_hooks_precheck(th, list, trace_arg) == 0)
return;
273 exec_hooks_body(th, list, trace_arg);
282 if (exec_hooks_precheck(th, list, trace_arg) == 0)
return 0;
290 exec_hooks_body(th, list, trace_arg);
302 rb_threadptr_exec_event_hooks_orig(
rb_trace_arg_t *trace_arg,
int pop_p)
314 exec_hooks_unprotected(th, &th->
event_hooks, trace_arg);
334 state = exec_hooks_protected(th, &th->
event_hooks, trace_arg);
335 if (state)
goto terminate;
338 state = exec_hooks_protected(th, &th->
vm->
event_hooks, trace_arg);
339 if (state)
goto terminate;
352 if (VM_FRAME_FINISHED_P(th->
ec.
cfp)) {
366 rb_threadptr_exec_event_hooks_orig(trace_arg, 1);
372 rb_threadptr_exec_event_hooks_orig(trace_arg, 0);
384 dummy_trace_arg.
event = 0;
393 result = (*func)(arg);
405 #if defined RUBY_USE_SETJMPEX && RUBY_USE_SETJMPEX 515 thread_add_trace_func_m(
VALUE obj,
VALUE trace)
517 thread_add_trace_func(rb_thread_ptr(obj), trace);
533 thread_set_trace_func_m(
VALUE target_thread,
VALUE trace)
535 rb_thread_t *target_th = rb_thread_ptr(target_thread);
537 rb_threadptr_remove_event_hook(target_th, call_trace_func,
Qundef);
543 thread_add_trace_func(target_th, trace);
571 #define C(name, NAME) case RUBY_EVENT_##NAME: CONST_ID(id, #name); return id; 578 C(c_return, C_RETURN);
581 C(b_return, B_RETURN);
582 C(thread_begin, THREAD_BEGIN);
583 C(thread_end, THREAD_END);
584 C(fiber_switch, FIBER_SWITCH);
585 C(specified_line, SPECIFIED_LINE);
609 klass =
RBASIC(klass)->klass;
621 argv[5] = klass ? klass :
Qnil;
628 static VALUE rb_cTracePoint;
649 tp_memsize(
const void *ptr)
661 tp_alloc(
VALUE klass)
668 symbol2event_flag(
VALUE v)
677 #define C(name, NAME) CONST_ID(id, #name); if (sym == ID2SYM(id)) return RUBY_EVENT_##NAME 684 C(c_return, C_RETURN);
687 C(b_return, B_RETURN);
688 C(thread_begin, THREAD_BEGIN);
689 C(thread_end, THREAD_END);
690 C(fiber_switch, FIBER_SWITCH);
691 C(specified_line, SPECIFIED_LINE);
693 C(a_return, A_RETURN);
710 if (trace_arg == 0) {
719 return get_trace_arg();
725 return trace_arg->
event;
754 fill_path_and_lineno(trace_arg);
760 fill_path_and_lineno(trace_arg);
761 return trace_arg->
path;
768 if (!trace_arg->
klass) {
772 if (trace_arg->
klass) {
788 fill_id_and_klass(trace_arg);
795 fill_id_and_klass(trace_arg);
802 fill_id_and_klass(trace_arg);
803 return trace_arg->
klass;
823 return trace_arg->
self;
836 rb_bug(
"tp_attr_return_value_m: unreachable");
838 return trace_arg->
data;
851 rb_bug(
"tp_attr_raised_exception_m: unreachable");
853 return trace_arg->
data;
866 rb_bug(
"tp_attr_raised_exception_m: unreachable");
868 return trace_arg->
data;
877 tracepoint_attr_event(
VALUE tpval)
886 tracepoint_attr_lineno(
VALUE tpval)
895 tracepoint_attr_path(
VALUE tpval)
904 tracepoint_attr_method_id(
VALUE tpval)
913 tracepoint_attr_callee_id(
VALUE tpval)
953 tracepoint_attr_defined_class(
VALUE tpval)
962 tracepoint_attr_binding(
VALUE tpval)
974 tracepoint_attr_self(
VALUE tpval)
983 tracepoint_attr_return_value(
VALUE tpval)
992 tracepoint_attr_raised_exception(
VALUE tpval)
1084 tracepoint_enable_m(
VALUE tpval)
1087 int previous_tracing = tp->
tracing;
1135 tracepoint_disable_m(
VALUE tpval)
1138 int previous_tracing = tp->
tracing;
1167 VALUE tpval = tp_alloc(klass);
1215 if (
RTEST(target_thval)) {
1216 target_th = rb_thread_ptr(target_thval);
1221 return tracepoint_new(rb_cTracePoint, target_th, events,
func, data,
Qundef);
1278 for (i=0; i<
argc; i++) {
1279 events |= symbol2event_flag(argv[i]);
1290 return tracepoint_new(
self, 0, events, 0, 0,
rb_block_proc());
1294 tracepoint_trace_s(
int argc,
VALUE *argv,
VALUE self)
1296 VALUE trace = tracepoint_new_s(argc, argv,
self);
1310 tracepoint_inspect(
VALUE self)
1316 switch (trace_arg->
event) {
1340 return rb_sprintf(
"#<TracePoint:%"PRIsVALUE
" %"PRIsVALUE
">",
1345 return rb_sprintf(
"#<TracePoint:%"PRIsVALUE
"@%"PRIsVALUE
":%d>",
1359 int active = 0, deleted = 0;
1387 tracepoint_stat_s(
VALUE self)
1398 static void Init_postponed_job(
void);
1484 rb_define_method(rb_cTracePoint,
"method_id", tracepoint_attr_method_id, 0);
1485 rb_define_method(rb_cTracePoint,
"callee_id", tracepoint_attr_callee_id, 0);
1486 rb_define_method(rb_cTracePoint,
"defined_class", tracepoint_attr_defined_class, 0);
1489 rb_define_method(rb_cTracePoint,
"return_value", tracepoint_attr_return_value, 0);
1490 rb_define_method(rb_cTracePoint,
"raised_exception", tracepoint_attr_raised_exception, 0);
1496 Init_postponed_job();
1506 #define MAX_POSTPONED_JOB 1000 1507 #define MAX_POSTPONED_JOB_SPECIAL_ADDITION 24 1510 Init_postponed_job(
void)
1529 if (expected_index >= max)
return PJRR_FULL;
1538 pjob->
flags = flags;
1561 default:
rb_bug(
"unreachable\n");
1576 for (i=0; i<index; i++) {
1578 if (pjob->
func == func) {
1587 default:
rb_bug(
"unreachable\n");
#define RUBY_EVENT_B_RETURN
rb_control_frame_t * rb_vm_get_ruby_level_next_cfp(const rb_thread_t *th, const rb_control_frame_t *cfp)
#define RUBY_EVENT_THREAD_END
VALUE rb_tracearg_lineno(rb_trace_arg_t *trace_arg)
void rb_bug(const char *fmt,...)
#define RUBY_EVENT_C_RETURN
VALUE rb_proc_call_with_block(VALUE, int argc, const VALUE *argv, VALUE)
#define RUBY_TYPED_FREE_IMMEDIATELY
int rb_vm_get_sourceline(const rb_control_frame_t *cfp)
#define RUBY_EVENT_RETURN
struct rb_trace_arg_struct * trace_arg
void rb_undef_alloc_func(VALUE)
void rb_define_singleton_method(VALUE obj, const char *name, VALUE(*func)(ANYARGS), int argc)
Defines a singleton method for obj.
int rb_block_given_p(void)
Determines if the current method is given a block.
VALUE local_storage_recursive_hash_for_trace
void rb_raise(VALUE exc, const char *fmt,...)
VALUE rb_tracearg_object(rb_trace_arg_t *trace_arg)
#define TypedData_Get_Struct(obj, type, data_type, sval)
VALUE rb_tracearg_return_value(rb_trace_arg_t *trace_arg)
#define TH_JUMP_TAG(th, st)
void rb_threadptr_exec_event_hooks(rb_trace_arg_t *trace_arg)
VALUE rb_ivar_get(VALUE, ID)
VALUE rb_tracearg_path(rb_trace_arg_t *trace_arg)
VALUE rb_tracearg_method_id(rb_trace_arg_t *trace_arg)
void rb_gc_mark(VALUE ptr)
void rb_thread_add_event_hook2(VALUE thval, rb_event_hook_func_t func, rb_event_flag_t events, VALUE data, rb_event_hook_flag_t hook_flags)
void rb_clear_trace_func(void)
void rb_define_global_function(const char *name, VALUE(*func)(ANYARGS), int argc)
Defines a global function.
VALUE rb_ensure(VALUE(*b_proc)(ANYARGS), VALUE data1, VALUE(*e_proc)(ANYARGS), VALUE data2)
An equivalent to ensure clause.
VALUE rb_tracearg_event(rb_trace_arg_t *trace_arg)
const char * rb_source_loc(int *pline)
int rb_remove_event_hook(rb_event_hook_func_t func)
VALUE rb_tracearg_callee_id(rb_trace_arg_t *trace_arg)
struct rb_tp_struct rb_tp_t
void rb_threadptr_exec_event_hooks_and_pop_frame(rb_trace_arg_t *trace_arg)
void rb_objspace_set_event_hook(const rb_event_flag_t event)
struct rb_trace_arg_struct * rb_tracearg_from_tracepoint(VALUE tpval)
#define RB_TYPE_P(obj, type)
VALUE rb_binding_new(void)
struct rb_thread_struct * th
VALUE rb_tracearg_self(rb_trace_arg_t *trace_arg)
int rb_vm_control_frame_id_and_class(const rb_control_frame_t *cfp, ID *idp, ID *called_idp, VALUE *klassp)
VALUE rb_tracepoint_disable(VALUE tpval)
VALUE default_inspect(VALUE self, const char *class_name)
VALUE rb_hash_aset(VALUE hash, VALUE key, VALUE val)
int rb_threadptr_set_raised(rb_thread_t *th)
VALUE rb_convert_type_with_id(VALUE, int, const char *, ID)
struct rb_event_hook_struct * next
RUBY_EXTERN VALUE rb_cObject
VALUE rb_tracearg_raised_exception(rb_trace_arg_t *trace_arg)
VALUE rb_tracepoint_enabled_p(VALUE tpval)
VALUE rb_define_class(const char *name, VALUE super)
Defines a top-level class.
VALUE rb_tracearg_defined_class(rb_trace_arg_t *trace_arg)
void(* rb_event_hook_func_t)(rb_event_flag_t evflag, VALUE data, VALUE self, ID mid, VALUE klass)
rb_event_flag_t rb_tracearg_event_flag(rb_trace_arg_t *trace_arg)
VALUE rb_tracearg_binding(rb_trace_arg_t *trace_arg)
#define RUBY_EVENT_C_CALL
struct rb_event_hook_struct * hooks
#define ATOMIC_CAS(var, oldval, newval)
VALUE local_storage_recursive_hash
rb_hook_list_t event_hooks
void rb_vm_pop_frame(rb_thread_t *th)
rb_event_hook_func_t func
#define RUBY_EVENT_SPECIFIED_LINE
VALUE rb_obj_is_proc(VALUE)
int rb_thread_remove_event_hook_with_data(VALUE thval, rb_event_hook_func_t func, VALUE data)
VALUE rb_sprintf(const char *format,...)
int rb_thread_remove_event_hook(VALUE thval, rb_event_hook_func_t func)
VALUE rb_vm_make_binding(rb_thread_t *th, const rb_control_frame_t *src_cfp)
RUBY_EXTERN VALUE rb_cThread
int rb_threadptr_reset_raised(rb_thread_t *th)
#define RUBY_EVENT_THREAD_BEGIN
#define RUBY_EVENT_TRACEPOINT_ALL
rb_event_hook_flag_t hook_flags
#define RUBY_INTERNAL_EVENT_MASK
#define MAX_POSTPONED_JOB
int rb_postponed_job_register_one(unsigned int flags, rb_postponed_job_func_t func, void *data)
VALUE rb_mRubyVMFrozenCore
int rb_postponed_job_register(unsigned int flags, rb_postponed_job_func_t func, void *data)
struct rb_event_hook_struct rb_event_hook_t
#define RUBY_TYPED_NEVER_FREE
unsigned long interrupt_mask
VALUE rb_block_proc(void)
#define RUBY_INTERNAL_EVENT_NEWOBJ
#define RUBY_INTERNAL_EVENT_FREEOBJ
VALUE rb_tracepoint_enable(VALUE tpval)
rb_hook_list_t event_hooks
void rb_thread_add_event_hook(VALUE thval, rb_event_hook_func_t func, rb_event_flag_t events, VALUE data)
VALUE rb_suppress_tracing(VALUE(*func)(VALUE), VALUE arg)
rb_event_flag_t ruby_vm_event_flags
struct rb_encoding_entry * list
rb_postponed_job_func_t func
#define TypedData_Make_Struct(klass, type, data_type, sval)
VALUE rb_iseq_path(const rb_iseq_t *iseq)
void rb_vm_trace_mark_event_hooks(rb_hook_list_t *hooks)
VALUE rb_tracepoint_new(VALUE target_thval, rb_event_flag_t events, void(*func)(VALUE, void *), void *data)
struct rb_postponed_job_struct rb_postponed_job_t
rb_execution_context_t ec
void rb_postponed_job_flush(rb_vm_t *vm)
postponed_job_register_result
#define MAX_POSTPONED_JOB_SPECIAL_ADDITION
struct list_head living_threads
void rb_add_event_hook2(rb_event_hook_func_t func, rb_event_flag_t events, VALUE data, rb_event_hook_flag_t hook_flags)
#define CONST_ID(var, str)
struct rb_postponed_job_struct * postponed_job_buffer
int rb_thread_method_id_and_class(rb_thread_t *th, ID *idp, ID *called_idp, VALUE *klassp)
void(* rb_postponed_job_func_t)(void *arg)
#define RUBY_VM_SET_POSTPONED_JOB_INTERRUPT(th)
int rb_remove_event_hook_with_data(rb_event_hook_func_t func, VALUE data)
void(* rb_event_hook_raw_arg_func_t)(VALUE data, const rb_trace_arg_t *arg)
void rb_define_method(VALUE klass, const char *name, VALUE(*func)(ANYARGS), int argc)
rb_control_frame_t * rb_vm_get_binding_creatable_next_cfp(const rb_thread_t *th, const rb_control_frame_t *cfp)
#define RUBY_EVENT_B_CALL
void(* func)(VALUE tpval, void *data)
void rb_add_event_hook(rb_event_hook_func_t func, rb_event_flag_t events, VALUE data)