[PDB] Make our PDBs look more like MS PDBs.

When investigating bugs in PDB generation, the first step is
often to do the same link with link.exe and then compare PDBs.

But comparing PDBs is hard because two completely different byte
sequences can both be correct, so it hampers the investigation when
you also have to spend time figuring out not just which bytes are
different, but also if the difference is meaningful.

This patch fixes a couple of cases related to string table emission,
hash table emission, and the order in which we emit strings that
makes more of our bytes the same as the bytes generated by MS PDBs.

Differential Revision: https://reviews.llvm.org/D44810

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@328348 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Zachary Turner
2018-03-23 18:43:39 +00:00
parent 287a3ef3c9
commit 0995a92322
15 changed files with 254 additions and 79 deletions

View File

@@ -86,6 +86,15 @@ Error DebugStringTableSubsection::commit(BinaryStreamWriter &Writer) const {
uint32_t DebugStringTableSubsection::size() const { return StringToId.size(); }
std::vector<uint32_t> DebugStringTableSubsection::sortedIds() const {
std::vector<uint32_t> Result;
Result.reserve(IdToString.size());
for (const auto &Entry : IdToString)
Result.push_back(Entry.first);
std::sort(Result.begin(), Result.end());
return Result;
}
uint32_t DebugStringTableSubsection::getIdForString(StringRef S) const {
auto Iter = StringToId.find(S);
assert(Iter != StringToId.end());