On Sat, Jul 23, 2016 at 10:30 AM, Alexandre Oliva <aol...@redhat.com> wrote:
> We used to emit, in debug information, the values bound to pointer to
> member function template parameters only when they were NULL or
> virtual member functions, because those can be represented with
> DW_AT_const_value.
>
> In order to represent the symbolic pointer to member function
> constants for non-virtual member functions, we'd need to be able to
> emit relocations for part of DW_AT_const_value, which we don't. The
> more viable alternative is to use DW_AT_location to represent such
> values, as slated for inclusion in DWARFv5, according to
> <URL:http://www.dwarfstd.org/ShowIssue.php?issue=130412.1>.

> With this patch, when we can't emit a DW_AT_const_value, we emit each
> "member" of the pointer to member function "record" as a
> DW_OP_stack_value DW_OP_piece, as long as the referenced member
> function is output in the same translation unit, otherwise we'd get
> relocations to external symbols, something to avoid in debug sections.

I wonder if it would make sense to use weak references...

> +                 if (pos > offset)
> +                   {
> +                     ret1 = new_loc_descr (DW_OP_piece, pos - offset, 0);
> +                     add_loc_descr (&ret, ret1);
> +                     offset = pos;
> +                   }

This seems like it will emit a DW_OP_piece with nothing before it,
which I think is invalid DWARF.  Perhaps we should use DW_OP_lit0
first, or fail the expansion.

> +             if (offset != size)
> +               {
> +                 ret1 = new_loc_descr (DW_OP_piece, size - offset, 0);
> +                 add_loc_descr (&ret, ret1);
> +                 offset = size;
> +               }

Likewise.

Jason

Reply via email to