31 make_unique_str(
st_table *tbl,
const char *str,
long len)
46 strncpy(result, str, len);
55 delete_unique_str(
st_table *tbl,
const char *str)
72 newobj_i(
VALUE tpval,
void *data)
93 delete_unique_str(arg->
str_table, info->path);
94 delete_unique_str(arg->
str_table, info->class_path);
100 info->flags =
RBASIC(obj)->flags;
103 info->path = path_cstr;
106 info->class_path = class_path_cstr;
112 freeobj_i(
VALUE tpval,
void *data)
125 delete_unique_str(arg->
str_table, info->path);
126 delete_unique_str(arg->
str_table, info->class_path);
147 static int tmp_keep_remains;
150 get_traceobj_arg(
void)
152 if (tmp_trace_arg == 0) {
161 return tmp_trace_arg;
171 trace_object_allocations_start(
VALUE self)
200 trace_object_allocations_stop(
VALUE self)
225 trace_object_allocations_clear(
VALUE self)
269 trace_object_allocations(
VALUE self)
271 trace_object_allocations_start(
self);
276 static int object_allocations_reporter_registered = 0;
285 fprintf(out,
"-- %p (%s F: %p, ", (
void *)obj, info->
living ?
"live" :
"dead", (
void *)info->
flags);
287 else fprintf(out,
"C: %p", (
void *)info->
klass);
288 fprintf(out,
"@%s:%lu", info->
path ? info->
path :
"", info->
line);
299 object_allocations_reporter(
FILE *out,
void *ptr)
301 fprintf(out,
"== object_allocations_reporter: START\n");
305 fprintf(out,
"== object_allocations_reporter: END\n");
309 trace_object_allocations_debug_start(
VALUE self)
311 tmp_keep_remains = 1;
312 if (object_allocations_reporter_registered == 0) {
313 object_allocations_reporter_registered = 1;
317 return trace_object_allocations_start(
self);
321 lookup_allocation_info(
VALUE obj)
335 return lookup_allocation_info(obj);
350 if (info && info->
path) {
485 rb_define_module_function(rb_mObjSpace,
"trace_object_allocations_debug_start", trace_object_allocations_debug_start, 0);
int st_get_key(st_table *, st_data_t, st_data_t *)
VALUE rb_ensure(VALUE(*b_proc)(ANYARGS), VALUE data1, VALUE(*e_proc)(ANYARGS), VALUE data2)
An equivalent to ensure clause.
RUBY_SYMBOL_EXPORT_BEGIN typedef unsigned long st_data_t
struct traceobj_arg * prev_traceobj_arg
void Init_object_tracing(VALUE rb_mObjSpace)
rb_trace_arg_t * rb_tracearg_from_tracepoint(VALUE tpval)
void rb_define_module_function(VALUE module, const char *name, VALUE(*func)(ANYARGS), int argc)
Defines a module function for module.
VALUE rb_tracearg_method_id(rb_trace_arg_t *trace_arg)
VALUE rb_tracearg_defined_class(rb_trace_arg_t *trace_arg)
VALUE rb_tracepoint_new(VALUE target_thread_not_supported_yet, rb_event_flag_t events, void(*func)(VALUE, void *), void *data)
VALUE rb_tracearg_lineno(rb_trace_arg_t *trace_arg)
register unsigned int len
void * ruby_xmalloc(size_t size)
struct allocation_info * objspace_lookup_allocation_info(VALUE obj)
VALUE rb_tracearg_object(rb_trace_arg_t *trace_arg)
#define RUBY_INTERNAL_EVENT_NEWOBJ
#define RUBY_INTERNAL_EVENT_FREEOBJ
#define RBASIC_CLASS(obj)
VALUE rb_class_path_cached(VALUE)
VALUE rb_tracearg_path(rb_trace_arg_t *trace_arg)
int rb_bug_reporter_add(void(*func)(FILE *, void *), void *data)
VALUE rb_tracepoint_enable(VALUE tpval)
void st_clear(st_table *)
VALUE rb_define_module(const char *name)
VALUE rb_tracepoint_disable(VALUE tpval)