On Wed, 2014-12-10 at 11:41 -0800, Josh Stone wrote:
> The function which contains an inline might not be the immediate next
> die scope.  For instance, there may be a lexical scope in between.
> Instead, iterate the remaining scopes until an appropriate tag is found.
>
> +2014-12-10  Josh Stone  <jist...@redhat.com>
> +
> +     * addr2line.c (handle_address): Find the proper inline parents.
>
> --- a/src/addr2line.c
> +++ b/src/addr2line.c
> @@ -672,7 +672,22 @@ handle_address (const char *string, Dwfl *dwfl)
>                       continue;
>  
>                     if (show_functions)
> -                     print_diesym (&scopes[i + 1]);
> +                     {
> +                       /* Search for the parent inline or function.  It
> +                          might not be directly above this inline -- e.g.
> +                          there could be a lexical_block in between.  */
> +                       for (int j = i + 1; j < nscopes; j++)
> +                         {
> +                           Dwarf_Die *parent = &scopes[j];
> +                           int tag = dwarf_tag (parent);
> +                           if (tag == DW_TAG_inlined_subroutine
> +                               || tag == DW_TAG_subprogram)

I believe technically you also want to match DW_TAG_entry_point. That
would match what eu-stack does. Admittedly GCC doesn't emit
DW_TAG_entry_point (the code is commented out in dwarf2out.c), but other
(fortran) compilers might. DWARF describes subprograms and entry_points
almost identically, both have a name and possibly a linkage_name, which
is what we care about here.

> +                             {
> +                               print_diesym (parent);
> +                               break;
> +                             }
> +                         }
> +                     }
>  
>                     src = NULL;
>                     lineno = 0;

Looks good, but please add DW_TAG_entry_point above before pushing this
commit.

Thanks,

Mark

Reply via email to