Issue 130701.1: Add MD5 digest to debug-line file table

Author: Paul Robinson
Champion: Paul Robinson
Date submitted: 2013-07-01
Date revised:
Date closed:
Type: Enhancement
Status: Accepted
DWARF Version: 5
Section 6.2.4, 6.2.5.3, pg 115
The .debug_line section's file table permits the producer to record the
file size and modification timestamp of each source file, allowing a
debugger to determine whether a source file has changed between the
compilation and a debugging session.

The Sony Playstation debugger is integrated with Visual Studio, which
wants an MD5 digest of each source file; apparently the modification
timestamp can be unreliable when using some source control tools.
Currently our debugger computes the MD5 digest as needed during the
debugging session, which makes this file-modification detection scheme
not particularly effective.

A compiler already needs to read all the source files; and to create
type units, the compiler already needs an MD5 implementation.
Therefore it seems not too unreasonable to add an optional MD5 digest
to the .debug_line section's file table.


Changes to Section 6.2.4 "The Line Number Program Header"

Add a new item numbered 11, and renumber the existing items 11 and 12
as 12 and 13.

  11. file_entry_format (ubyte)
      A format code indicating the format of certain data in entries in
      the file_names field.  The format codes are as follows:
      o DW_LNF_timestamp_size
        Entries contain a modification timestamp and file size.
      o DW_LNF_MD5
        Entries contain an MD5 digest of the file contents.

In item 13 (renumbered from item 12), file_names, replace the second
and third bullets (timestamp/length) with the following.

  o If file_entry_format is DW_LNF_timestamp_size:
    o An unsigned LEB128 number representing the (implementation-defined)
      time of last modification for the file, or 0 if not available.
    o An unsigned LEB128 number representing the length in bytes of
      the file, or 0 if not available.

    If file_entry_format is DW_LNF_MD5:
    o A 16-byte MD5 digest of the file contents.

Also modify the non-normative text at the end of this item as follows.

    *A compiler may generate a single null byte for the file names field
    and define file names using the extended opcode DW_LNE_define_file
    (when file_entry_format is DW_LNF_timestamp_size) or
    DW_LNE_define_file_MD5 (when file_entry_format is DW_LNF_MD5).*

Changes to Section 6.2.5.3 "Extended Opcodes"

Add a new item numbered 5, as follows.

    5. DW_LNE_define_file_MD5

       The DW_LNE_define_file_MD5 opcode takes three operands:

       1. <copy text from DW_LNE_define_file operand 1>

       2. <copy text from DW_LNE_define_file operand 2>

       3. A 16-byte MD5 digest of the file contents.

Changes to Section 7.21:

Add a new figure after figure 38:

    Format Code Name       | Value
    DW_LNF_timestamp_size  | 0x01
    DW_LNF_MD5             | 0x02
    Figure 39. File Entry Format Code encodings.

Changes to Appendix F:

The .debug_line version number in DWARF v5 will be 5.

---

Revised 7/26/13.
Revised 8/1/13.
Accepted 9/25/2013.