Bug 17276 - gdb needs to coalesce multiple line number entries for the same (non-prologue) line
Summary: gdb needs to coalesce multiple line number entries for the same (non-prologue...
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: symtab (show other bugs)
Version: HEAD
: P2 normal
Target Milestone: ---
Assignee: dje
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-08-15 18:35 UTC by dje
Modified: 2014-08-23 22:08 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
Project(s) to access:
ssh public key:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description dje 2014-08-15 18:35:45 UTC
watchpoint-reuse-slot.exp fails with clang.
The reason is that the test does a stepi to step into the middle of a line and expects gdb to print the pc value (which gdb will do when in the middle of a line).

  for (i = 0; i < 10; ++i) continue;

clang emits several line number entries for that line,
each with a different discriminator.

The Directory Table:
  ../../../binutils-gdb/gdb/testsuite/gdb.base

 The File Name Table:
  Entry Dir     Time    Size    Name
  1     1       0       0       watchpoint-reuse-slot.c

 Line Number Statements:
  Extended opcode 2: set Address to 0x400600
  Advance Line by 29 to 30
  Copy
  Set column to 3
  Set prologue_end to true
  Special opcode 160: advance Address by 11 to 0x40060b and Line by 1 to 31
  Set column to 8
  Special opcode 106: advance Address by 7 to 0x400612 and Line by 3 to 34
  Extended opcode 4: set Discriminator to 4
  Special opcode 103: advance Address by 7 to 0x400619 and Line by 0 to 34
  Extended opcode 4: set Discriminator to 2
  Special opcode 201: advance Address by 14 to 0x400627 and Line by 0 to 34
  Set column to 27
  Extended opcode 4: set Discriminator to 3
  Special opcode 75: advance Address by 5 to 0x40062c and Line by 0 to 34
  Set column to 3
  Extended opcode 4: set Discriminator to 0
  Advance PC by constant 17 to 0x40063d
  Special opcode 63: advance Address by 4 to 0x400641 and Line by 2 to 36
  Advance PC by 2 to 0x400643
  Extended opcode 1: End of Sequence

Thus gdb gets confused - the pc is in the middle of line 34, but gdb doesn't think so.

patch to follow.
Comment 1 Sourceware Commits 2014-08-23 00:29:08 UTC
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gdb and binutils".

The branch, master has been updated
       via  a05a36a5fc98c816381b25c37e8aa971cc86c28d (commit)
      from  9bda4a968f56cb61b832cdbdabf09a84eab140ab (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=a05a36a5fc98c816381b25c37e8aa971cc86c28d

commit a05a36a5fc98c816381b25c37e8aa971cc86c28d
Author: Doug Evans <dje@google.com>
Date:   Fri Aug 22 17:25:59 2014 -0700

    Fix pr 17276.
    
    See the description here:
    https://sourceware.org/ml/gdb-patches/2014-08/msg00283.html
    
    This patch keeps track of whether the current line has seen a
    non-zero discriminator, and if so coalesces consecutive entries
    for the same line (by ignoring all entries after the first).
    
    gdb/ChangeLog:
    
    	PR 17276
    	* dwarf2read.c (dwarf_record_line_p): New function.
    	(dwarf_decode_lines_1): Ignore subsequent line number entries
    	for the same line if any entry had a non-zero discriminator.
    
    gdb/testsuite/ChangeLog:
    
    	* gdb.dwarf2/dw2-single-line-discriminators.S: New file.
    	* gdb.dwarf2/dw2-single-line-discriminators.c: New file.
    	* gdb.dwarf2/dw2-single-line-discriminators.exp: New file.

-----------------------------------------------------------------------

Summary of changes:
 gdb/ChangeLog                                      |    7 +
 gdb/dwarf2read.c                                   |  108 +++++++-
 gdb/testsuite/ChangeLog                            |    7 +
 .../gdb.dwarf2/dw2-single-line-discriminators.S    |  281 ++++++++++++++++++++
 .../gdb.dwarf2/dw2-single-line-discriminators.c    |   31 +++
 .../gdb.dwarf2/dw2-single-line-discriminators.exp  |   49 ++++
 6 files changed, 471 insertions(+), 12 deletions(-)
 create mode 100644 gdb/testsuite/gdb.dwarf2/dw2-single-line-discriminators.S
 create mode 100644 gdb/testsuite/gdb.dwarf2/dw2-single-line-discriminators.c
 create mode 100644 gdb/testsuite/gdb.dwarf2/dw2-single-line-discriminators.exp
Comment 2 Doug Evans 2014-08-23 22:08:14 UTC
Patch is checked in.