44 #define MAX_EVENT_NUM 32
70 if (events & (1 << i)) {
84 if (events & (1 << i)) {
162 if (func == 0 || hook->
func == func) {
231 while ((hook = *nextp) != 0) {
262 for (hook = list->
hooks; hook; hook = hook->
next) {
290 const int outer_state = th->
state;
304 if (state)
goto terminate;
310 state =
exec_hooks(th, list, trace_arg, !vm_tracing);
311 if (state)
goto terminate;
328 th->
state = outer_state;
348 volatile int outer_state;
352 const int tracing = th->
trace_arg ? 1 : 0;
359 outer_state = th->
state;
364 result = (*func)(
arg);
379 th->
state = outer_state;
542 #define C(name, NAME) case RUBY_EVENT_##NAME: CONST_ID(id, #name); return id;
549 C(c_return, C_RETURN);
552 C(b_return, B_RETURN);
553 C(thread_begin, THREAD_BEGIN);
554 C(thread_end, THREAD_END);
555 C(specified_line, SPECIFIED_LINE);
579 klass =
RBASIC(klass)->klass;
582 klass =
rb_iv_get(klass,
"__attached__");
591 argv[5] = klass ? klass :
Qnil;
650 #define C(name, NAME) CONST_ID(id, #name); if (sym == ID2SYM(id)) return RUBY_EVENT_##NAME
657 C(c_return, C_RETURN);
660 C(b_return, B_RETURN);
661 C(thread_begin, THREAD_BEGIN);
662 C(thread_end, THREAD_END);
663 C(specified_line, SPECIFIED_LINE);
680 if (trace_arg == 0) {
725 return trace_arg->
path;
732 if (!trace_arg->
klass) {
736 if (trace_arg->
klass) {
760 return trace_arg->
klass;
780 return trace_arg->
self;
793 rb_bug(
"tp_attr_return_value_m: unreachable");
795 return trace_arg->
data;
808 rb_bug(
"tp_attr_raised_exception_m: unreachable");
810 return trace_arg->
data;
1022 int previous_tracing = tp->
tracing;
1073 int previous_tracing = tp->
tracing;
1119 if (
RTEST(target_thval)) {
1182 for (i=0; i<
argc; i++) {
1220 switch (trace_arg->
event) {
1244 return rb_sprintf(
"#<TracePoint:%"PRIsVALUE
" %"PRIsVALUE
">",
1249 return rb_sprintf(
"#<TracePoint:%"PRIsVALUE
"@%"PRIsVALUE
":%d>",
void(* rb_event_hook_func_t)(rb_event_flag_t evflag, VALUE data, VALUE self, ID mid, VALUE klass)
#define RB_TYPE_P(obj, type)
#define RUBY_EVENT_B_RETURN
#define RUBY_EVENT_THREAD_END
VALUE rb_tracearg_lineno(rb_trace_arg_t *trace_arg)
#define RUBY_EVENT_THREAD_BEGIN
void rb_bug(const char *fmt,...)
rb_control_frame_t * rb_vm_get_binding_creatable_next_cfp(rb_thread_t *th, const rb_control_frame_t *cfp)
int rb_vm_get_sourceline(const rb_control_frame_t *cfp)
#define VM_FRAME_TYPE_FINISH_P(cfp)
void rb_define_singleton_method(VALUE obj, const char *name, VALUE(*func)(ANYARGS), int argc)
Defines a singleton method for obj.
#define RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp)
static VALUE set_trace_func(VALUE obj, VALUE trace)
static VALUE tp_alloc(VALUE klass)
#define RUBY_EVENT_C_RETURN
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)
VALUE rb_iv_get(VALUE, const char *)
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)
void rb_threadptr_exec_event_hooks(rb_trace_arg_t *trace_arg)
static size_t tp_memsize(const void *ptr)
static rb_tp_t * tpptr(VALUE tpval)
void rb_raise(VALUE exc, const char *fmt,...)
static VALUE tracepoint_attr_event(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_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)
void rb_define_global_function(const char *name, VALUE(*func)(ANYARGS), int argc)
Defines a global function.
#define RUBY_EVENT_TRACEPOINT_ALL
VALUE rb_tracearg_event(rb_trace_arg_t *trace_arg)
int rb_remove_event_hook(rb_event_hook_func_t func)
static const char * get_event_name(rb_event_flag_t event)
void rb_undef_method(VALUE klass, const char *name)
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 int clear_trace_func_i(st_data_t key, st_data_t val, st_data_t flag)
unsigned long rb_event_flag_t
static void call_trace_func(rb_event_flag_t, VALUE data, VALUE self, ID id, VALUE klass)
struct rb_trace_arg_struct * rb_tracearg_from_tracepoint(VALUE tpval)
int rb_vm_control_frame_id_and_class(const rb_control_frame_t *cfp, ID *idp, VALUE *klassp)
static rb_thread_t * thval2thread_t(VALUE thval)
VALUE rb_binding_new(void)
VALUE rb_tracearg_self(rb_trace_arg_t *trace_arg)
VALUE rb_block_proc(void)
VALUE rb_tracepoint_disable(VALUE tpval)
int rb_thread_method_id_and_class(rb_thread_t *th, ID *idp, VALUE *klassp)
#define TypedData_Get_Struct(obj, type, data_type, sval)
int rb_block_given_p(void)
int rb_threadptr_set_raised(rb_thread_t *th)
rb_control_frame_t * rb_vm_get_ruby_level_next_cfp(rb_thread_t *th, const rb_control_frame_t *cfp)
struct rb_event_hook_struct * next
void(* func)(VALUE tpval, void *data)
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)
static int exec_hooks(rb_thread_t *th, rb_hook_list_t *list, const rb_trace_arg_t *trace_arg, int can_clean_hooks)
VALUE rb_binding_new_with_cfp(rb_thread_t *th, const rb_control_frame_t *src_cfp)
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)
#define RUBY_EVENT_RETURN
VALUE rb_tracearg_binding(rb_trace_arg_t *trace_arg)
struct rb_event_hook_struct * hooks
static void fill_path_and_lineno(rb_trace_arg_t *trace_arg)
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 fill_id_and_klass(rb_trace_arg_t *trace_arg)
rb_hook_list_t event_hooks
rb_event_hook_func_t func
int st_foreach(st_table *, int(*)(ANYARGS), st_data_t)
SSL_METHOD *(* func)(void)
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,...)
void(* rb_event_hook_raw_arg_func_t)(VALUE data, const rb_trace_arg_t *arg)
#define CONST_ID(var, str)
static void tp_free(void *ptr)
static int remove_event_hook(rb_hook_list_t *list, rb_event_hook_func_t func, VALUE data)
VALUE rb_proc_call_with_block(VALUE, int argc, VALUE *argv, VALUE)
int rb_thread_remove_event_hook(VALUE thval, rb_event_hook_func_t func)
static VALUE tracepoint_attr_return_value(VALUE tpval)
int rb_threadptr_reset_raised(rb_thread_t *th)
void rb_undef_alloc_func(VALUE)
rb_iseq_location_t location
VALUE rb_ensure(VALUE(*b_proc)(ANYARGS), VALUE data1, VALUE(*e_proc)(ANYARGS), VALUE data2)
static const rb_data_type_t tp_data_type
rb_event_hook_flag_t hook_flags
static int rb_threadptr_remove_event_hook(rb_thread_t *th, rb_event_hook_func_t func, VALUE data)
VALUE rb_obj_is_proc(VALUE)
static VALUE tracepoint_attr_lineno(VALUE tpval)
static VALUE tracepoint_disable_m(VALUE tpval)
static rb_trace_arg_t * get_trace_arg(void)
VALUE rb_mRubyVMFrozenCore
static void thread_add_trace_func(rb_thread_t *th, VALUE trace)
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)
static void tp_mark(void *ptr)
#define RUBY_EVENT_SPECIFIED_LINE
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)
#define TypedData_Make_Struct(klass, type, data_type, sval)
RUBY_EXTERN VALUE rb_cObject
static VALUE tracepoint_attr_binding(VALUE tpval)
VALUE rb_suppress_tracing(VALUE(*func)(VALUE), VALUE arg)
rb_event_flag_t ruby_vm_event_flags
struct rb_encoding_entry * list
void vm_trace_mark_event_hooks(rb_hook_list_t *hooks)
#define GetThreadPtr(obj, ptr)
VALUE rb_tracepoint_new(VALUE target_thval, rb_event_flag_t events, void(*func)(VALUE, void *), void *data)
const char * rb_id2name(ID id)
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)
int rb_remove_event_hook_with_data(rb_event_hook_func_t func, VALUE data)
static VALUE tracepoint_attr_self(VALUE tpval)
static rb_thread_t * GET_THREAD(void)
void rb_define_method(VALUE klass, const char *name, VALUE(*func)(ANYARGS), int argc)
#define RUBY_EVENT_C_CALL
static VALUE tracepoint_attr_method_id(VALUE tpval)
static VALUE default_inspect(VALUE self, const char *class_name)
VALUE rb_convert_type(VALUE, int, const char *, const char *)
RUBY_EXTERN VALUE rb_cThread
struct rb_trace_arg_struct * trace_arg
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)