On Thu, Aug 13, 2015 at 8:25 AM, Ian Lance Taylor <i...@google.com> wrote: > On Thu, Aug 13, 2015 at 7:11 AM, FX <fxcoud...@gmail.com> wrote: >> >>> I don't know why this is not working. Everything looks fine in the >>> a.out that you sent. Unfortunately, I think you sent the one built >>> without libbacktrace. Can you send me the one built with libbacktrace? >> >> Attached is the a.out with libgfortran (and thus libbacktrace) linked in >> statically. If this isn’t sufficient, I can send any file necessary >> (including the whole tree if need be). > > Thanks. The problem seems to be that gfortran is generating DWARF > info that looks like this: > > subprogram test > subprogram foo > subprogram bar > > libbacktrace does not expect to see this structure, and it thinks that > foo and bar have been inlined within test, which is not the case. > > Please try this patch to libbacktrace and see if it helps.
And yet, that patch has absolutely nothing to do with libbacktrace. Hmmm. Let's try this one. Ian
Index: dwarf.c =================================================================== --- dwarf.c (revision 226846) +++ dwarf.c (working copy) @@ -2250,7 +2250,8 @@ read_function_entry (struct backtrace_st struct unit *u, uint64_t base, struct dwarf_buf *unit_buf, const struct line_header *lhdr, backtrace_error_callback error_callback, void *data, - struct function_vector *vec) + struct function_vector *vec_function, + struct function_vector *vec_inlined) { while (unit_buf->left > 0) { @@ -2258,6 +2259,7 @@ read_function_entry (struct backtrace_st const struct abbrev *abbrev; int is_function; struct function *function; + struct function_vector *vec; size_t i; uint64_t lowpc; int have_lowpc; @@ -2279,6 +2281,11 @@ read_function_entry (struct backtrace_st || abbrev->tag == DW_TAG_entry_point || abbrev->tag == DW_TAG_inlined_subroutine); + if (abbrev->tag == DW_TAG_inlined_subroutine) + vec = vec_inlined; + else + vec = vec_function; + function = NULL; if (is_function) { @@ -2458,7 +2465,8 @@ read_function_entry (struct backtrace_st if (!is_function) { if (!read_function_entry (state, ddata, u, base, unit_buf, lhdr, - error_callback, data, vec)) + error_callback, data, vec_function, + vec_inlined)) return 0; } else @@ -2471,7 +2479,8 @@ read_function_entry (struct backtrace_st memset (&fvec, 0, sizeof fvec); if (!read_function_entry (state, ddata, u, base, unit_buf, lhdr, - error_callback, data, &fvec)) + error_callback, data, vec_function, + &fvec)) return 0; if (fvec.count > 0) @@ -2535,7 +2544,7 @@ read_function_info (struct backtrace_sta while (unit_buf.left > 0) { if (!read_function_entry (state, ddata, u, 0, &unit_buf, lhdr, - error_callback, data, pfvec)) + error_callback, data, pfvec, pfvec)) return; }