From 49f0da682180f3623c173075c498694b1d21d585 Mon Sep 17 00:00:00 2001 From: fundamental Date: Tue, 30 Mar 2021 19:16:15 -0400 Subject: Add support for partial backtraces When debug information is omitted within ireps, show that a stack frame existed rather than silently hiding it. --- src/backtrace.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/backtrace.c') diff --git a/src/backtrace.c b/src/backtrace.c index 70c82e2d1..c69af5955 100644 --- a/src/backtrace.c +++ b/src/backtrace.c @@ -61,7 +61,6 @@ each_backtrace(mrb_state *mrb, ptrdiff_t ciidx, each_backtrace_func func, void * idx = (uint32_t)(pc - irep->iseq); loc.lineno = mrb_debug_get_line(mrb, irep, idx); - if (loc.lineno == -1) continue; loc.filename = mrb_debug_get_filename(mrb, irep, idx); if (!loc.filename) { @@ -202,7 +201,12 @@ mrb_unpack_backtrace(mrb_state *mrb, mrb_value backtrace) const struct backtrace_location *entry = &bt[i]; mrb_value btline; - btline = mrb_format(mrb, "%s:%d", entry->filename, (int)entry->lineno); + if (entry->lineno != -1) {//debug info was available + btline = mrb_format(mrb, "%s:%d", entry->filename, (int)entry->lineno); + } + else { //all that was left was the stack frame + btline = mrb_format(mrb, "%s:missing-lineno", entry->filename); + } if (entry->method_id != 0) { mrb_str_cat_lit(mrb, btline, ":in "); mrb_str_cat_cstr(mrb, btline, mrb_sym_name(mrb, entry->method_id)); -- cgit v1.2.3