20static VALUE rb_cBacktrace;
21static VALUE rb_cBacktraceLocation;
30#define rb_id2str(id) id2str(id)
56#if VMDEBUG && defined(HAVE_BUILTIN___BUILTIN_TRAP)
114location_mark(
void *
ptr)
124 case LOCATION_TYPE_ISEQ:
125 case LOCATION_TYPE_ISEQ_CALCED:
128 case LOCATION_TYPE_CFUNC:
129 case LOCATION_TYPE_IFUNC:
136location_memsize(
const void *
ptr)
149location_ptr(
VALUE locobj)
160 case LOCATION_TYPE_ISEQ:
161 loc->
type = LOCATION_TYPE_ISEQ_CALCED;
163 case LOCATION_TYPE_ISEQ_CALCED:
165 case LOCATION_TYPE_CFUNC:
171 rb_bug(
"location_lineno: unreachable");
185location_lineno_m(
VALUE self)
187 return INT2FIX(location_lineno(location_ptr(
self)));
194 case LOCATION_TYPE_ISEQ:
195 case LOCATION_TYPE_ISEQ_CALCED:
197 case LOCATION_TYPE_CFUNC:
199 case LOCATION_TYPE_IFUNC:
201 rb_bug(
"location_label: unreachable");
234location_label_m(
VALUE self)
236 return location_label(location_ptr(
self));
243 case LOCATION_TYPE_ISEQ:
244 case LOCATION_TYPE_ISEQ_CALCED:
246 case LOCATION_TYPE_CFUNC:
248 case LOCATION_TYPE_IFUNC:
250 rb_bug(
"location_base_label: unreachable");
261location_base_label_m(
VALUE self)
263 return location_base_label(location_ptr(
self));
270 case LOCATION_TYPE_ISEQ:
271 case LOCATION_TYPE_ISEQ_CALCED:
273 case LOCATION_TYPE_CFUNC:
278 case LOCATION_TYPE_IFUNC:
280 rb_bug(
"location_path: unreachable");
294location_path_m(
VALUE self)
296 return location_path(location_ptr(
self));
303 case LOCATION_TYPE_ISEQ:
304 case LOCATION_TYPE_ISEQ_CALCED:
306 case LOCATION_TYPE_CFUNC:
311 case LOCATION_TYPE_IFUNC:
313 rb_bug(
"location_realpath: unreachable");
324location_absolute_path_m(
VALUE self)
326 return location_realpath(location_ptr(
self));
353 case LOCATION_TYPE_ISEQ:
358 loc->
type = LOCATION_TYPE_ISEQ_CALCED;
360 case LOCATION_TYPE_ISEQ_CALCED:
365 case LOCATION_TYPE_CFUNC:
371 file =
GET_VM()->progname;
376 case LOCATION_TYPE_IFUNC:
378 rb_bug(
"location_to_str: unreachable");
381 return location_format(file, lineno,
name);
388location_to_str_m(
VALUE self)
390 return location_to_str(location_ptr(
self));
398location_inspect_m(
VALUE self)
412backtrace_mark(
void *
ptr)
417 for (
i=0;
i<s;
i++) {
425backtrace_free(
void *
ptr)
433backtrace_memsize(
const void *
ptr)
441 {backtrace_mark, backtrace_free, backtrace_memsize,},
461 void (*init)(
void *
arg,
size_t size),
472 if (start_cfp ==
NULL) {
491 if (start_cfp < last_cfp) {
495 size = start_cfp - last_cfp + 1;
512 iter_cfunc(
arg,
cfp, mid);
527 arg->btobj = backtrace_alloc(rb_cBacktrace);
530 arg->bt->backtrace_size = 0;
540 loc->
type = LOCATION_TYPE_ISEQ;
551 loc->
type = LOCATION_TYPE_CFUNC;
578 rb_bug(
"backtrace_collect: unreachable");
594 return location_to_str(loc);
598backtrace_to_str_ary(
VALUE self,
long lev,
long n)
614 r = backtrace_collect(
bt, lev,
n, location_to_str_dmyarg, 0);
647 loc->
type = LOCATION_TYPE_ISEQ_CALCED;
664backtrace_to_location_ary(
VALUE self,
long lev,
long n)
680 r = backtrace_collect(bt, lev,
n, location_create, (
void *)
self);
692 bt->
locary = backtrace_to_location_ary(
self, 0, 0);
698backtrace_dump_data(
VALUE self)
735oldbt_init(
void *
ptr,
size_t dmy)
772 fprintf(fp,
"\tfrom %s:%d:in unknown method\n",
776 fprintf(fp,
"\tfrom %s:%d:in `%s'\n",
782vm_backtrace_print(
FILE *fp)
786 arg.func = oldbt_print;
787 arg.data = (
void *)fp;
796oldbt_bugreport(
void *
arg,
VALUE file,
int line,
VALUE method)
801 "----------------------------------------\n");
818 arg.func = oldbt_bugreport;
819 arg.data = (
int *)&
i;
831 vm_backtrace_print(
stderr);
862 arg.func = oldbt_print_to;
894 lev = lev_default + lev_plus;
912 lev = beg + lev_plus;
939 r = backtrace_to_str_ary(btval, lev,
n);
942 r = backtrace_to_location_ary(btval, lev,
n);
956 return ec_backtrace_to_ary(target_th->
ec,
argc,
argv, 0, 0, to_str);
962 return thread_backtrace_to_ary(
argc,
argv, thval, 1);
968 return thread_backtrace_to_ary(
argc,
argv, thval, 0);
1105 rb_define_method(rb_cBacktraceLocation,
"base_label", location_base_label_m, 0);
1107 rb_define_method(rb_cBacktraceLocation,
"absolute_path", location_absolute_path_m, 0);
1142collect_caller_bindings_init(
void *
arg,
size_t size)
1204 collect_caller_bindings_init,
1205 collect_caller_bindings_iseq,
1206 collect_caller_bindings_cfunc,
1216 if (!
NIL_P(cfp_val)) {
1241 dbg_context.
ec = ec;
1242 dbg_context.
cfp = dbg_context.
ec->
cfp;
1245 dbg_context.
contexts = collect_caller_bindings(ec);
1249 result = (*func)(&dbg_context, data);
1315 for (
i=0;
i<limit &&
cfp != end_cfp;) {
1316 if (VM_FRAME_RUBYFRAME_P(
cfp)) {
1342frame2iseq(
VALUE frame)
1364 rb_bug(
"frame2iseq: unreachable");
1403frame2klass(
VALUE frame)
1463 if (method_name !=
Qnil) {
1467 if (classpath !=
Qnil) {
1469 classpath, singleton_p ==
Qtrue ?
"." :
"#", method_name);
1487 if (
NIL_P(qualified_method_name) || base_label == qualified_method_name) {
1493 int prefix_len =
rb_long2int(label_length - base_label_length);
VALUE(* rb_debug_inspector_func_t)(const rb_debug_inspector_t *, void *)
rb_encoding * rb_enc_compatible(VALUE str1, VALUE str2)
char str[HTML_ESCAPE_MAX_LEN+1]
VALUE rb_define_class_under(VALUE, const char *, VALUE)
Defines a class under the namespace of outer.
void rb_undef_method(VALUE, const char *)
VALUE rb_cObject
Object class.
void rb_raise(VALUE exc, const char *fmt,...)
int rb_typeddata_is_kind_of(VALUE obj, const rb_data_type_t *data_type)
void rb_bug(const char *fmt,...)
VALUE rb_obj_class(VALUE)
Equivalent to Object#class in Ruby.
VALUE rb_enc_sprintf(rb_encoding *enc, const char *format,...)
rb_backtrace_location_t * prev_loc
void(* func)(void *data, VALUE file, int lineno, VALUE name)
VALUE(* iter)(VALUE recv, VALUE str)
@ LOCATION_TYPE_ISEQ_CALCED
struct rb_backtrace_location_struct * prev_loc
enum rb_backtrace_location_struct::LOCATION_TYPE type
union rb_backtrace_location_struct::@233 body
struct rb_backtrace_location_struct::@233::@235 cfunc
rb_backtrace_location_t * backtrace
rb_backtrace_location_t * backtrace_base
struct rb_method_definition_struct *const def
const VALUE defined_class
rb_execution_context_t * ec
enum rb_iseq_constant_body::iseq_type type
unsigned int local_table_size
rb_iseq_location_t location
struct rb_iseq_constant_body * body
union rb_method_definition_struct::@41 body
rb_iseq_t * iseqptr
iseq pointer, should be separated from iseqval
rb_execution_context_t * ec
enum rb_thread_status status
rb_backtrace_location_t * loc
int rb_profile_frames(int start, int limit, VALUE *buff, int *lines)
VALUE rb_profile_frame_full_label(VALUE frame)
VALUE rb_debug_inspector_frame_iseq_get(const rb_debug_inspector_t *dc, long index)
void rb_backtrace_each(VALUE(*iter)(VALUE recv, VALUE str), VALUE output)
struct rb_backtrace_location_struct rb_backtrace_location_t
struct rb_backtrace_struct rb_backtrace_t
VALUE rb_profile_frame_method_name(VALUE frame)
VALUE rb_ec_backtrace_str_ary(const rb_execution_context_t *ec, long lev, long n)
VALUE rb_profile_frame_qualified_method_name(VALUE frame)
VALUE rb_profile_frame_label(VALUE frame)
void rb_backtrace_print_as_bugreport(void)
void Init_vm_backtrace(void)
VALUE rb_profile_frame_singleton_method_p(VALUE frame)
VALUE rb_debug_inspector_backtrace_locations(const rb_debug_inspector_t *dc)
int rb_vm_get_sourceline(const rb_control_frame_t *cfp)
VALUE rb_profile_frame_absolute_path(VALUE frame)
VALUE rb_debug_inspector_open(rb_debug_inspector_func_t func, void *data)
int rb_backtrace_p(VALUE obj)
MJIT_FUNC_EXPORTED VALUE rb_ec_backtrace_object(const rb_execution_context_t *ec)
VALUE rb_vm_thread_backtrace(int argc, const VALUE *argv, VALUE thval)
VALUE rb_debug_inspector_frame_self_get(const rb_debug_inspector_t *dc, long index)
MJIT_FUNC_EXPORTED void rb_backtrace_use_iseq_first_lineno_for_last_location(VALUE self)
VALUE rb_backtrace_to_location_ary(VALUE self)
VALUE rb_debug_inspector_frame_binding_get(const rb_debug_inspector_t *dc, long index)
VALUE rb_debug_inspector_frame_class_get(const rb_debug_inspector_t *dc, long index)
VALUE rb_profile_frame_classpath(VALUE frame)
VALUE rb_vm_thread_backtrace_locations(int argc, const VALUE *argv, VALUE thval)
VALUE rb_profile_frame_path(VALUE frame)
VALUE rb_profile_frame_first_lineno(VALUE frame)
VALUE rb_ec_backtrace_location_ary(const rb_execution_context_t *ec, long lev, long n)
VALUE rb_make_backtrace(void)
VALUE rb_backtrace_to_str_ary(VALUE self)
VALUE rb_profile_frame_base_label(VALUE frame)
MJIT_STATIC const rb_callable_method_entry_t * rb_vm_frame_method_entry(const rb_control_frame_t *cfp)