This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Emit DW_AT_data_bit_offset instead of DW_AT_{data_member_location,bit_offset,byte_size} for -gdwarf-5 (PR debug/71669)


OK.

On Thu, Jan 12, 2017 at 3:27 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> While DW_AT_data_bit_offset has been introduced already in DWARF4, GDB only
> gained support for it last November, so I think it is better to enable this
> only for -gdwarf-5 for now and we can reconsider it in a year or two.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
>
> 2017-01-12  Jakub Jelinek  <jakub@redhat.com>
>
>         PR debug/71669
>         * dwarf2out.c (add_data_member_location_attribute): For constant
>         offset bitfield emit for -gdwarf-5 DW_AT_data_bit_offset attribute
>         instead of DW_AT_data_member_location, DW_AT_bit_offset and
>         DW_AT_byte_size attributes.
>
> --- gcc/dwarf2out.c.jj  2017-01-11 19:05:15.000000000 +0100
> +++ gcc/dwarf2out.c     2017-01-12 15:08:29.842773537 +0100
> @@ -18272,6 +18272,23 @@ add_data_member_location_attribute (dw_d
>
>    if (! loc_descr)
>      {
> +      /* While DW_AT_data_bit_offset has been added already in DWARF4,
> +        e.g. GDB only added support to it in November 2016.  For DWARF5
> +        we need newer debug info consumers anyway.  We might change this
> +        to dwarf_version >= 4 once most consumers catched up.  */
> +      if (dwarf_version >= 5
> +         && TREE_CODE (decl) == FIELD_DECL
> +         && DECL_BIT_FIELD_TYPE (decl))
> +       {
> +         tree off = bit_position (decl);
> +         if (tree_fits_uhwi_p (off) && get_AT (die, DW_AT_bit_size))
> +           {
> +             remove_AT (die, DW_AT_byte_size);
> +             remove_AT (die, DW_AT_bit_offset);
> +             add_AT_unsigned (die, DW_AT_data_bit_offset, tree_to_uhwi (off));
> +             return;
> +           }
> +       }
>        if (dwarf_version > 2)
>         {
>           /* Don't need to output a location expression, just the constant. */
>
>         Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]