42 #define MAX_EVENT_NUM 32 170 if (func == 0 || hook->
func == func) {
235 while ((hook = *nextp) != 0) {
253 for (hook = list->
hooks; hook; hook = hook->
next) {
332 const int outer_state = th->
state;
345 if (state)
goto terminate;
349 if (state)
goto terminate;
369 th->
state = outer_state;
390 volatile int outer_state;
394 const int tracing = th->
trace_arg ? 1 : 0;
396 dummy_trace_arg.
event = 0;
402 outer_state = th->
state;
407 result = (*func)(arg);
422 th->
state = outer_state;
586 #define C(name, NAME) case RUBY_EVENT_##NAME: CONST_ID(id, #name); return id; 593 C(c_return, C_RETURN);
596 C(b_return, B_RETURN);
597 C(thread_begin, THREAD_BEGIN);
598 C(thread_end, THREAD_END);
600 C(specified_line, SPECIFIED_LINE);
624 klass =
RBASIC(klass)->klass;
636 argv[5] = klass ? klass :
Qnil;
692 #define C(name, NAME) CONST_ID(id, #name); if (sym == ID2SYM(id)) return RUBY_EVENT_##NAME 699 C(c_return, C_RETURN);
702 C(b_return, B_RETURN);
703 C(thread_begin, THREAD_BEGIN);
704 C(thread_end, THREAD_END);
706 C(specified_line, SPECIFIED_LINE);
708 C(a_return, A_RETURN);
725 if (trace_arg == 0) {
740 return trace_arg->
event;
776 return trace_arg->
path;
783 if (!trace_arg->
klass) {
787 if (trace_arg->
klass) {
818 return trace_arg->
klass;
838 return trace_arg->
self;
851 rb_bug(
"tp_attr_return_value_m: unreachable");
853 return trace_arg->
data;
866 rb_bug(
"tp_attr_raised_exception_m: unreachable");
868 return trace_arg->
data;
881 rb_bug(
"tp_attr_raised_exception_m: unreachable");
883 return trace_arg->
data;
1102 int previous_tracing = tp->
tracing;
1153 int previous_tracing = tp->
tracing;
1229 if (
RTEST(target_thval)) {
1292 for (i=0; i<
argc; i++) {
1330 switch (trace_arg->
event) {
1354 return rb_sprintf(
"#<TracePoint:%"PRIsVALUE
" %"PRIsVALUE
">",
1359 return rb_sprintf(
"#<TracePoint:%"PRIsVALUE
"@%"PRIsVALUE
":%d>",
1373 int active = 0, deleted = 0;
1520 #define MAX_POSTPONED_JOB 1000 1521 #define MAX_POSTPONED_JOB_SPECIAL_ADDITION 24 1543 if (expected_index >= max)
return PJRR_FULL;
1552 pjob->
flags = flags;
1575 default:
rb_bug(
"unreachable\n");
1590 for (i=0; i<index; i++) {
1592 if (pjob->
func == func) {
1601 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)
#define RUBY_EVENT_C_RETURN
VALUE rb_proc_call_with_block(VALUE, int argc, const VALUE *argv, VALUE)
void rb_bug(const char *fmt,...)
#define RUBY_TYPED_FREE_IMMEDIATELY
int rb_vm_get_sourceline(const rb_control_frame_t *cfp)
#define RUBY_EVENT_RETURN
static int max(int a, int b)
static unsigned int hash(str, len) register const char *str
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.
static VALUE set_trace_func(VALUE obj, VALUE trace)
static int VM_FRAME_FINISHED_P(const rb_control_frame_t *cfp)
VALUE rb_tracearg_object(rb_trace_arg_t *trace_arg)
static VALUE tp_alloc(VALUE klass)
#define TypedData_Get_Struct(obj, type, data_type, sval)
VALUE rb_tracearg_return_value(rb_trace_arg_t *trace_arg)
static VALUE tracepoint_new(VALUE klass, rb_thread_t *target_th, rb_event_flag_t events, void(func)(VALUE, void *), void *data, VALUE proc)
static VALUE tracepoint_attr_path(VALUE tpval)
static void connect_event_hook(rb_hook_list_t *list, rb_event_hook_t *hook)
static VALUE thread_add_trace_func_m(VALUE obj, VALUE trace)
#define TH_JUMP_TAG(th, st)
static void rb_threadptr_exec_event_hooks_orig(rb_trace_arg_t *trace_arg, int pop_p)
static ID get_event_id(rb_event_flag_t event)
struct rb_iseq_constant_body * body
void rb_threadptr_exec_event_hooks(rb_trace_arg_t *trace_arg)
static VALUE fiber_switch(rb_fiber_t *fib, int argc, const VALUE *argv, int is_resume)
static size_t tp_memsize(const void *ptr)
static rb_tp_t * tpptr(VALUE tpval)
void rb_raise(VALUE exc, const char *fmt,...)
VALUE rb_ivar_get(VALUE, ID)
static void tracepoint_stat_event_hooks(VALUE hash, VALUE key, rb_event_hook_t *hook)
static VALUE tracepoint_attr_event(VALUE tpval)
VALUE rb_convert_type(VALUE, int, const char *, const char *)
static VALUE tracepoint_attr_callee_id(VALUE tpval)
VALUE rb_tracearg_path(rb_trace_arg_t *trace_arg)
static void clean_hooks(rb_hook_list_t *list)
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)
static void recalc_remove_ruby_vm_event_flags(rb_event_flag_t events)
VALUE local_storage_recursive_hash_for_trace
void rb_define_global_function(const char *name, VALUE(*func)(ANYARGS), int argc)
Defines a global function.
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)
static const char * get_event_name(rb_event_flag_t event)
VALUE rb_tracearg_callee_id(rb_trace_arg_t *trace_arg)
static void recalc_add_ruby_vm_event_flags(rb_event_flag_t events)
struct rb_tp_struct rb_tp_t
void rb_threadptr_exec_event_hooks_and_pop_frame(rb_trace_arg_t *trace_arg)
static void call_trace_func(rb_event_flag_t, VALUE data, VALUE self, ID id, VALUE klass)
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)
static rb_thread_t * thval2thread_t(VALUE thval)
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)
int rb_block_given_p(void)
static VALUE tracepoint_stat_s(VALUE self)
VALUE rb_hash_aset(VALUE hash, VALUE key, VALUE val)
int rb_threadptr_set_raised(rb_thread_t *th)
struct rb_event_hook_struct * next
RUBY_EXTERN VALUE rb_cObject
static VALUE tracepoint_enable_m(VALUE tpval)
static void rb_threadptr_add_event_hook(rb_thread_t *th, rb_event_hook_func_t func, rb_event_flag_t events, VALUE data, rb_event_hook_flag_t hook_flags)
static VALUE rb_cTracePoint
VALUE rb_tracearg_raised_exception(rb_trace_arg_t *trace_arg)
VALUE rb_tracepoint_enabled_p(VALUE tpval)
static VALUE tracepoint_attr_defined_class(VALUE tpval)
static VALUE thread_set_trace_func_m(VALUE obj, VALUE trace)
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
static void fill_path_and_lineno(rb_trace_arg_t *trace_arg)
#define ATOMIC_CAS(var, oldval, newval)
static int ruby_event_flag_count[MAX_EVENT_NUM]
static rb_event_hook_t * alloc_event_hook(rb_event_hook_func_t func, rb_event_flag_t events, VALUE data, rb_event_hook_flag_t hook_flags)
static VALUE tracepoint_inspect(VALUE self)
static rb_event_flag_t symbol2event_flag(VALUE v)
static void exec_hooks_body(rb_thread_t *th, rb_hook_list_t *list, const rb_trace_arg_t *trace_arg)
static void fill_id_and_klass(rb_trace_arg_t *trace_arg)
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)
static VALUE tracepoint_attr_raised_exception(VALUE tpval)
int rb_thread_remove_event_hook_with_data(VALUE thval, rb_event_hook_func_t func, VALUE data)
VALUE rb_sprintf(const char *format,...)
static int remove_event_hook(rb_hook_list_t *list, rb_event_hook_func_t func, VALUE data)
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)
static VALUE tracepoint_attr_return_value(VALUE tpval)
RUBY_EXTERN VALUE rb_cThread
int rb_threadptr_reset_raised(rb_thread_t *th)
#define RUBY_EVENT_THREAD_BEGIN
VALUE rb_ensure(VALUE(*b_proc)(ANYARGS), VALUE data1, VALUE(*e_proc)(ANYARGS), VALUE data2)
static const rb_data_type_t tp_data_type
#define RUBY_EVENT_TRACEPOINT_ALL
rb_event_hook_flag_t hook_flags
#define RUBY_INTERNAL_EVENT_MASK
static int rb_threadptr_remove_event_hook(rb_thread_t *th, rb_event_hook_func_t func, VALUE data)
static VALUE tracepoint_attr_lineno(VALUE tpval)
#define MAX_POSTPONED_JOB
static VALUE tracepoint_disable_m(VALUE tpval)
int rb_postponed_job_register_one(unsigned int flags, rb_postponed_job_func_t func, void *data)
static rb_trace_arg_t * get_trace_arg(void)
VALUE rb_mRubyVMFrozenCore
static void thread_add_trace_func(rb_thread_t *th, VALUE trace)
int rb_postponed_job_register(unsigned int flags, rb_postponed_job_func_t func, void *data)
static VALUE tracepoint_trace_s(int argc, VALUE *argv, VALUE self)
struct rb_event_hook_struct rb_event_hook_t
static void tp_call_trace(VALUE tpval, rb_trace_arg_t *trace_arg)
#define RUBY_TYPED_NEVER_FREE
static int exec_hooks_precheck(rb_thread_t *th, rb_hook_list_t *list, const rb_trace_arg_t *trace_arg)
unsigned long interrupt_mask
VALUE rb_block_proc(void)
static void tp_mark(void *ptr)
#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)
static VALUE tracepoint_attr_binding(VALUE tpval)
static int exec_hooks_protected(rb_thread_t *th, rb_hook_list_t *list, const rb_trace_arg_t *trace_arg)
static enum postponed_job_register_result postponed_job_register(rb_thread_t *th, rb_vm_t *vm, unsigned int flags, rb_postponed_job_func_t func, void *data, int max, int expected_index)
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)
#define GetThreadPtr(obj, ptr)
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
void rb_postponed_job_flush(rb_vm_t *vm)
static void Init_postponed_job(void)
postponed_job_register_result
#define MAX_POSTPONED_JOB_SPECIAL_ADDITION
VALUE local_storage_recursive_hash
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)
static VALUE tracepoint_attr_self(VALUE tpval)
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)
static VALUE tracepoint_attr_method_id(VALUE tpval)
rb_control_frame_t * rb_vm_get_binding_creatable_next_cfp(const rb_thread_t *th, const rb_control_frame_t *cfp)
static void exec_hooks_unprotected(rb_thread_t *th, rb_hook_list_t *list, const rb_trace_arg_t *trace_arg)
struct rb_trace_arg_struct * trace_arg
#define RUBY_EVENT_B_CALL
void(* func)(VALUE tpval, void *data)
rb_iseq_location_t location
void rb_add_event_hook(rb_event_hook_func_t func, rb_event_flag_t events, VALUE data)
static VALUE tracepoint_new_s(int argc, VALUE *argv, VALUE self)