backtrace.c: do not skip frames for C function calls.
MODIFY
src/backtrace.c
src/backtrace.c
@@ -38,15 +38,17 @@ each_backtrace(mrb_state *mrb, ptrdiff_t ciidx, each_backtrace_func func, void *
for (ptrdiff_t i=ciidx; i >= 0; i--) {
struct backtrace_location loc;
mrb_callinfo *ci;
- const mrb_irep *irep;
+ const mrb_irep *irep = 0;
const mrb_code *pc;
uint32_t idx;
ci = &mrb->c->cibase[i];
- if (!ci->proc) continue;
- if (MRB_PROC_CFUNC_P(ci->proc)) continue;
-
+ if (!ci->proc || MRB_PROC_CFUNC_P(ci->proc)) {
+ loc.lineno = -1;
+ idx = 0;
+ }
+ else {
irep = ci->proc->body.irep;
if (!irep) continue;
if (mrb->c->cibase[i].pc) {
@@ -55,10 +57,10 @@ each_backtrace(mrb_state *mrb, ptrdiff_t ciidx, each_backtrace_func func, void *
else {
continue;
}
-
- loc.method_id = ci->mid;
idx = (uint32_t)(pc - irep->iseq);
loc.lineno = mrb_debug_get_line(mrb, irep, idx);
+ }
+ loc.method_id = ci->mid;
if (loc.lineno == -1) {
for (ptrdiff_t j=i-1; j >= 0; j--) {
ci = &mrb->c->cibase[j];

backtrace.c: do not skip frames for C function calls.