public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "vries at gcc dot gnu.org" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug symtab/26092] New: Complain about contradictory DW_LNE_end_sequence marker
Date: Mon, 08 Jun 2020 08:34:49 +0000	[thread overview]
Message-ID: <bug-26092-4717@http.sourceware.org/bugzilla/> (raw)

https://sourceware.org/bugzilla/show_bug.cgi?id=26092

            Bug ID: 26092
           Summary: Complain about contradictory DW_LNE_end_sequence
                    marker
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: symtab
          Assignee: unassigned at sourceware dot org
          Reporter: vries at gcc dot gnu.org
  Target Milestone: ---

Consider test-case gdb.dwarf2/dw2-ranges-base.exp.  It has a line-table for
dw2-ranges-base.c like this:
...
     Line Number Statements:
      [0x0000014e]  Extended opcode 2: set Address to 0x4004ba
      [0x00000159]  Advance Line by 10 to 11
      [0x0000015b]  Copy
      [0x0000015c]  Advance PC by 12 to 0x4004c6
      [0x0000015e]  Advance Line by 19 to 30
      [0x00000160]  Copy
      [0x00000161]  Extended opcode 1: End of Sequence

      [0x00000164]  Extended opcode 2: set Address to 0x4004ae
      [0x0000016f]  Advance Line by 20 to 21
      [0x00000171]  Copy
      [0x00000172]  Advance PC by 12 to 0x4004ba
      [0x00000174]  Advance Line by 29 to 50
      [0x00000176]  Copy
      [0x00000177]  Extended opcode 1: End of Sequence

      [0x0000017a]  Extended opcode 2: set Address to 0x4004a7
      [0x00000185]  Advance Line by 30 to 31
      [0x00000187]  Copy
      [0x00000188]  Advance PC by 7 to 0x4004ae
      [0x0000018a]  Advance Line by 39 to 70
      [0x0000018c]  Copy
      [0x0000018d]  Extended opcode 1: End of Sequence
...

The Copy followed by End-of-Sequence is as specified in the dwarf assembly, but
incorrect.  F.i., consider:
 ...
      [0x0000015c]  Advance PC by 12 to 0x4004c6
      [0x0000015e]  Advance Line by 19 to 30
      [0x00000160]  Copy
      [0x00000161]  Extended opcode 1: End of Sequence
 ...

Both the Copy and the End-of-Sequence append a row to the matrix using the same
addres: 0x4004c6.

The Copy declares a target instruction at that address.

The End-of-Sequence declares that the sequence ends before that address.

It's a contradiction that the target instruction is both part of the sequence
(according to Copy) and not part of the sequence (according to
End-of-Sequence).

[ Relevant dwarf standard bits:

DW_LNS_copy

The DW_LNS_copy opcode takes no operands. It appends a row to the matrix using
the current values of the state machine registers. Then it sets the
discriminator register to 0, and sets the basic_block, prologue_end and
epilogue_begin registers to “false.”

end_sequence:

A boolean indicating that the current address is that of the first byte
after the end of a sequence of target machine instructions. end_sequence
terminates a sequence of lines; therefore other information in the same
row is not meaningful.

DW_LNE_end_sequence:

The DW_LNE_end_sequence opcode takes no operands. It sets the
end_sequence register of the state machine to “true” and appends a row
to the matrix using the current values of the state-machine registers.
Then it resets the registers to the initial values specified above (see
Section 6.2.2). Every line number program sequence must end with a
DW_LNE_end_sequence instruction which creates a row whose address is
that of the byte after the last target machine instruction of the sequence.

]

The offending Copy is currently silently skipped by
buildsym_compunit::record_line.

It would be good to warn about this invalid use of dwarf, through the
complaints mechanism, or some such.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

             reply	other threads:[~2020-06-08  8:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-08  8:34 vries at gcc dot gnu.org [this message]
2020-06-08  8:59 ` [Bug symtab/26092] " vries at gcc dot gnu.org
2020-06-08  9:38 ` vries at gcc dot gnu.org
2020-06-08 10:04 ` vries 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-26092-4717@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@sourceware.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).