Ruby  2.0.0p648(2015-12-16revision53162)
Data Structures | Macros | Typedefs | Functions | Variables
vm_trace.c File Reference
#include "ruby/ruby.h"
#include "ruby/debug.h"
#include "ruby/encoding.h"
#include "internal.h"
#include "vm_core.h"
#include "eval_intern.h"
Include dependency graph for vm_trace.c:

Go to the source code of this file.

Data Structures

struct  rb_event_hook_struct
 
struct  rb_tp_struct
 

Macros

#define MAX_EVENT_NUM   32
 
#define C(name, NAME)   case RUBY_EVENT_##NAME: CONST_ID(id, #name); return id;
 
#define C(name, NAME)   CONST_ID(id, #name); if (sym == ID2SYM(id)) return RUBY_EVENT_##NAME
 

Typedefs

typedef struct rb_event_hook_struct rb_event_hook_t
 
typedef void(* rb_event_hook_raw_arg_func_t) (VALUE data, const rb_trace_arg_t *arg)
 
typedef struct rb_tp_struct rb_tp_t
 

Functions

void vm_trace_mark_event_hooks (rb_hook_list_t *hooks)
 
static void recalc_add_ruby_vm_event_flags (rb_event_flag_t events)
 
static void recalc_remove_ruby_vm_event_flags (rb_event_flag_t events)
 
static rb_thread_tthval2thread_t (VALUE thval)
 
static rb_event_hook_talloc_event_hook (rb_event_hook_func_t func, rb_event_flag_t events, VALUE data, rb_event_hook_flag_t hook_flags)
 
static void connect_event_hook (rb_hook_list_t *list, rb_event_hook_t *hook)
 
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)
 
void rb_thread_add_event_hook (VALUE thval, rb_event_hook_func_t func, rb_event_flag_t events, VALUE data)
 
void rb_add_event_hook (rb_event_hook_func_t func, rb_event_flag_t events, VALUE data)
 
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_add_event_hook2 (rb_event_hook_func_t func, rb_event_flag_t events, VALUE data, rb_event_hook_flag_t hook_flags)
 
static int remove_event_hook (rb_hook_list_t *list, rb_event_hook_func_t func, VALUE data)
 
static int rb_threadptr_remove_event_hook (rb_thread_t *th, rb_event_hook_func_t func, VALUE data)
 
int rb_thread_remove_event_hook (VALUE thval, rb_event_hook_func_t func)
 
int rb_thread_remove_event_hook_with_data (VALUE thval, rb_event_hook_func_t func, VALUE data)
 
int rb_remove_event_hook (rb_event_hook_func_t func)
 
int rb_remove_event_hook_with_data (rb_event_hook_func_t func, VALUE data)
 
static int clear_trace_func_i (st_data_t key, st_data_t val, st_data_t flag)
 
void rb_clear_trace_func (void)
 
static void clean_hooks (rb_hook_list_t *list)
 
static int exec_hooks (rb_thread_t *th, rb_hook_list_t *list, const rb_trace_arg_t *trace_arg, int can_clean_hooks)
 
static void rb_threadptr_exec_event_hooks_orig (rb_trace_arg_t *trace_arg, int pop_p)
 
void rb_threadptr_exec_event_hooks_and_pop_frame (rb_trace_arg_t *trace_arg)
 
void rb_threadptr_exec_event_hooks (rb_trace_arg_t *trace_arg)
 
VALUE rb_suppress_tracing (VALUE(*func)(VALUE), VALUE arg)
 
static void call_trace_func (rb_event_flag_t, VALUE data, VALUE self, ID id, VALUE klass)
 
static VALUE set_trace_func (VALUE obj, VALUE trace)
 
static void thread_add_trace_func (rb_thread_t *th, VALUE trace)
 
static VALUE thread_add_trace_func_m (VALUE obj, VALUE trace)
 
static VALUE thread_set_trace_func_m (VALUE obj, VALUE trace)
 
static const char * get_event_name (rb_event_flag_t event)
 
static ID get_event_id (rb_event_flag_t event)
 
static void tp_mark (void *ptr)
 
