summaryrefslogtreecommitdiffstats
path: root/llvm/lib/DebugInfo/PDB/Raw/PDBNameMap.cpp
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2016-04-29 17:28:47 +0000
committerZachary Turner <zturner@google.com>2016-04-29 17:28:47 +0000
commit2f09b5091ce055dbc3a803ecb2576540d6abb503 (patch)
tree13a919a417b0870502c6b5c87daa56aa55ed803f /llvm/lib/DebugInfo/PDB/Raw/PDBNameMap.cpp
parent6ba65deeb9b017e4144cdae341dcb9e3564c7c7b (diff)
downloadbcm5719-llvm-2f09b5091ce055dbc3a803ecb2576540d6abb503.tar.gz
bcm5719-llvm-2f09b5091ce055dbc3a803ecb2576540d6abb503.zip
Put PDB parsing code into a pdb namespace.
llvm-svn: 268072
Diffstat (limited to 'llvm/lib/DebugInfo/PDB/Raw/PDBNameMap.cpp')
-rw-r--r--llvm/lib/DebugInfo/PDB/Raw/PDBNameMap.cpp109
1 files changed, 0 insertions, 109 deletions
diff --git a/llvm/lib/DebugInfo/PDB/Raw/PDBNameMap.cpp b/llvm/lib/DebugInfo/PDB/Raw/PDBNameMap.cpp
deleted file mode 100644
index 4dd8cf0c7aa..00000000000
--- a/llvm/lib/DebugInfo/PDB/Raw/PDBNameMap.cpp
+++ /dev/null
@@ -1,109 +0,0 @@
-//===- PDBNameMap.cpp - PDB Name Map ----------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "llvm/DebugInfo/PDB/Raw/PDBNameMap.h"
-#include "llvm/ADT/BitVector.h"
-#include "llvm/DebugInfo/PDB/Raw/StreamReader.h"
-
-using namespace llvm;
-
-PDBNameMap::PDBNameMap() {}
-
-std::error_code PDBNameMap::load(StreamReader &Stream) {
-
- // This is some sort of weird string-set/hash table encoded in the stream.
- // It starts with the number of bytes in the table.
- uint32_t NumberOfBytes;
- Stream.readInteger(NumberOfBytes);
-
- // Following that field is the starting offset of strings in the name table.
- uint32_t StringsOffset = Stream.getOffset();
- Stream.setOffset(StringsOffset + NumberOfBytes);
-
- // This appears to be equivalent to the total number of strings *actually*
- // in the name table.
- uint32_t HashSize;
- Stream.readInteger(HashSize);
-
- // This appears to be an upper bound on the number of strings in the name
- // table.
- uint32_t MaxNumberOfStrings;
- Stream.readInteger(MaxNumberOfStrings);
-
- // This appears to be a hash table which uses bitfields to determine whether
- // or not a bucket is 'present'.
- uint32_t NumPresentWords;
- Stream.readInteger(NumPresentWords);
-
- // Store all the 'present' bits in a vector for later processing.
- SmallVector<uint32_t, 1> PresentWords;
- for (uint32_t I = 0; I != NumPresentWords; ++I) {
- uint32_t Word;
- Stream.readInteger(Word);
- PresentWords.push_back(Word);
- }
-
- // This appears to be a hash table which uses bitfields to determine whether
- // or not a bucket is 'deleted'.
- uint32_t NumDeletedWords;
- Stream.readInteger(NumDeletedWords);
-
- // Store all the 'deleted' bits in a vector for later processing.
- SmallVector<uint32_t, 1> DeletedWords;
- for (uint32_t I = 0; I != NumDeletedWords; ++I) {
- uint32_t Word;
- Stream.readInteger(Word);
- DeletedWords.push_back(Word);
- }
-
- BitVector Present(MaxNumberOfStrings, false);
- if (!PresentWords.empty())
- Present.setBitsInMask(PresentWords.data(), PresentWords.size());
- BitVector Deleted(MaxNumberOfStrings, false);
- if (!DeletedWords.empty())
- Deleted.setBitsInMask(DeletedWords.data(), DeletedWords.size());
-
- for (uint32_t I = 0; I < MaxNumberOfStrings; ++I) {
- if (!Present.test(I))
- continue;
-
- // For all present entries, dump out their mapping.
-
- // This appears to be an offset relative to the start of the strings.
- // It tells us where the null-terminated string begins.
- uint32_t NameOffset;
- Stream.readInteger(NameOffset);
-
- // This appears to be a stream number into the stream directory.
- uint32_t NameIndex;
- Stream.readInteger(NameIndex);
-
- // Compute the offset of the start of the string relative to the stream.
- uint32_t StringOffset = StringsOffset + NameOffset;
- uint32_t OldOffset = Stream.getOffset();
- // Pump out our c-string from the stream.
- std::string Str;
- Stream.setOffset(StringOffset);
- Stream.readZeroString(Str);
-
- Stream.setOffset(OldOffset);
- // Add this to a string-map from name to stream number.
- Mapping.insert({Str, NameIndex});
- }
-
- return std::error_code();
-}
-
-bool PDBNameMap::tryGetValue(StringRef Name, uint32_t &Value) const {
- auto Iter = Mapping.find(Name);
- if (Iter == Mapping.end())
- return false;
- Value = Iter->second;
- return true;
-}
OpenPOWER on IntegriCloud