[PATCH] D34491: [PDB] Fix reading of clang-generated PDBs by CVDump.

Zachary Turner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 26 02:47:38 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL306233: [pdb] Fix reading of llvm-generated PDBs by cvdump. (authored by zturner).

Changed prior to commit:
  https://reviews.llvm.org/D34491?vs=103503&id=103906#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D34491

Files:
  llvm/trunk/lib/DebugInfo/PDB/Native/NamedStreamMap.cpp


Index: llvm/trunk/lib/DebugInfo/PDB/Native/NamedStreamMap.cpp
===================================================================
--- llvm/trunk/lib/DebugInfo/PDB/Native/NamedStreamMap.cpp
+++ llvm/trunk/lib/DebugInfo/PDB/Native/NamedStreamMap.cpp
@@ -23,6 +23,14 @@
 using namespace llvm;
 using namespace llvm::pdb;
 
+// FIXME: This shouldn't be necessary, but if we insert the strings in any
+// other order, cvdump cannot read the generated name map.  This suggests that
+// we may be using the wrong hash function.  A closer inspection of the cvdump
+// source code may reveal something, but for now this at least makes us work,
+// even if only by accident.
+static constexpr const char *OrderedStreamNames[] = {"/LinkInfo", "/names",
+                                                     "/src/headerblock"};
+
 NamedStreamMap::NamedStreamMap() = default;
 
 Error NamedStreamMap::load(BinaryStreamReader &Stream) {
@@ -73,9 +81,10 @@
   if (auto EC = Writer.writeInteger(FinalizedInfo->StringDataBytes))
     return EC;
 
-  // Now all of the string data itself.
-  for (const auto &Item : Mapping) {
-    if (auto EC = Writer.writeCString(Item.getKey()))
+  for (const auto &Name : OrderedStreamNames) {
+    auto Item = Mapping.find(Name);
+    assert(Item != Mapping.end());
+    if (auto EC = Writer.writeCString(Item->getKey()))
       return EC;
   }
 
@@ -93,9 +102,12 @@
   // Build the finalized hash table.
   FinalizedHashTable.clear();
   FinalizedInfo.emplace();
-  for (const auto &Item : Mapping) {
-    FinalizedHashTable.set(FinalizedInfo->StringDataBytes, Item.getValue());
-    FinalizedInfo->StringDataBytes += Item.getKeyLength() + 1;
+
+  for (const auto &Name : OrderedStreamNames) {
+    auto Item = Mapping.find(Name);
+    assert(Item != Mapping.end());
+    FinalizedHashTable.set(FinalizedInfo->StringDataBytes, Item->getValue());
+    FinalizedInfo->StringDataBytes += Item->getKeyLength() + 1;
   }
 
   // Number of bytes of string data.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34491.103906.patch
Type: text/x-patch
Size: 1978 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170626/3b77c425/attachment.bin>


More information about the llvm-commits mailing list