static void tp_free (void *ptr)
 
static size_t tp_memsize (const void *ptr)
 
static VALUE tp_alloc (VALUE klass)
 
static rb_event_flag_t symbol2event_flag (VALUE v)
 
static rb_tp_ttpptr (VALUE tpval)
 
static rb_trace_arg_tget_trace_arg (void)
 
struct rb_trace_arg_structrb_tracearg_from_tracepoint (VALUE tpval)
 
VALUE rb_tracearg_event (rb_trace_arg_t *trace_arg)
 
static void fill_path_and_lineno (rb_trace_arg_t *trace_arg)
 
VALUE rb_tracearg_lineno (rb_trace_arg_t *trace_arg)
 
VALUE rb_tracearg_path (rb_trace_arg_t *trace_arg)
 
static void fill_id_and_klass (rb_trace_arg_t *trace_arg)
 
VALUE rb_tracearg_method_id (rb_trace_arg_t *trace_arg)
 
VALUE rb_tracearg_defined_class (rb_trace_arg_t *trace_arg)
 
VALUE rb_tracearg_binding (rb_trace_arg_t *trace_arg)
 
VALUE rb_tracearg_self (rb_trace_arg_t *trace_arg)
 
VALUE rb_tracearg_return_value (rb_trace_arg_t *trace_arg)
 
VALUE rb_tracearg_raised_exception (rb_trace_arg_t *trace_arg)
 
static VALUE tracepoint_attr_event (VALUE tpval)
 
static VALUE tracepoint_attr_lineno (VALUE tpval)
 
static VALUE tracepoint_attr_path (VALUE tpval)
 
static VALUE tracepoint_attr_method_id (VALUE tpval)
 
static VALUE tracepoint_attr_defined_class (VALUE tpval)
 
static VALUE tracepoint_attr_binding (VALUE tpval)
 
static VALUE tracepoint_attr_self (VALUE tpval)
 
static VALUE tracepoint_attr_return_value (VALUE tpval)
 
static VALUE tracepoint_attr_raised_exception (VALUE tpval)
 
static void tp_call_trace (VALUE tpval, rb_trace_arg_t *trace_arg)
 
VALUE rb_tracepoint_enable (VALUE tpval)
 
VALUE rb_tracepoint_disable (VALUE tpval)
 
static VALUE tracepoint_enable_m (VALUE tpval)
 
static VALUE tracepoint_disable_m (VALUE tpval)
 
VALUE rb_tracepoint_enabled_p (VALUE tpval)
 
static VALUE tracepoint_new (VALUE klass, rb_thread_t *target_th, rb_event_flag_t events, void(func)(VALUE, void *), void *data, VALUE proc)
 
VALUE rb_tracepoint_new (VALUE target_thval, rb_event_flag_t events, void(*func)(VALUE, void *), void *data)
 
static VALUE tracepoint_new_s (int argc, VALUE *argv, VALUE self)
 
static VALUE tracepoint_trace_s (int argc, VALUE *argv, VALUE self)
 
static VALUE tracepoint_inspect (VALUE self)
 
void Init_vm_trace (void)
 

Variables

static int ruby_event_flag_count [MAX_EVENT_NUM] = {0}
 
static VALUE rb_cTracePoint
 
static const rb_data_type_t tp_data_type
 

Macro Definition Documentation

#define C (   name,
  NAME 
)    case RUBY_EVENT_##NAME: CONST_ID(id, #name); return id;

Referenced by get_event_id(), and symbol2event_flag().

