public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "uweigand at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug debug/66728] New: CONST_WIDE_INT causes corrupted DWARF debug info
Date: Wed, 01 Jul 2015 17:39:00 -0000	[thread overview]
Message-ID: <bug-66728-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66728

            Bug ID: 66728
           Summary: CONST_WIDE_INT causes corrupted DWARF debug info
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
          Assignee: unassigned at gcc dot gnu.org
          Reporter: uweigand at gcc dot gnu.org
  Target Milestone: ---

Compiling the following test case:

__uint128_t test(void)
{
  static const __uint128_t two127 = ((__uint128_t) 1) << 127;

  return two127;
}

on x86_64-linux (or ppc64le-linux) with -O -S -g -dA results in:

        .uleb128 0x2    # (DIE (0x2d) DW_TAG_subprogram)
                        # DW_AT_external
        .long   .LASF3  # DW_AT_name: "test"
[snip]
        .uleb128 0x3    # (DIE (0x4e) DW_TAG_variable)
        .long   .LASF4  # DW_AT_name: "two127"
        .byte   0x1     # DW_AT_decl_file (xxx.i)
        .byte   0x4     # DW_AT_decl_line
        .long   0x61    # DW_AT_type
        .byte   0       # end of children of DIE 0x2d

But abbreviation 3 (used for the 0x4e DIE) reads:
        .uleb128 0x3    # (abbrev code)
        .uleb128 0x34   # (TAG: DW_TAG_variable)
        .byte   0       # DW_children_no
        .uleb128 0x3    # (DW_AT_name)
        .uleb128 0xe    # (DW_FORM_strp)
        .uleb128 0x3a   # (DW_AT_decl_file)
        .uleb128 0xb    # (DW_FORM_data1)
        .uleb128 0x3b   # (DW_AT_decl_line)
        .uleb128 0xb    # (DW_FORM_data1)
        .uleb128 0x49   # (DW_AT_type)
        .uleb128 0x13   # (DW_FORM_ref4)
        .uleb128 0x1c   # (DW_AT_const_value)
        .uleb128 0xa    # (DW_FORM_block1)
        .byte   0
        .byte   0

So the variable DIE should have an DW_AT_const_value attribute encoded as
DW_FORM_block1.  This makes sense, since the variable was optimized away due to
being constant, and the size of the constant is 16 bytes.

However, the code in .debug_info to construct the DIE does not emit any
DW_FORM_block1; in fact, it does not emit *anything* where the
DW_AT_const_value is expected.  This causes the resulting debug info to be
corrupted, and tools operating on this info will emit errors (or even crash).

On ppc64le-linux (but not x86_64-linux), the same problem occurs with GCC 5 as
well.  The difference seems to be that x86_64 in GCC 5 uses a CONST_DOUBLE
instead of a CONST_WIDE_INT to represent that 128-bit constant.


             reply	other threads:[~2015-07-01 17:39 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-01 17:39 uweigand at gcc dot gnu.org [this message]
2015-07-01 17:48 ` [Bug debug/66728] " uweigand at gcc dot gnu.org
2015-07-01 17:50 ` pinskia at gcc dot gnu.org
2015-07-02  7:50 ` [Bug debug/66728] [5/6 Regression] " rguenth at gcc dot gnu.org
2015-07-02 17:22 ` rsandifo at gcc dot gnu.org
2015-07-02 18:50 ` rsandifo at gcc dot gnu.org
2015-07-16  9:18 ` rguenth at gcc dot gnu.org
2015-08-20 12:00 ` uweigand at gcc dot gnu.org
2015-08-20 20:57 ` rsandifo at gcc dot gnu.org
2021-03-22  7:53 ` [Bug debug/66728] [5 " cvs-commit at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-66728-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).