Ruby
2.7.2p137(2020-10-01revision5445e0435260b449decf2ac16f9d09bae3cafe72)
|
Go to the documentation of this file.
20 static VALUE rb_cBacktrace;
21 static VALUE rb_cBacktraceLocation;
30 #define rb_id2str(id) id2str(id)
56 #if VMDEBUG && defined(HAVE_BUILTIN___BUILTIN_TRAP)
114 location_mark(
void *
ptr)
124 case LOCATION_TYPE_ISEQ:
125 case LOCATION_TYPE_ISEQ_CALCED:
128 case LOCATION_TYPE_CFUNC:
129 case LOCATION_TYPE_IFUNC:
136 location_memsize(
const void *
ptr)
149 location_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");
185 location_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");
234 location_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");
261 location_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");
294 location_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");
324 location_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);
388 location_to_str_m(
VALUE self)
390 return location_to_str(location_ptr(
self));
398 location_inspect_m(
VALUE self)
412 backtrace_mark(
void *
ptr)
417 for (
i=0;
i<s;
i++) {
425 backtrace_free(
void *
ptr)
433 backtrace_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);
524 bt_init(
void *
ptr,
size_t size)
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);
598 backtrace_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;
664 backtrace_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);
698 backtrace_dump_data(
VALUE self)
735 oldbt_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",
782 vm_backtrace_print(
FILE *fp)
786 arg.func = oldbt_print;
787 arg.data = (
void *)fp;
796 oldbt_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);
1142 collect_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)) {
1342 frame2iseq(
VALUE frame)
1364 rb_bug(
"frame2iseq: unreachable");
1403 frame2klass(
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_iseq_realpath(const rb_iseq_t *iseq)
#define RUBY_SYMBOL_EXPORT_END
#define TypedData_Make_Struct(klass, type, data_type, sval)
VALUE rb_profile_frame_method_name(VALUE frame)
VALUE rb_backtrace_to_location_ary(VALUE self)
VALUE rb_iseq_label(const rb_iseq_t *iseq)
VALUE rb_iseq_first_lineno(const rb_iseq_t *iseq)
VALUE rb_profile_frame_base_label(VALUE frame)
VALUE rb_make_backtrace(void)
rb_backtrace_location_t * backtrace
VALUE rb_profile_frame_label(VALUE frame)
int rb_backtrace_p(VALUE obj)
void rb_marshal_define_compat(VALUE newclass, VALUE oldclass, VALUE(*dumper)(VALUE), VALUE(*loader)(VALUE, VALUE))
MJIT_FUNC_EXPORTED void rb_backtrace_use_iseq_first_lineno_for_last_location(VALUE self)
VALUE rb_enc_sprintf(rb_encoding *enc, const char *format,...)
void rb_ary_store(VALUE ary, long idx, VALUE val)
#define RB_TYPE_P(obj, type)
struct rb_backtrace_location_struct * prev_loc
void rb_define_global_function(const char *name, VALUE(*func)(ANYARGS), int argc)
Defines a global function.
VALUE rb_iseq_path(const rb_iseq_t *iseq)
#define EC_JUMP_TAG(ec, st)
VALUE rb_profile_frame_classpath(VALUE frame)
rb_iseq_location_t location
#define RUBY_VM_NEXT_CONTROL_FRAME(cfp)
void rb_define_method(VALUE klass, const char *name, VALUE(*func)(ANYARGS), int argc)
void rb_backtrace_each(VALUE(*iter)(VALUE recv, VALUE str), VALUE output)
VALUE rb_ec_backtrace_location_ary(const rb_execution_context_t *ec, long lev, long n)
VALUE rb_str_inspect(VALUE)
rb_iseq_t * iseqptr
iseq pointer, should be separated from iseqval
union rb_backtrace_location_struct::@1 body
VALUE rb_debug_inspector_frame_iseq_get(const rb_debug_inspector_t *dc, long index)
VALUE rb_profile_frame_full_label(VALUE frame)
@ LOCATION_TYPE_ISEQ_CALCED
void rb_print_backtrace(void)
VALUE rb_ec_backtrace_str_ary(const rb_execution_context_t *ec, long lev, long n)
VALUE rb_profile_frame_singleton_method_p(VALUE frame)
rb_execution_context_t * ec
VALUE rb_profile_frame_first_lineno(VALUE frame)
void rb_undef_method(VALUE klass, const char *name)
enum rb_backtrace_location_struct::LOCATION_TYPE type
#define RUBY_TYPED_DEFAULT_FREE
void rb_raise(VALUE exc, const char *fmt,...)
VALUE rb_ary_entry(VALUE ary, long offset)
VALUE rb_debug_inspector_open(rb_debug_inspector_func_t func, void *data)
VALUE rb_ivar_get(VALUE, ID)
VALUE rb_debug_inspector_backtrace_locations(const rb_debug_inspector_t *dc)
VALUE rb_obj_class(VALUE)
Equivalent to Object#class in Ruby.
const VALUE defined_class
VALUE rb_vm_make_binding(const rb_execution_context_t *ec, const rb_control_frame_t *src_cfp)
VALUE rb_iseqw_new(const rb_iseq_t *)
VALUE rb_debug_inspector_frame_self_get(const rb_debug_inspector_t *dc, long index)
unsigned int local_table_size
enum rb_thread_status status
rb_backtrace_location_t * backtrace_base
void rb_backtrace_print_as_bugreport(void)
VALUE rb_debug_inspector_frame_class_get(const rb_debug_inspector_t *dc, long index)
VALUE rb_ary_push(VALUE ary, VALUE item)
VALUE rb_profile_frame_absolute_path(VALUE frame)
struct rb_backtrace_location_struct rb_backtrace_location_t
rb_execution_context_t * ec
enum rb_iseq_constant_body::iseq_type type
VALUE rb_vm_thread_backtrace(int argc, const VALUE *argv, VALUE thval)
MJIT_FUNC_EXPORTED VALUE rb_ec_backtrace_object(const rb_execution_context_t *ec)
rb_encoding * rb_enc_compatible(VALUE str1, VALUE str2)
struct rb_backtrace_location_struct::@1::@3 cfunc
VALUE rb_iseq_base_label(const rb_iseq_t *iseq)
const char * rb_class2name(VALUE)
#define RUBYVM_CFUNC_FRAME_P(cfp)
RUBY_EXTERN VALUE rb_cThread
void Init_vm_backtrace(void)
int rb_typeddata_is_kind_of(VALUE obj, const rb_data_type_t *data_type)
unsigned int rb_iseq_line_no(const rb_iseq_t *iseq, size_t pos)
VALUE rb_profile_frame_path(VALUE frame)
MJIT_STATIC const rb_callable_method_entry_t * rb_vm_frame_method_entry(const rb_control_frame_t *cfp)
RUBY_EXTERN VALUE rb_cObject
void(* func)(void *data, VALUE file, int lineno, VALUE name)
void rb_bug(const char *fmt,...)
VALUE rb_profile_frame_qualified_method_name(VALUE frame)
VALUE rb_debug_inspector_frame_binding_get(const rb_debug_inspector_t *dc, long index)
int rb_profile_frames(int start, int limit, VALUE *buff, int *lines)
#define RUBY_SYMBOL_EXPORT_BEGIN
VALUE rb_sprintf(const char *format,...)
VALUE rb_range_beg_len(VALUE, long *, long *, long, int)
rb_backtrace_location_t * loc
union rb_method_definition_struct::@0 body
char str[HTML_ESCAPE_MAX_LEN+1]
rb_backtrace_location_t * prev_loc
int rb_vm_control_frame_id_and_class(const rb_control_frame_t *cfp, ID *idp, ID *called_idp, VALUE *klassp)
#define RUBY_TYPED_FREE_IMMEDIATELY
VALUE rb_vm_thread_backtrace_locations(int argc, const VALUE *argv, VALUE thval)
void rb_vm_stack_to_heap(rb_execution_context_t *ec)
@ VM_METHOD_TYPE_ISEQ
Ruby method.
void rb_gc_mark(VALUE ptr)
#define MJIT_FUNC_EXPORTED
struct rb_method_definition_struct *const def
VALUE rb_str_catf(VALUE str, const char *format,...)
VALUE rb_class_path(VALUE)
struct rb_iseq_constant_body * body
VALUE rb_define_class_under(VALUE outer, const char *name, VALUE super)
Defines a class under the namespace of outer.
VALUE rb_backtrace_to_str_ary(VALUE self)
struct rb_backtrace_struct rb_backtrace_t
VALUE(* rb_debug_inspector_func_t)(const rb_debug_inspector_t *, void *)
VALUE rb_ary_reverse(VALUE ary)
int rb_vm_get_sourceline(const rb_control_frame_t *cfp)
#define GetCoreDataFromValue(obj, type, ptr)
void rb_undef_alloc_func(VALUE)
VALUE rb_iseq_method_name(const rb_iseq_t *iseq)
#define RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp)
void rb_define_alloc_func(VALUE, rb_alloc_func_t)
#define GC_GUARDED_PTR_REF(p)
#define GC_GUARDED_PTR(p)
VALUE(* iter)(VALUE recv, VALUE str)