#define C (   name,
  NAME 
)    CONST_ID(id, #name); if (sym == ID2SYM(id)) return RUBY_EVENT_##NAME
#define MAX_EVENT_NUM   32

Definition at line 44 of file vm_trace.c.

Referenced by recalc_add_ruby_vm_event_flags(), and recalc_remove_ruby_vm_event_flags().

Typedef Documentation

typedef void(* rb_event_hook_raw_arg_func_t) (VALUE data, const rb_trace_arg_t *arg)

Definition at line 42 of file vm_trace.c.

typedef struct rb_tp_struct rb_tp_t

Function Documentation

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
static void call_trace_func ( rb_event_flag_t  event,
VALUE  data,
VALUE  self,
ID  id,
VALUE  klass 
)
static
static void clean_hooks ( rb_hook_list_t list)
static
static int clear_trace_func_i ( st_data_t  key,
st_data_t  val,
st_data_t  flag 
)
static

Definition at line 206 of file vm_trace.c.

References GetThreadPtr, Qundef, rb_threadptr_remove_event_hook(), and ST_CONTINUE.

Referenced by rb_clear_trace_func().

static void connect_event_hook ( rb_hook_list_t list,
rb_event_hook_t hook 
)
static
static int exec_hooks ( rb_thread_t th,
rb_hook_list_t list,
const rb_trace_arg_t trace_arg,
int  can_clean_hooks 
)
static
static void fill_id_and_klass ( rb_trace_arg_t trace_arg)
static
static void fill_path_and_lineno ( rb_trace_arg_t trace_arg)
static
static ID get_event_id ( rb_event_flag_t  event)
static

Definition at line 537 of file vm_trace.c.

References C, CALL, CONST_ID, END, id, RETURN, RUBY_EVENT_LINE, and RUBY_EVENT_SPECIFIED_LINE.

Referenced by rb_tracearg_event().

static const char* get_event_name ( rb_event_flag_t  event)
static
static rb_trace_arg_t* get_trace_arg ( void  )
static
void Init_vm_trace ( void  )
void rb_add_event_hook ( rb_event_hook_func_t  func,
rb_event_flag_t  events,
VALUE  data 
)
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 
)

Definition at line 148 of file vm_trace.c.

References alloc_event_hook(), connect_event_hook(), and GET_VM.

Referenced by rb_tracepoint_enable().

void rb_clear_trace_func ( void  )

Definition at line 215 of file vm_trace.c.

References clear_trace_func_i(), GET_VM, rb_remove_event_hook(), and st_foreach().

Referenced by ruby_finalize_0(), and ruby_options().

int rb_remove_event_hook ( rb_event_hook_func_t  func)

Definition at line 194 of file vm_trace.c.

References GET_VM, Qundef, and remove_event_hook().

Referenced by rb_clear_trace_func(), rb_reset_coverages(), and set_trace_func().

int rb_remove_event_hook_with_data ( rb_event_hook_func_t  func,
VALUE  data 
)

Definition at line 200 of file vm_trace.c.

References GET_VM, and remove_event_hook().

Referenced by rb_tracepoint_disable().

VALUE rb_suppress_tracing ( VALUE(*)(VALUE func,
VALUE  arg 
)
void rb_thread_add_event_hook ( VALUE  thval,
rb_event_hook_func_t  func,
rb_event_flag_t  events,
VALUE  data 
)
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 
)

Definition at line 142 of file vm_trace.c.

References rb_threadptr_add_event_hook(), and thval2thread_t().

Referenced by rb_tracepoint_enable().

int rb_thread_remove_event_hook ( VALUE  thval,
rb_event_hook_func_t  func 
)

Definition at line 182 of file vm_trace.c.

References Qundef, rb_threadptr_remove_event_hook(), and thval2thread_t().

int rb_thread_remove_event_hook_with_data ( VALUE  thval,
rb_event_hook_func_t  func,
VALUE  data 
)

Definition at line 188 of file vm_trace.c.

References rb_threadptr_remove_event_hook(), and thval2thread_t().

Referenced by rb_tracepoint_disable().

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
void rb_threadptr_exec_event_hooks ( rb_trace_arg_t trace_arg)

Definition at line 339 of file vm_trace.c.

References rb_threadptr_exec_event_hooks_orig().

void rb_threadptr_exec_event_hooks_and_pop_frame ( rb_trace_arg_t trace_arg)

Definition at line 333 of file vm_trace.c.

References rb_threadptr_exec_event_hooks_orig().

static void rb_threadptr_exec_event_hooks_orig ( rb_trace_arg_t trace_arg,
int  pop_p 
)
static
static int rb_threadptr_remove_event_hook ( rb_thread_t th,
rb_event_hook_func_t  func,
VALUE  data 
)
static
VALUE rb_tracearg_binding ( rb_trace_arg_t trace_arg)
VALUE rb_tracearg_defined_class ( rb_trace_arg_t trace_arg)

