12 #include "eval_intern.h"
14 #include "internal/class.h"
15 #include "internal/error.h"
16 #include "internal/vm.h"
22 static VALUE rb_cBacktrace;
23 static VALUE rb_cBacktraceLocation;
29 if (!str)
return Qnil;
32 #define rb_id2str(id) id2str(id)
34 #define BACKTRACE_START 0
35 #define ALL_BACKTRACE_LINES -1
38 calc_pos(
const rb_iseq_t *iseq,
const VALUE *pc,
int *lineno,
int *node_id)
43 if (ISEQ_BODY(iseq)->
type == ISEQ_TYPE_TOP) {
44 VM_ASSERT(! ISEQ_BODY(iseq)->local_table);
45 VM_ASSERT(! ISEQ_BODY(iseq)->local_table_size);
48 if (lineno) *lineno = ISEQ_BODY(iseq)->location.first_lineno;
49 #ifdef USE_ISEQ_NODE_ID
50 if (node_id) *node_id = -1;
55 VM_ASSERT(ISEQ_BODY(iseq));
56 VM_ASSERT(ISEQ_BODY(iseq)->iseq_encoded);
57 VM_ASSERT(ISEQ_BODY(iseq)->iseq_size);
59 ptrdiff_t n = pc - ISEQ_BODY(iseq)->iseq_encoded;
61 #if SIZEOF_PTRDIFF_T > SIZEOF_INT
62 VM_ASSERT(n <= (ptrdiff_t)UINT_MAX);
64 VM_ASSERT((
unsigned int)n <= ISEQ_BODY(iseq)->iseq_size);
71 #if VMDEBUG && defined(HAVE_BUILTIN___BUILTIN_TRAP)
74 rb_print_backtrace(stderr);
78 if (lineno) *lineno = rb_iseq_line_no(iseq, pos);
79 #ifdef USE_ISEQ_NODE_ID
80 if (node_id) *node_id = rb_iseq_node_id(iseq, pos);
90 if (calc_pos(iseq, pc, &lineno, NULL))
return lineno;
94 #ifdef USE_ISEQ_NODE_ID
99 if (calc_pos(iseq, pc, NULL, &node_id))
return node_id;
107 if (VM_FRAME_RUBYFRAME_P(cfp) && cfp->iseq) {
109 int line = calc_lineno(iseq, cfp->pc);
114 return ISEQ_BODY(iseq)->location.first_lineno;
134 location_mark(
void *
ptr)
141 location_ref_update(
void *
ptr)
162 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_EMBEDDABLE
166 rb_frame_info_p(
VALUE obj)
172 location_ptr(
VALUE locobj)
183 return calc_lineno(loc->iseq, loc->pc);
197 location_lineno_m(
VALUE self)
199 return INT2FIX(location_lineno(location_ptr(
self)));
202 VALUE rb_mod_name0(
VALUE klass,
bool *permanent);
209 if (RCLASS_SINGLETON_P(owner)) {
210 VALUE v = RCLASS_ATTACHED_OBJECT(owner);
212 v = rb_mod_name0(v, &permanent);
213 if (permanent && !
NIL_P(v)) {
214 return rb_sprintf(
"%"PRIsVALUE
".%"PRIsVALUE, v, name);
219 owner = rb_mod_name0(owner, &permanent);
220 if (permanent && !
NIL_P(owner)) {
221 return rb_sprintf(
"%"PRIsVALUE
"#%"PRIsVALUE, owner, name);
232 switch (ISEQ_BODY(iseq)->
type) {
234 case ISEQ_TYPE_CLASS:
236 return ISEQ_BODY(iseq)->location.label;
237 case ISEQ_TYPE_METHOD:
238 return rb_gen_method_name(owner, ISEQ_BODY(iseq)->location.label);
239 case ISEQ_TYPE_BLOCK:
240 case ISEQ_TYPE_PLAIN: {
243 if (ISEQ_BODY(orig_iseq)->parent_iseq != 0) {
244 while (ISEQ_BODY(orig_iseq)->local_iseq != iseq) {
245 if (ISEQ_BODY(iseq)->
type == ISEQ_TYPE_BLOCK) {
248 iseq = ISEQ_BODY(iseq)->parent_iseq;
252 return rb_sprintf(
"block in %"PRIsVALUE, calculate_iseq_label(owner, iseq));
255 return rb_sprintf(
"block (%d levels) in %"PRIsVALUE, level, calculate_iseq_label(owner, iseq));
258 case ISEQ_TYPE_RESCUE:
259 case ISEQ_TYPE_ENSURE:
261 iseq = ISEQ_BODY(iseq)->parent_iseq;
264 rb_bug(
"calculate_iseq_label: unreachable");
272 if (!loc->cme)
return false;
274 switch (loc->cme->def->type) {
275 case VM_METHOD_TYPE_CFUNC:
277 case VM_METHOD_TYPE_ISEQ:
278 return rb_iseq_attr_p(loc->cme->def->body.iseq.
iseqptr, BUILTIN_ATTR_C_TRACE);
287 if (location_cfunc_p(loc)) {
288 return rb_gen_method_name(loc->cme->owner,
rb_id2str(loc->cme->def->original_id));
293 owner = loc->cme->owner;
295 return calculate_iseq_label(owner, loc->iseq);
325 location_label_m(
VALUE self)
327 return location_label(location_ptr(
self));
333 if (location_cfunc_p(loc)) {
334 return rb_id2str(loc->cme->def->original_id);
337 return ISEQ_BODY(loc->iseq)->location.base_label;
365 location_base_label_m(
VALUE self)
367 return location_base_label(location_ptr(
self));
387 location_path_m(
VALUE self)
389 const rb_iseq_t *iseq = location_iseq(location_ptr(
self));
390 return iseq ? rb_iseq_path(iseq) :
Qnil;
393 #ifdef USE_ISEQ_NODE_ID
397 if (loc->iseq && loc->pc) {
398 return calc_node_id(loc->iseq, loc->pc);
405 rb_get_node_id_from_frame_info(
VALUE obj)
407 #ifdef USE_ISEQ_NODE_ID
409 return location_node_id(loc);
416 rb_get_iseq_from_frame_info(
VALUE obj)
419 const rb_iseq_t *iseq = location_iseq(loc);
427 return rb_iseq_realpath(loc->iseq);
439 location_absolute_path_m(
VALUE self)
441 return location_realpath(location_ptr(
self));
445 location_format(
VALUE file,
int lineno,
VALUE name)
467 if (location_cfunc_p(loc)) {
468 if (loc->iseq && loc->pc) {
469 file = rb_iseq_path(loc->iseq);
470 lineno = calc_lineno(loc->iseq, loc->pc);
473 file = GET_VM()->progname;
476 name = rb_gen_method_name(loc->cme->owner,
rb_id2str(loc->cme->def->original_id));
479 file = rb_iseq_path(loc->iseq);
480 lineno = calc_lineno(loc->iseq, loc->pc);
482 owner = loc->cme->owner;
484 name = calculate_iseq_label(owner, loc->iseq);
487 return location_format(file, lineno, name);
494 location_to_str_m(
VALUE self)
496 return location_to_str(location_ptr(
self));
504 location_inspect_m(
VALUE self)
517 backtrace_mark(
void *
ptr)
520 size_t i, s = bt->backtrace_size;
522 for (i=0; i<s; i++) {
523 location_mark_entry(&bt->backtrace[i]);
539 backtrace_update(
void *
ptr)
542 size_t i, s = bt->backtrace_size;
544 for (i=0; i<s; i++) {
545 location_update_entry(&bt->backtrace[i]);
562 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED
566 rb_backtrace_p(
VALUE obj)
572 backtrace_alloc(
VALUE klass)
595 if (start_cfp == NULL) {
600 RUBY_VM_NEXT_CONTROL_FRAME(
601 RUBY_VM_NEXT_CONTROL_FRAME(start_cfp));
603 if (start_cfp < last_cfp) {
607 return start_cfp - last_cfp + 1;
613 static const char prefix[] =
"<internal:";
614 const size_t prefix_len =
sizeof(prefix) - 1;
615 VALUE file = rb_iseq_path(cfp->iseq);
616 return strncmp(prefix,
RSTRING_PTR(file), prefix_len) == 0;
622 enum rb_iseq_type
type = ISEQ_BODY(cfp->iseq)->type;
623 return type == ISEQ_TYPE_RESCUE ||
type == ISEQ_TYPE_ENSURE;
629 for (; cfunc_counter > 0; cfunc_counter--, cfunc_loc--) {
630 cfunc_loc->iseq = iseq;
640 for (; num_frames > 0; num_frames--, loc++) {
641 rb_yield(location_create(loc, (
void *)btobj));
646 rb_ec_partial_backtrace_object(
const rb_execution_context_t *ec,
long start_frame,
long num_frames,
int* start_too_large,
bool skip_internal,
bool do_yield)
654 unsigned long cfunc_counter = 0;
655 bool skip_next_frame = FALSE;
658 if (end_cfp == NULL) {
662 end_cfp = RUBY_VM_NEXT_CONTROL_FRAME(end_cfp);
674 size = end_cfp - cfp + 1;
678 else if (num_frames < 0 || num_frames > size) {
683 btobj = backtrace_alloc_capa(num_frames, &bt);
685 bt->backtrace_size = 0;
686 if (num_frames == 0) {
687 if (start_too_large) *start_too_large = 0;
691 for (; cfp != end_cfp && (bt->backtrace_size < num_frames); cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp)) {
694 if (start_frame > 0) {
697 else if (!(skip_internal && is_internal_location(cfp))) {
698 if (!skip_next_frame) {
700 const VALUE *pc = cfp->pc;
701 loc = &bt->backtrace[bt->backtrace_size++];
702 RB_OBJ_WRITE(btobj, &loc->cme, rb_vm_frame_method_entry(cfp));
704 if (rb_iseq_attr_p(cfp->iseq, BUILTIN_ATTR_C_TRACE)) {
712 bt_update_cfunc_loc(cfunc_counter, loc-1, iseq, pc);
714 bt_yield_loc(loc - cfunc_counter, cfunc_counter+1, btobj);
719 skip_next_frame = is_rescue_or_ensure_frame(cfp);
724 VM_ASSERT(RUBYVM_CFUNC_FRAME_P(cfp));
725 if (start_frame > 0) {
729 loc = &bt->backtrace[bt->backtrace_size++];
730 RB_OBJ_WRITE(btobj, &loc->cme, rb_vm_frame_method_entry(cfp));
740 if (cfunc_counter > 0) {
741 for (; cfp != end_cfp; cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp)) {
742 if (cfp->iseq && cfp->pc && !(skip_internal && is_internal_location(cfp))) {
743 VM_ASSERT(!skip_next_frame);
744 bt_update_cfunc_loc(cfunc_counter, loc, cfp->iseq, cfp->pc);
747 bt_yield_loc(loc - cfunc_counter, cfunc_counter, btobj);
754 if (start_too_large) *start_too_large = (start_frame > 0 ? -1 : 0);
761 return rb_ec_partial_backtrace_object(ec, BACKTRACE_START, ALL_BACKTRACE_LINES, NULL, FALSE, FALSE);
772 for (i=0; i<bt->backtrace_size; i++) {
783 return location_to_str(loc);
787 backtrace_to_str_ary(
VALUE self)
792 r = backtrace_collect(bt, location_to_str_dmyarg, 0);
798 rb_backtrace_to_str_ary(
VALUE self)
804 RB_OBJ_WRITE(
self, &bt->strary, backtrace_to_str_ary(
self));
810 rb_backtrace_use_iseq_first_lineno_for_last_location(
VALUE self)
816 VM_ASSERT(bt->backtrace_size > 0);
818 loc = &bt->backtrace[0];
820 VM_ASSERT(!loc->cme || loc->cme->def->type == VM_METHOD_TYPE_ISEQ);
839 backtrace_to_location_ary(
VALUE self)
844 r = backtrace_collect(bt, location_create, (
void *)
self);
850 rb_backtrace_to_location_ary(
VALUE self)
856 RB_OBJ_WRITE(
self, &bt->locary, backtrace_to_location_ary(
self));
862 rb_location_ary_to_backtrace(
VALUE ary)
870 VALUE btobj = backtrace_alloc_capa(num_frames, &new_backtrace);
872 for (
long index = 0; index <
RARRAY_LEN(ary); index++) {
875 if (!rb_frame_info_p(locobj)) {
883 RB_OBJ_WRITE(btobj, &dst_location->cme, src_vloc->loc->cme);
884 RB_OBJ_WRITE(btobj, &dst_location->iseq, src_vloc->loc->iseq);
885 dst_location->pc = src_vloc->loc->pc;
887 new_backtrace->backtrace_size++;
896 backtrace_dump_data(
VALUE self)
898 VALUE str = rb_backtrace_to_str_ary(
self);
962 backtrace_limit(
VALUE self)
964 return LONG2NUM(rb_backtrace_length_limit);
970 return rb_backtrace_to_str_ary(rb_ec_partial_backtrace_object(ec, lev, n, NULL, FALSE, FALSE));
976 return rb_backtrace_to_location_ary(rb_ec_partial_backtrace_object(ec, lev, n, NULL, skip_internal, FALSE));
983 void (*init)(
void *arg,
size_t size),
994 if (start_cfp == NULL) {
1010 RUBY_VM_NEXT_CONTROL_FRAME(
1011 RUBY_VM_NEXT_CONTROL_FRAME(start_cfp));
1013 if (start_cfp < last_cfp) {
1017 size = start_cfp - last_cfp + 1;
1023 for (i=0, cfp = start_cfp; i<size; i++, cfp = RUBY_VM_NEXT_CONTROL_FRAME(cfp)) {
1027 iter_iseq(arg, cfp);
1031 VM_ASSERT(RUBYVM_CFUNC_FRAME_P(cfp));
1033 ID mid = me->def->original_id;
1035 iter_cfunc(arg, cfp, mid);
1043 void (*func)(
void *data,
VALUE file,
int lineno,
VALUE name);
1048 oldbt_init(
void *
ptr,
size_t dmy)
1051 arg->filename = GET_VM()->progname;
1059 const VALUE *pc = cfp->pc;
1061 VALUE file = arg->filename = rb_iseq_path(iseq);
1062 VALUE name = ISEQ_BODY(iseq)->location.label;
1063 int lineno = arg->lineno = calc_lineno(iseq, pc);
1065 (arg->func)(arg->data, file, lineno, name);
1072 VALUE file = arg->filename;
1074 int lineno = arg->lineno;
1076 (arg->func)(arg->data, file, lineno, name);
1080 oldbt_print(
void *data,
VALUE file,
int lineno,
VALUE name)
1085 fprintf(fp,
"\tfrom %s:%d:in unknown method\n",
1089 fprintf(fp,
"\tfrom %s:%d:in '%s'\n",
1095 vm_backtrace_print(
FILE *fp)
1099 arg.func = oldbt_print;
1100 arg.data = (
void *)fp;
1101 backtrace_each(GET_EC(),
1114 oldbt_bugreport(
void *arg,
VALUE file,
int line,
VALUE method)
1120 fprintf(fp,
"-- Ruby level backtrace information "
1121 "----------------------------------------\n");
1124 if (
NIL_P(method)) {
1125 fprintf(fp,
"%s:%d:in unknown method\n", filename, line);
1128 fprintf(fp,
"%s:%d:in '%s'\n", filename, line,
RSTRING_PTR(method));
1133 rb_backtrace_print_as_bugreport(
FILE *fp)
1138 arg.func = oldbt_bugreport;
1141 backtrace_each(GET_EC(),
1151 vm_backtrace_print(stderr);
1160 oldbt_print_to(
void *data,
VALUE file,
int lineno,
VALUE name)
1171 (*arg->iter)(arg->output, str);
1181 parg.output = output;
1182 arg.func = oldbt_print_to;
1184 backtrace_each(GET_EC(),
1194 return rb_ec_backtrace_str_ary(GET_EC(), BACKTRACE_START, ALL_BACKTRACE_LINES);
1200 VALUE level, vn, opts;
1208 if (argc == 2 &&
NIL_P(vn)) argc--;
1212 lev = lev_default + lev_plus;
1213 n = ALL_BACKTRACE_LINES;
1217 long beg,
len, bt_size = backtrace_size(ec);
1225 n = ALL_BACKTRACE_LINES;
1230 lev = beg + lev_plus;
1263 lev = ec_backtrace_range(ec, argc, argv, lev_default, lev_plus, &n);
1264 if (lev < 0)
return Qnil;
1270 btval = rb_ec_partial_backtrace_object(ec, lev, n, &too_large, FALSE, FALSE);
1277 r = backtrace_to_str_ary(btval);
1280 r = backtrace_to_location_ary(btval);
1287 thread_backtrace_to_ary(
int argc,
const VALUE *argv,
VALUE thval,
int to_str)
1291 if (target_th->to_kill || target_th->status == THREAD_KILLED)
1294 return ec_backtrace_to_ary(target_th->ec, argc, argv, 0, 0, to_str);
1298 rb_vm_thread_backtrace(
int argc,
const VALUE *argv,
VALUE thval)
1300 return thread_backtrace_to_ary(argc, argv, thval, 1);
1304 rb_vm_thread_backtrace_locations(
int argc,
const VALUE *argv,
VALUE thval)
1306 return thread_backtrace_to_ary(argc, argv, thval, 0);
1312 return ec_backtrace_to_ary(ec, argc, argv, 0, 0, 1);
1318 return ec_backtrace_to_ary(ec, argc, argv, 0, 0, 0);
1362 return ec_backtrace_to_ary(GET_EC(), argc, argv, 1, 1, 1);
1388 rb_f_caller_locations(
int argc,
VALUE *argv,
VALUE _)
1390 return ec_backtrace_to_ary(GET_EC(), argc, argv, 1, 1, 0);
1401 each_caller_location(
int argc,
VALUE *argv,
VALUE _)
1404 long n, lev = ec_backtrace_range(ec, argc, argv, 1, 1, &n);
1405 if (lev >= 0 && n != 0) {
1406 rb_ec_partial_backtrace_object(ec, lev, n, NULL, FALSE, TRUE);
1413 Init_vm_backtrace(
void)
1478 rb_define_method(rb_cBacktraceLocation,
"base_label", location_base_label_m, 0);
1480 rb_define_method(rb_cBacktraceLocation,
"absolute_path", location_absolute_path_m, 0);
1492 RUBY_SYMBOL_EXPORT_BEGIN
1494 RUBY_SYMBOL_EXPORT_END
1501 long backtrace_size;
1505 CALLER_BINDING_SELF,
1506 CALLER_BINDING_CLASS,
1507 CALLER_BINDING_BINDING,
1508 CALLER_BINDING_ISEQ,
1510 CALLER_BINDING_DEPTH,
1519 collect_caller_bindings_init(
void *arg,
size_t size)
1528 if (rb_vm_control_frame_id_and_class(cfp, 0, 0, &klass)) {
1530 return RBASIC(klass)->klass;
1544 VM_ASSERT(RUBY_VM_END_CONTROL_FRAME(ec) >= cfp);
1545 return (
int)(RUBY_VM_END_CONTROL_FRAME(ec) - cfp);
1555 rb_ary_store(frame, CALLER_BINDING_CLASS, get_klass(cfp));
1556 rb_ary_store(frame, CALLER_BINDING_BINDING, GC_GUARDED_PTR(cfp));
1558 rb_ary_store(frame, CALLER_BINDING_CFP, GC_GUARDED_PTR(cfp));
1571 rb_ary_store(frame, CALLER_BINDING_CLASS, get_klass(cfp));
1574 rb_ary_store(frame, CALLER_BINDING_CFP, GC_GUARDED_PTR(cfp));
1590 collect_caller_bindings_init,
1591 collect_caller_bindings_iseq,
1592 collect_caller_bindings_cfunc,
1602 if (!
NIL_P(cfp_val)) {
1604 rb_ary_store(entry, CALLER_BINDING_BINDING, rb_vm_make_binding(ec, cfp));
1621 enum ruby_tag_type state;
1622 volatile VALUE MAYBE_UNUSED(result);
1625 rb_vm_stack_to_heap(ec);
1627 dbg_context.ec = ec;
1628 dbg_context.cfp = dbg_context.ec->cfp;
1629 dbg_context.backtrace = rb_ec_backtrace_location_ary(ec, BACKTRACE_START, ALL_BACKTRACE_LINES, FALSE);
1630 dbg_context.backtrace_size =
RARRAY_LEN(dbg_context.backtrace);
1631 dbg_context.contexts = collect_caller_bindings(ec);
1634 if ((state = EC_EXEC_TAG()) == TAG_NONE) {
1635 result = (*func)(&dbg_context, data);
1642 EC_JUMP_TAG(ec, state);
1651 if (index < 0 || index >= dc->backtrace_size) {
1660 VALUE frame = frame_get(dc, index);
1667 VALUE frame = frame_get(dc, index);
1674 VALUE frame = frame_get(dc, index);
1681 VALUE frame = frame_get(dc, index);
1690 VALUE frame = frame_get(dc, index);
1698 return INT2FIX(frame_depth(ec, ec->cfp));
1704 return dc->backtrace;
1725 end_cfp = RUBY_VM_NEXT_CONTROL_FRAME(end_cfp);
1727 for (i=0; i<limit && cfp != end_cfp; cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp)) {
1728 if (VM_FRAME_RUBYFRAME_P(cfp) && cfp->pc != 0) {
1735 cme = rb_vm_frame_method_entry(cfp);
1736 if (cme && cme->def->type == VM_METHOD_TYPE_ISEQ) {
1737 buff[i] = (
VALUE)cme;
1740 buff[i] = (
VALUE)cfp->iseq;
1748 if (cfp == top && cfp->jit_return) {
1752 lines[i] = calc_lineno(cfp->iseq, cfp->pc);
1759 cme = rb_vm_frame_method_entry(cfp);
1760 if (cme && cme->def->type == VM_METHOD_TYPE_CFUNC) {
1765 buff[i] = (
VALUE)cme;
1766 if (lines) lines[i] = 0;
1786 return thread_profile_frames(ec, start, limit, buff, lines);
1793 return thread_profile_frames(th->ec, start, limit, buff, lines);
1797 frame2iseq(
VALUE frame)
1799 if (
NIL_P(frame))
return NULL;
1802 switch (imemo_type(frame)) {
1808 switch (cme->def->type) {
1809 case VM_METHOD_TYPE_ISEQ:
1810 return cme->def->body.iseq.
iseqptr;
1819 rb_bug(
"frame2iseq: unreachable");
1825 const rb_iseq_t *iseq = frame2iseq(frame);
1826 return iseq ? rb_iseq_path(iseq) :
Qnil;
1832 if (
NIL_P(frame))
return NULL;
1835 switch (imemo_type(frame)) {
1839 switch (cme->def->type) {
1840 case VM_METHOD_TYPE_CFUNC:
1857 if (cframe(frame)) {
1861 rb_vm_register_global_object(cfunc_str);
1865 const rb_iseq_t *iseq = frame2iseq(frame);
1866 return iseq ? rb_iseq_realpath(iseq) :
Qnil;
1872 const rb_iseq_t *iseq = frame2iseq(frame);
1873 return iseq ? rb_iseq_label(iseq) :
Qnil;
1879 const rb_iseq_t *iseq = frame2iseq(frame);
1880 return iseq ? rb_iseq_base_label(iseq) :
Qnil;
1886 const rb_iseq_t *iseq = frame2iseq(frame);
1887 return iseq ? rb_iseq_first_lineno(iseq) :
Qnil;
1891 frame2klass(
VALUE frame)
1898 if (imemo_type(frame) == imemo_ment) {
1899 return cme->defined_class;
1908 VALUE klass = frame2klass(frame);
1910 if (klass && !
NIL_P(klass)) {
1912 klass =
RBASIC(klass)->klass;
1914 else if (RCLASS_SINGLETON_P(klass)) {
1915 klass = RCLASS_ATTACHED_OBJECT(klass);
1929 VALUE klass = frame2klass(frame);
1931 return RBOOL(klass && !
NIL_P(klass) && RCLASS_SINGLETON_P(klass));
1939 ID mid = cme->def->original_id;
1942 const rb_iseq_t *iseq = frame2iseq(frame);
1943 return iseq ? rb_iseq_method_name(iseq) :
Qnil;
1947 qualified_method_name(
VALUE frame,
VALUE method_name)
1949 if (method_name !=
Qnil) {
1953 if (classpath !=
Qnil) {
1954 return rb_sprintf(
"%"PRIsVALUE
"%s%"PRIsVALUE,
1955 classpath, singleton_p ==
Qtrue ?
"." :
"#", method_name);
1971 return qualified_method_name(frame, method_name);
1979 ID mid = cme->def->original_id;
1980 VALUE method_name = id2str(mid);
1981 return qualified_method_name(frame, method_name);
1988 if (
NIL_P(qualified_method_name) || base_label == qualified_method_name) {
1994 int prefix_len =
rb_long2int(label_length - base_label_length);
#define rb_define_singleton_method(klass, mid, func, arity)
Defines klass.mid.
int rb_profile_frames(int start, int limit, VALUE *buff, int *lines)
Queries mysterious "frame"s of the given range.
VALUE rb_profile_frame_full_label(VALUE frame)
Identical to rb_profile_frame_label(), except it returns a qualified result.
VALUE rb_debug_inspector_frame_iseq_get(const rb_debug_inspector_t *dc, long index)
Queries the instruction sequence of the passed context's upper frame.
VALUE rb_debug_inspector_current_depth(void)
Return current frmae depth.
VALUE rb_profile_frame_method_name(VALUE frame)
Queries the name of the method of the passed frame.
VALUE rb_debug_inspector_frame_depth(const rb_debug_inspector_t *dc, long index)
Queries the depth of the passed context's upper frame.
VALUE rb_profile_frame_qualified_method_name(VALUE frame)
Identical to rb_profile_frame_method_name(), except it "qualifies" the return value with its defining...
VALUE rb_profile_frame_label(VALUE frame)
Queries human-readable "label" string.
VALUE rb_profile_frame_singleton_method_p(VALUE frame)
Queries if the method of the passed frame is a singleton class.
VALUE rb_debug_inspector_backtrace_locations(const rb_debug_inspector_t *dc)
Queries the backtrace object of the context.
VALUE rb_profile_frame_absolute_path(VALUE frame)
Identical to rb_profile_frame_path(), except it tries to expand the returning path.
VALUE rb_debug_inspector_open(rb_debug_inspector_func_t func, void *data)
Prepares, executes, then cleans up a debug session.
VALUE rb_debug_inspector_frame_self_get(const rb_debug_inspector_t *dc, long index)
Queries the current receiver of the passed context's upper frame.
VALUE rb_debug_inspector_frame_binding_get(const rb_debug_inspector_t *dc, long index)
Queries the binding of the passed context's upper frame.
VALUE rb_debug_inspector_frame_class_get(const rb_debug_inspector_t *dc, long index)
Queries the current class of the passed context's upper frame.
VALUE rb_profile_frame_classpath(VALUE frame)
Queries the class path of the method that the passed frame represents.
VALUE rb_profile_frame_path(VALUE frame)
Queries the path of the passed backtrace.
VALUE rb_profile_frame_first_lineno(VALUE frame)
Queries the first line of the method of the passed frame pointer.
int rb_profile_thread_frames(VALUE thread, int start, int limit, VALUE *buff, int *lines)
Queries mysterious "frame"s of the given range.
VALUE(* rb_debug_inspector_func_t)(const rb_debug_inspector_t *dc, void *data)
Type of the callback function passed to rb_debug_inspector_open().
VALUE rb_profile_frame_base_label(VALUE frame)
Identical to rb_profile_frame_label(), except it does not "qualify" the result.
VALUE rb_enc_sprintf(rb_encoding *enc, const char *fmt,...)
Identical to rb_sprintf(), except it additionally takes an encoding.
VALUE rb_define_class_under(VALUE outer, const char *name, VALUE super)
Defines a class under the namespace of outer.
void rb_undef_method(VALUE klass, const char *name)
Defines an undef of a method.
int rb_scan_args(int argc, const VALUE *argv, const char *fmt,...)
Retrieves argument from argc and argv to given VALUE references according to the format string.
void rb_define_method(VALUE klass, const char *name, VALUE(*func)(ANYARGS), int argc)
Defines a method.
int rb_get_kwargs(VALUE keyword_hash, const ID *table, int required, int optional, VALUE *values)
Keyword argument deconstructor.
void rb_define_global_function(const char *name, VALUE(*func)(ANYARGS), int argc)
Defines a global function.
#define Qundef
Old name of RUBY_Qundef.
#define INT2FIX
Old name of RB_INT2FIX.
#define T_IMEMO
Old name of RUBY_T_IMEMO.
#define CLASS_OF
Old name of rb_class_of.
#define T_MODULE
Old name of RUBY_T_MODULE.
#define ASSUME
Old name of RBIMPL_ASSUME.
#define T_ICLASS
Old name of RUBY_T_ICLASS.
#define LONG2NUM
Old name of RB_LONG2NUM.
#define Qtrue
Old name of RUBY_Qtrue.
#define Qnil
Old name of RUBY_Qnil.
#define Qfalse
Old name of RUBY_Qfalse.
#define T_ARRAY
Old name of RUBY_T_ARRAY.
#define NIL_P
Old name of RB_NIL_P.
#define T_CLASS
Old name of RUBY_T_CLASS.
#define NUM2LONG
Old name of RB_NUM2LONG.
#define rb_ary_new2
Old name of rb_ary_new_capa.
void rb_raise(VALUE exc, const char *fmt,...)
Exception entry point.
int rb_typeddata_is_kind_of(VALUE obj, const rb_data_type_t *data_type)
Checks if the given object is of given kind.
void rb_bug(const char *fmt,...)
Interpreter panic switch.
VALUE rb_eArgError
ArgumentError exception.
VALUE rb_cArray
Array class.
VALUE rb_obj_class(VALUE obj)
Queries the class of an object.
VALUE rb_cThread
Thread class.
#define RB_OBJ_WRITTEN(old, oldv, young)
Identical to RB_OBJ_WRITE(), except it doesn't write any values, but only a WB declaration.
#define RB_OBJ_WRITE(old, slot, young)
Declaration of a "back" pointer.
rb_encoding * rb_enc_compatible(VALUE str1, VALUE str2)
Look for the "common" encoding between the two.
void rb_gc_mark(VALUE obj)
Marks an object.
void rb_gc_mark_movable(VALUE obj)
Maybe this is the only function provided for C extensions to control the pinning of objects,...
VALUE rb_gc_location(VALUE obj)
Finds a new "location" of an object.
VALUE rb_ary_reverse(VALUE ary)
Destructively reverses the passed array in-place.
VALUE rb_ary_new(void)
Allocates a new, empty array.
VALUE rb_ary_push(VALUE ary, VALUE elem)
Special case of rb_ary_cat() that it adds only one element.
VALUE rb_ary_entry(VALUE ary, long off)
Queries an element of an array.
void rb_ary_store(VALUE ary, long key, VALUE val)
Destructively stores the passed value to the passed array's passed index.
VALUE rb_range_beg_len(VALUE range, long *begp, long *lenp, long len, int err)
Deconstructs a numerical range.
#define rb_str_new_literal(str)
Just another name of rb_str_new_lit.
VALUE rb_str_cat2(VALUE, const char *)
Just another name of rb_str_cat_cstr.
VALUE rb_str_inspect(VALUE str)
Generates a "readable" version of the receiver.
VALUE rb_str_cat_cstr(VALUE dst, const char *src)
Identical to rb_str_cat(), except it assumes the passed pointer is a pointer to a C string.
VALUE rb_class_path(VALUE mod)
Identical to rb_mod_name(), except it returns #<Class: ...> style inspection for anonymous modules.
void rb_undef_alloc_func(VALUE klass)
Deletes the allocator function of a class.
void rb_define_alloc_func(VALUE klass, rb_alloc_func_t func)
Sets the allocator function of a class.
VALUE rb_make_backtrace(void)
Creates the good old fashioned array-of-strings style backtrace info.
void rb_backtrace(void)
Prints the backtrace out to the standard error.
VALUE rb_id2str(ID id)
Identical to rb_id2name(), except it returns a Ruby's String instead of C's.
char * ptr
Pointer to the underlying memory region, of at least capa bytes.
int len
Length of the buffer.
VALUE rb_sprintf(const char *fmt,...)
Ruby's extended sprintf(3).
VALUE rb_str_catf(VALUE dst, const char *fmt,...)
Identical to rb_sprintf(), except it renders the output to the specified object rather than creating ...
VALUE rb_yield(VALUE val)
Yields the block.
#define rb_long2int
Just another name of rb_long2int_inline.
void rb_marshal_define_compat(VALUE newclass, VALUE oldclass, VALUE(*dumper)(VALUE), VALUE(*loader)(VALUE, VALUE))
Marshal format compatibility layer.
#define RB_GC_GUARD(v)
Prevents premature destruction of local objects.
VALUE type(ANYARGS)
ANYARGS-ed function type.
#define RARRAY_LEN
Just another name of rb_array_len.
#define RARRAY_AREF(a, i)
#define RBASIC(obj)
Convenient casting macro.
#define RUBY_DEFAULT_FREE
This is a value you can set to RData::dfree.
static char * RSTRING_PTR(VALUE str)
Queries the contents pointer of the string.
static long RSTRING_LEN(VALUE str)
Queries the length of the string.
#define RUBY_TYPED_DEFAULT_FREE
This is a value you can set to rb_data_type_struct::dfree.
VALUE rb_data_typed_object_zalloc(VALUE klass, size_t size, const rb_data_type_t *type)
Identical to rb_data_typed_object_wrap(), except it allocates a new data region internally instead of...
#define TypedData_Get_Struct(obj, type, data_type, sval)
Obtains a C struct from inside of a wrapper Ruby object.
#define TypedData_Make_Struct(klass, type, data_type, sval)
Identical to TypedData_Wrap_Struct, except it allocates a new data region internally instead of takin...
const char * rb_class2name(VALUE klass)
Queries the name of the passed class.
#define RTEST
This is an old name of RB_TEST.
#define _(args)
This was a transition path from K&R to ANSI.
This is the struct that holds necessary info for a struct.
const rb_iseq_t * iseqptr
iseq pointer, should be separated from iseqval
uintptr_t ID
Type that represents a Ruby identifier such as a variable name.
uintptr_t VALUE
Type that represents a Ruby object.
static bool RB_TYPE_P(VALUE obj, enum ruby_value_type t)
Queries if the given object is of given type.