<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Duplicate file names in DWARF v5 line tables"
   href="https://bugs.llvm.org/show_bug.cgi?id=44170">44170</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Duplicate file names in DWARF v5 line tables
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>DebugInfo
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>labath@google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dblaikie@gmail.com, jdevlieghere@apple.com, keith.walker@arm.com, llvm-bugs@lists.llvm.org, paul_robinson@playstation.sony.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>[Filing this as a debug info bug, but in all likelihood this is a bug in how
clang generates llvm ir.]

If compile the a file with just a slightly more complicated path (e.g. add a
leading "./"), the file will end up twice in the line table.

=====
$ clang -gmlt -gdwarf-5 -o a.o ./a.c -c && llvm-dwarfdump -debug-line a.o
...
include_directories[  0] = "/tmp/X"
include_directories[  1] = "."
file_names[  0]:
           name: "a.c"
      dir_index: 0
   md5_checksum: e6ab1d5b7f82464c963a8522037dfa72
file_names[  1]:
           name: "a.c"
      dir_index: 1
   md5_checksum: e6ab1d5b7f82464c963a8522037dfa72

Address            Line   Column File   ISA Discriminator Flags
------------------ ------ ------ ------ --- ------------- -------------
0x0000000000000000      1      0      1   0             0  is_stmt
=====

If I remove the "./" then the file is present just once, and all the line table
entries correctly reference entry 0.

I found this while playing around with lldb and dwarf 5. It seems lldb has some
code, which assumes a file will be present only once in a line table, and so
things fail in subtle ways, because sometimes it will pick file zero, which has
no line entries associated with it. Lldb probably shouldn't be making that
assumption, but regardless of that, this looks like a bug in llvm/clang. The
code in question definitely comes from the primary source file, so the line
tables should reference it as such.

This is probably caused by the fact that we do some form of path simplification
on the path which goes in the the DICompileUnit, but not on the line !dbg
attachments.  I guess both should undergo the same kinds of simplifications.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>