Definition at line 757 of file vm_trace.c.

References fill_id_and_klass(), and rb_trace_arg_struct::klass.

Referenced by tracepoint_attr_defined_class().

VALUE rb_tracearg_event ( rb_trace_arg_t trace_arg)

Definition at line 693 of file vm_trace.c.

References rb_trace_arg_struct::event, get_event_id(), and ID2SYM.

Referenced by tracepoint_attr_event(), and tracepoint_inspect().

struct rb_trace_arg_struct* rb_tracearg_from_tracepoint ( VALUE  tpval)

Definition at line 687 of file vm_trace.c.

References get_trace_arg().

VALUE rb_tracearg_lineno ( rb_trace_arg_t trace_arg)
VALUE rb_tracearg_method_id ( rb_trace_arg_t trace_arg)

Definition at line 750 of file vm_trace.c.

References fill_id_and_klass(), rb_trace_arg_struct::id, ID2SYM, and Qnil.

Referenced by tracepoint_attr_method_id(), and tracepoint_inspect().

VALUE rb_tracearg_path ( rb_trace_arg_t trace_arg)

Definition at line 722 of file vm_trace.c.

References fill_path_and_lineno(), and rb_trace_arg_struct::path.

Referenced by tracepoint_attr_path(), and tracepoint_inspect().

VALUE rb_tracearg_raised_exception ( rb_trace_arg_t trace_arg)
VALUE rb_tracearg_return_value ( rb_trace_arg_t trace_arg)
VALUE rb_tracearg_self ( rb_trace_arg_t trace_arg)

Definition at line 778 of file vm_trace.c.

References rb_trace_arg_struct::self.

Referenced by tracepoint_attr_self(), and tracepoint_inspect().

VALUE rb_tracepoint_disable ( VALUE  tpval)
VALUE rb_tracepoint_enable ( VALUE  tpval)
VALUE rb_tracepoint_enabled_p ( VALUE  tpval)

Definition at line 1093 of file vm_trace.c.

References Qfalse, Qtrue, tpptr(), and rb_tp_struct::tracing.

Referenced by Init_vm_trace().

VALUE rb_tracepoint_new ( VALUE  target_thval,
rb_event_flag_t  events,
void(*)(VALUE, void *)  func,
void *  data 
)

Definition at line 1116 of file vm_trace.c.

References func, GetThreadPtr, Qundef, RTEST, and tracepoint_new().

static void recalc_add_ruby_vm_event_flags ( rb_event_flag_t  events)
static

Definition at line 64 of file vm_trace.c.

References i, MAX_EVENT_NUM, ruby_event_flag_count, and ruby_vm_event_flags.

Referenced by connect_event_hook().

static void recalc_remove_ruby_vm_event_flags ( rb_event_flag_t  events)
static

Definition at line 78 of file vm_trace.c.

References i, MAX_EVENT_NUM, ruby_event_flag_count, and ruby_vm_event_flags.

Referenced by clean_hooks().

static int remove_event_hook ( rb_hook_list_t list,
rb_event_hook_func_t  func,
VALUE  data 
)
static
static VALUE set_trace_func ( VALUE  obj,
VALUE  trace 
)
static
static rb_event_flag_t symbol2event_flag ( VALUE  v)
static

Definition at line 645 of file vm_trace.c.

References C, CALL, END, id, rb_convert_type(), rb_eArgError, rb_id2name(), rb_raise(), RETURN, sym, SYM2ID, and T_SYMBOL.

Referenced by tracepoint_new_s().

static void thread_add_trace_func ( rb_thread_t th,
VALUE  trace 
)
static
static VALUE thread_add_trace_func_m ( VALUE  obj,
VALUE  trace 
)
static

Definition at line 482 of file vm_trace.c.

References GetThreadPtr, rb_secure(), and thread_add_trace_func().

Referenced by Init_vm_trace().

