<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 - PDB GUIDs are printed with incorrect byte order."
   href="https://bugs.llvm.org/show_bug.cgi?id=41712">41712</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>PDB GUIDs are printed with incorrect byte order.
          </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>Windows NT
          </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>zturner@google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>amccarth@google.com, jdevlieghere@apple.com, keith.walker@arm.com, llvm-bugs@lists.llvm.org, nicolasweber@gmx.de, paul_robinson@playstation.sony.com, rnk@google.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>In DebugInfo/CodeView/GUID.h we define the GUID structure like this:

struct GUID {
  uint8_t Guid[16];
};

Then when we print it, we just iterate the sequence of bytes and print each one
with dashes in the appropriate place.

In the Microsoft headers, GUID is defined like this:

typedef struct _GUID {
    unsigned long  Data1;
    unsigned short Data2;
    unsigned short Data3;
    unsigned char  Data4[ 8 ];
} GUID;

So the "standard" way of formatting a GUID will have the first 3 fields printed
in little-endian byte order.  We can see this in action with the following
commands:

$ llvm-readobj -coff-debug-directory foo.exe | grep PDBGUID
      PDBGUID: (66 ED A0 BF 54 10 96 42 9B 7B 29 28 7E 84 67 B1)

$ llvm-pdbutil dump -summary foo.pdb | grep GUID
  GUID: {66EDA0BF-5410-9642-9B7B-29287E8467B1}

So here we can see that we print the GUID in byte-order.

Now load this EXE in WinDbg:

0:000> !chksym foo
*** WARNING: Unable to verify checksum for foo.exe

foo.exe
    Timestamp: 5CCB1685
  SizeOfImage: 6B000
          pdb: C:\src\sandbox\foo.pdb
      pdb sig: BFA0ED66-1054-4296-9B7B-29287E8467B1

And we can see that the signature is printed as if the first 3 fields were
little endian integers, not just a sequence of bytes.</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>