static VALUE thread_set_trace_func_m ( VALUE  obj,
VALUE  trace 
)
static
static rb_thread_t* thval2thread_t ( VALUE  thval)
static
static VALUE tp_alloc ( VALUE  klass)
static

Definition at line 638 of file vm_trace.c.

References TypedData_Make_Struct.

Referenced by tracepoint_new().

static void tp_call_trace ( VALUE  tpval,
rb_trace_arg_t trace_arg 
)
static
static void tp_free ( void *  ptr)
static

Definition at line 621 of file vm_trace.c.

static void tp_mark ( void *  ptr)
static
static size_t tp_memsize ( const void *  ptr)
static

Definition at line 627 of file vm_trace.c.

static rb_tp_t* tpptr ( VALUE  tpval)
static
static VALUE tracepoint_attr_binding ( VALUE  tpval)
static

Definition at line 895 of file vm_trace.c.

References get_trace_arg(), and rb_tracearg_binding().

Referenced by Init_vm_trace().

static VALUE tracepoint_attr_defined_class ( VALUE  tpval)
static

Definition at line 886 of file vm_trace.c.

References get_trace_arg(), and rb_tracearg_defined_class().

Referenced by Init_vm_trace().

static VALUE tracepoint_attr_event ( VALUE  tpval)
static

Definition at line 819 of file vm_trace.c.

References get_trace_arg(), and rb_tracearg_event().

Referenced by Init_vm_trace().

static VALUE tracepoint_attr_lineno ( VALUE  tpval)
static

Definition at line 828 of file vm_trace.c.

References get_trace_arg(), and rb_tracearg_lineno().

Referenced by Init_vm_trace().

static VALUE tracepoint_attr_method_id ( VALUE  tpval)
static

Definition at line 846 of file vm_trace.c.

References get_trace_arg(), and rb_tracearg_method_id().

Referenced by Init_vm_trace().

static VALUE tracepoint_attr_path ( VALUE  tpval)
static

Definition at line 837 of file vm_trace.c.

References get_trace_arg(), and rb_tracearg_path().

Referenced by Init_vm_trace().

static VALUE tracepoint_attr_raised_exception ( VALUE  tpval)
static

Definition at line 925 of file vm_trace.c.

References get_trace_arg(), and rb_tracearg_raised_exception().

Referenced by Init_vm_trace().

static VALUE tracepoint_attr_return_value ( VALUE  tpval)
static

Definition at line 916 of file vm_trace.c.

References get_trace_arg(), and rb_tracearg_return_value().

Referenced by Init_vm_trace().

static VALUE tracepoint_attr_self ( VALUE  tpval)
static

Definition at line 907 of file vm_trace.c.

References get_trace_arg(), and rb_tracearg_self().

Referenced by Init_vm_trace().

static VALUE tracepoint_disable_m ( VALUE  tpval)
static
static VALUE tracepoint_enable_m ( VALUE  tpval)
static
static VALUE tracepoint_inspect ( VALUE  self)
static
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
static VALUE tracepoint_new_s ( int  argc,
VALUE argv,
VALUE  self 
)
static
static VALUE tracepoint_trace_s ( int  argc,
VALUE argv,
VALUE  self 
)
static

Definition at line 1198 of file vm_trace.c.

References rb_tracepoint_enable(), and tracepoint_new_s().

Referenced by Init_vm_trace().

void vm_trace_mark_event_hooks ( rb_hook_list_t hooks)

Variable Documentation

VALUE rb_cTracePoint
static

Definition at line 598 of file vm_trace.c.

int ruby_event_flag_count[MAX_EVENT_NUM] = {0}
static

Definition at line 46 of file vm_trace.c.

Referenced by recalc_add_ruby_vm_event_flags(), and recalc_remove_ruby_vm_event_flags().

const rb_data_type_t tp_data_type
static
Initial value:
= {
"tracepoint",
}
static size_t tp_memsize(const void *ptr)
Definition: vm_trace.c:627
static void tp_free(void *ptr)
Definition: vm_trace.c:621
static void tp_mark(void *ptr)
Definition: vm_trace.c:611

Definition at line 632 of file vm_trace.c.