#include "llvm/DebugInfo/MSF/StreamRef.h"
#include "llvm/DebugInfo/PDB/PDBTypes.h"
#include "llvm/DebugInfo/PDB/Raw/ModInfo.h"
-#include "llvm/DebugInfo/PDB/Raw/NameHashTable.h"
#include "llvm/DebugInfo/PDB/Raw/RawConstants.h"
#include "llvm/DebugInfo/PDB/Raw/RawTypes.h"
+#include "llvm/DebugInfo/PDB/Raw/StringTable.h"
#include "llvm/Support/Endian.h"
#include "llvm/Support/Error.h"
std::unique_ptr<msf::MappedBlockStream> Stream;
std::vector<ModuleInfoEx> ModuleInfos;
- NameHashTable ECNames;
+ StringTable ECNames;
msf::ReadableStreamRef ModInfoSubstream;
msf::ReadableStreamRef SecContrSubstream;
#include "llvm/ADT/StringMap.h"
#include "llvm/DebugInfo/MSF/MappedBlockStream.h"
#include "llvm/DebugInfo/PDB/PDBTypes.h"
-#include "llvm/DebugInfo/PDB/Raw/NameMap.h"
+#include "llvm/DebugInfo/PDB/Raw/NamedStreamMap.h"
#include "llvm/DebugInfo/PDB/Raw/RawConstants.h"
#include "llvm/Support/Endian.h"
// universally unique.
PDB_UniqueId Guid;
- NameMap NamedStreams;
+ NamedStreamMap NamedStreams;
};
}
}
#include "llvm/Support/Error.h"
#include "llvm/DebugInfo/PDB/PDBTypes.h"
-#include "llvm/DebugInfo/PDB/Raw/NameMapBuilder.h"
+#include "llvm/DebugInfo/PDB/Raw/NamedStreamMapBuilder.h"
#include "llvm/DebugInfo/PDB/Raw/PDBFile.h"
#include "llvm/DebugInfo/PDB/Raw/RawConstants.h"
void setAge(uint32_t A);
void setGuid(PDB_UniqueId G);
- NameMapBuilder &getNamedStreamsBuilder();
+ NamedStreamMapBuilder &getNamedStreamsBuilder();
uint32_t calculateSerializedLength() const;
uint32_t Age;
PDB_UniqueId Guid;
- NameMapBuilder NamedStreams;
+ NamedStreamMapBuilder NamedStreams;
};
}
}
-//===- NameMap.h - PDB Name Map ---------------------------------*- C++ -*-===//
+//===- NamedStreamMap.h - PDB Named Stream Map ------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_DEBUGINFO_PDB_RAW_PDBNAMEMAP_H
-#define LLVM_DEBUGINFO_PDB_RAW_PDBNAMEMAP_H
+#ifndef LLVM_DEBUGINFO_PDB_RAW_PDBNAMEDSTREAMMAP_H
+#define LLVM_DEBUGINFO_PDB_RAW_PDBNAMEDSTREAMMAP_H
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
class StreamWriter;
}
namespace pdb {
-class NameMapBuilder;
-class NameMap {
- friend NameMapBuilder;
+class NamedStreamMapBuilder;
+class NamedStreamMap {
+ friend NamedStreamMapBuilder;
public:
- NameMap();
+ NamedStreamMap();
Error load(msf::StreamReader &Stream);
} // end namespace pdb
} // end namespace llvm
-#endif // LLVM_DEBUGINFO_PDB_RAW_PDBNAMEMAP_H
+#endif // LLVM_DEBUGINFO_PDB_RAW_PDBNAMEDSTREAMMAP_H
-//===- NameMapBuilder.h - PDB Name Map Builder ------------------*- C++ -*-===//
+//===- NamedStreamMapBuilder.h - PDB Named Stream Map Builder ---*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_DEBUGINFO_PDB_RAW_PDBNAMEMAPBUILDER_H
-#define LLVM_DEBUGINFO_PDB_RAW_PDBNAMEMAPBUILDER_H
+#ifndef LLVM_DEBUGINFO_PDB_RAW_PDBNAMEDSTREAMMAPBUILDER_H
+#define LLVM_DEBUGINFO_PDB_RAW_PDBNAMEDSTREAMMAPBUILDER_H
#include "llvm/DebugInfo/PDB/Raw/HashTable.h"
#include "llvm/Support/Error.h"
class StreamWriter;
}
namespace pdb {
-class NameMap;
-class NameMapBuilder {
+class NamedStreamMapBuilder {
public:
- NameMapBuilder();
+ NamedStreamMapBuilder();
void addMapping(StringRef Name, uint32_t Mapping);
class DbiStream;
class GlobalsStream;
class InfoStream;
-class NameHashTable;
+class StringTable;
class PDBFileBuilder;
class PublicsStream;
class SymbolStream;
Expected<TpiStream &> getPDBIpiStream();
Expected<PublicsStream &> getPDBPublicsStream();
Expected<SymbolStream &> getPDBSymbolStream();
- Expected<NameHashTable &> getStringTable();
+ Expected<StringTable &> getStringTable();
BumpPtrAllocator &getAllocator() { return Allocator; }
std::unique_ptr<SymbolStream> Symbols;
std::unique_ptr<msf::MappedBlockStream> DirectoryStream;
std::unique_ptr<msf::MappedBlockStream> StringTableStream;
- std::unique_ptr<NameHashTable> StringTable;
+ std::unique_ptr<StringTable> Strings;
};
}
}
};
/// The header preceeding the /names stream.
-struct NameHashTableHeader {
+struct StringTableHeader {
support::ulittle32_t Signature;
support::ulittle32_t HashVersion;
support::ulittle32_t ByteSize;
};
-const uint32_t NameHashTableSignature = 0xEFFEEFFE;
+const uint32_t StringTableSignature = 0xEFFEEFFE;
} // namespace pdb
} // namespace llvm
-//===- NameHashTable.h - PDB Name Hash Table --------------------*- C++ -*-===//
+//===- StringTable.h - PDB String Table -------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_DEBUGINFO_PDB_RAW_NAMEHASHTABLE_H
-#define LLVM_DEBUGINFO_PDB_RAW_NAMEHASHTABLE_H
+#ifndef LLVM_DEBUGINFO_PDB_RAW_STRINGTABLE_H
+#define LLVM_DEBUGINFO_PDB_RAW_STRINGTABLE_H
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/StringRef.h"
}
namespace pdb {
-class NameHashTable {
+class StringTable {
public:
- NameHashTable();
+ StringTable();
Error load(msf::StreamReader &Stream);
} // end namespace pdb
} // end namespace llvm
-#endif // LLVM_DEBUGINFO_PDB_RAW_NAMEHASHTABLE_H
+#endif // LLVM_DEBUGINFO_PDB_RAW_STRINGTABLE_H
-//===- NameHashTableBuilder.h - PDB Name Hash Table Builder -----*- C++ -*-===//
+//===- StringTableBuilder.h - PDB String Table Builder ----------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_DEBUGINFO_PDB_RAW_NAMEHASHTABLEBUILDER_H
-#define LLVM_DEBUGINFO_PDB_RAW_NAMEHASHTABLEBUILDER_H
+#ifndef LLVM_DEBUGINFO_PDB_RAW_STRINGTABLEBUILDER_H
+#define LLVM_DEBUGINFO_PDB_RAW_STRINGTABLEBUILDER_H
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/StringRef.h"
}
namespace pdb {
-class NameHashTableBuilder {
+class StringTableBuilder {
public:
// If string S does not exist in the string table, insert it.
// Returns the ID for S.
} // end namespace pdb
} // end namespace llvm
-#endif // LLVM_DEBUGINFO_PDB_RAW_NAMEHASHTABLEBUILDER_H
+#endif // LLVM_DEBUGINFO_PDB_RAW_STRINGTABLEBUILDER_H
Raw/InfoStreamBuilder.cpp
Raw/ModInfo.cpp
Raw/ModStream.cpp
- Raw/NameHashTable.cpp
- Raw/NameHashTableBuilder.cpp
- Raw/NameMap.cpp
- Raw/NameMapBuilder.cpp
+ Raw/NamedStreamMap.cpp
+ Raw/NamedStreamMapBuilder.cpp
Raw/PDBFile.cpp
Raw/PDBFileBuilder.cpp
Raw/PublicsStream.cpp
Raw/RawError.cpp
Raw/RawSession.cpp
+ Raw/StringTable.cpp
+ Raw/StringTableBuilder.cpp
Raw/SymbolStream.cpp
Raw/TpiHashing.cpp
Raw/TpiStream.cpp
#include "llvm/DebugInfo/PDB/Raw/ISectionContribVisitor.h"
#include "llvm/DebugInfo/PDB/Raw/InfoStream.h"
#include "llvm/DebugInfo/PDB/Raw/ModInfo.h"
-#include "llvm/DebugInfo/PDB/Raw/NameHashTable.h"
#include "llvm/DebugInfo/PDB/Raw/PDBFile.h"
#include "llvm/DebugInfo/PDB/Raw/RawConstants.h"
#include "llvm/DebugInfo/PDB/Raw/RawError.h"
void InfoStreamBuilder::setGuid(PDB_UniqueId G) { Guid = G; }
-NameMapBuilder &InfoStreamBuilder::getNamedStreamsBuilder() {
+NamedStreamMapBuilder &InfoStreamBuilder::getNamedStreamsBuilder() {
return NamedStreams;
}
-//===- NameMap.cpp - PDB Name Map -------------------------------*- C++ -*-===//
+//===- NamedStreamMap.cpp - PDB Named Stream Map ----------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
//
//===----------------------------------------------------------------------===//
-#include "llvm/DebugInfo/PDB/Raw/NameMap.h"
+#include "llvm/DebugInfo/PDB/Raw/NamedStreamMap.h"
#include "llvm/ADT/SparseBitVector.h"
#include "llvm/ADT/StringMap.h"
using namespace llvm::msf;
using namespace llvm::pdb;
-NameMap::NameMap() = default;
+NamedStreamMap::NamedStreamMap() = default;
-Error NameMap::load(StreamReader &Stream) {
+Error NamedStreamMap::load(StreamReader &Stream) {
uint32_t StringBufferSize;
if (auto EC = Stream.readInteger(StringBufferSize))
return joinErrors(std::move(EC),
return Error::success();
}
-iterator_range<StringMapConstIterator<uint32_t>> NameMap::entries() const {
+iterator_range<StringMapConstIterator<uint32_t>>
+NamedStreamMap::entries() const {
return make_range<StringMapConstIterator<uint32_t>>(Mapping.begin(),
Mapping.end());
}
-bool NameMap::tryGetValue(StringRef Name, uint32_t &Value) const {
+bool NamedStreamMap::tryGetValue(StringRef Name, uint32_t &Value) const {
auto Iter = Mapping.find(Name);
if (Iter == Mapping.end())
return false;
-//===- NameMapBuilder.cpp - PDB Name Map Builder ----------------*- C++ -*-===//
+//===- NamedStreamMapBuilder.cpp - PDB Named Stream Map Builder -*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
//
//===----------------------------------------------------------------------===//
+#include "llvm/DebugInfo/PDB/Raw/NamedStreamMapBuilder.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/DebugInfo/MSF/StreamWriter.h"
-#include "llvm/DebugInfo/PDB/Raw/NameMap.h"
-#include "llvm/DebugInfo/PDB/Raw/NameMapBuilder.h"
+#include "llvm/DebugInfo/PDB/Raw/NamedStreamMap.h"
#include "llvm/Support/Endian.h"
#include "llvm/Support/Error.h"
#include <algorithm>
using namespace llvm;
using namespace llvm::pdb;
-NameMapBuilder::NameMapBuilder() = default;
+NamedStreamMapBuilder::NamedStreamMapBuilder() = default;
-void NameMapBuilder::addMapping(StringRef Name, uint32_t Mapping) {
+void NamedStreamMapBuilder::addMapping(StringRef Name, uint32_t Mapping) {
Strings.push_back(Name);
Map.set(Offset, Mapping);
Offset += Name.size() + 1;
}
-uint32_t NameMapBuilder::calculateSerializedLength() const {
+uint32_t NamedStreamMapBuilder::calculateSerializedLength() const {
uint32_t TotalLength = 0;
// Number of bytes of string data.
return TotalLength;
}
-Error NameMapBuilder::commit(msf::StreamWriter &Writer) const {
+Error NamedStreamMapBuilder::commit(msf::StreamWriter &Writer) const {
// The first field is the number of bytes of string data. We've already been
// keeping a running total of this in `Offset`.
if (auto EC = Writer.writeInteger(Offset)) // Number of bytes of string data
//
//===----------------------------------------------------------------------===//
+#include "llvm/DebugInfo/PDB/Raw/PDBFile.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/STLExtras.h"
-#include "llvm/DebugInfo/MSF/MappedBlockStream.h"
#include "llvm/DebugInfo/MSF/MSFCommon.h"
+#include "llvm/DebugInfo/MSF/MappedBlockStream.h"
#include "llvm/DebugInfo/MSF/StreamArray.h"
#include "llvm/DebugInfo/MSF/StreamInterface.h"
#include "llvm/DebugInfo/MSF/StreamReader.h"
#include "llvm/DebugInfo/PDB/Raw/DbiStream.h"
#include "llvm/DebugInfo/PDB/Raw/GlobalsStream.h"
#include "llvm/DebugInfo/PDB/Raw/InfoStream.h"
-#include "llvm/DebugInfo/PDB/Raw/NameHashTable.h"
-#include "llvm/DebugInfo/PDB/Raw/PDBFile.h"
#include "llvm/DebugInfo/PDB/Raw/PublicsStream.h"
#include "llvm/DebugInfo/PDB/Raw/RawError.h"
+#include "llvm/DebugInfo/PDB/Raw/StringTable.h"
#include "llvm/DebugInfo/PDB/Raw/SymbolStream.h"
#include "llvm/DebugInfo/PDB/Raw/TpiStream.h"
#include "llvm/Support/Endian.h"
return *Symbols;
}
-Expected<NameHashTable &> PDBFile::getStringTable() {
- if (!StringTable || !StringTableStream) {
+Expected<StringTable &> PDBFile::getStringTable() {
+ if (!Strings || !StringTableStream) {
auto IS = getPDBInfoStream();
if (!IS)
return IS.takeError();
if (!NS) return NS.takeError();
StreamReader Reader(**NS);
- auto N = llvm::make_unique<NameHashTable>();
+ auto N = llvm::make_unique<StringTable>();
if (auto EC = N->load(Reader))
return std::move(EC);
- StringTable = std::move(N);
+ Strings = std::move(N);
StringTableStream = std::move(*NS);
}
- return *StringTable;
+ return *Strings;
}
bool PDBFile::hasPDBDbiStream() const { return StreamDBI < getNumStreams(); }
-//===- NameHashTable.cpp - PDB Name Hash Table ------------------*- C++ -*-===//
+//===- StringTable.cpp - PDB String Table -----------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
//
//===----------------------------------------------------------------------===//
-#include "llvm/DebugInfo/PDB/Raw/NameHashTable.h"
+#include "llvm/DebugInfo/PDB/Raw/StringTable.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/DebugInfo/MSF/StreamReader.h"
using namespace llvm::support;
using namespace llvm::pdb;
-NameHashTable::NameHashTable() : Signature(0), HashVersion(0), NameCount(0) {}
+StringTable::StringTable() : Signature(0), HashVersion(0), NameCount(0) {}
-Error NameHashTable::load(StreamReader &Stream) {
- const NameHashTableHeader *H;
+Error StringTable::load(StreamReader &Stream) {
+ const StringTableHeader *H;
if (auto EC = Stream.readObject(H))
return EC;
- if (H->Signature != NameHashTableSignature)
+ if (H->Signature != StringTableSignature)
return make_error<RawError>(raw_error_code::corrupt_file,
"Invalid hash table signature");
if (H->HashVersion != 1 && H->HashVersion != 2)
return Error::success();
}
-StringRef NameHashTable::getStringForID(uint32_t ID) const {
+StringRef StringTable::getStringForID(uint32_t ID) const {
if (ID == IDs[0])
return StringRef();
return Result;
}
-uint32_t NameHashTable::getIDForString(StringRef Str) const {
+uint32_t StringTable::getIDForString(StringRef Str) const {
uint32_t Hash = (HashVersion == 1) ? hashStringV1(Str) : hashStringV2(Str);
size_t Count = IDs.size();
uint32_t Start = Hash % Count;
return IDs[0];
}
-FixedStreamArray<support::ulittle32_t> NameHashTable::name_ids() const {
+FixedStreamArray<support::ulittle32_t> StringTable::name_ids() const {
return IDs;
}
-//===- NameHashTable.cpp - PDB Name Hash Table ------------------*- C++ -*-===//
+//===- StringTableBuilder.cpp - PDB String Table ----------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
//
//===----------------------------------------------------------------------===//
-#include "llvm/DebugInfo/PDB/Raw/NameHashTableBuilder.h"
+#include "llvm/DebugInfo/PDB/Raw/StringTableBuilder.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/DebugInfo/MSF/StreamWriter.h"
#include "llvm/DebugInfo/PDB/Raw/Hash.h"
using namespace llvm::support::endian;
using namespace llvm::pdb;
-uint32_t NameHashTableBuilder::insert(StringRef S) {
+uint32_t StringTableBuilder::insert(StringRef S) {
auto P = Strings.insert({S, StringSize});
// If a given string didn't exist in the string table, we want to increment
return (NumStrings + 1) * 1.25;
}
-uint32_t NameHashTableBuilder::calculateSerializedLength() const {
+uint32_t StringTableBuilder::calculateSerializedLength() const {
uint32_t Size = 0;
- Size += sizeof(NameHashTableHeader);
+ Size += sizeof(StringTableHeader);
Size += StringSize;
Size += 4; // Hash table begins with 4-byte size field.
return Size;
}
-Error NameHashTableBuilder::commit(msf::StreamWriter &Writer) const {
+Error StringTableBuilder::commit(msf::StreamWriter &Writer) const {
// Write a header
- NameHashTableHeader H;
- H.Signature = NameHashTableSignature;
+ StringTableHeader H;
+ H.Signature = StringTableSignature;
H.HashVersion = 1;
H.ByteSize = StringSize;
if (auto EC = Writer.writeObject(H))
set(DebugInfoPDBSources
HashTableTest.cpp
MappedBlockStreamTest.cpp
- NameHashTableBuilderTest.cpp
+ StringTableBuilderTest.cpp
MSFBuilderTest.cpp
PDBApiTest.cpp
)
-//===- NameHashTableBuilderTest.cpp ---------------------------------------===//
+//===- StringTableBuilderTest.cpp -----------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
#include "llvm/DebugInfo/MSF/ByteStream.h"
#include "llvm/DebugInfo/MSF/StreamReader.h"
#include "llvm/DebugInfo/MSF/StreamWriter.h"
-#include "llvm/DebugInfo/PDB/Raw/NameHashTable.h"
-#include "llvm/DebugInfo/PDB/Raw/NameHashTableBuilder.h"
+#include "llvm/DebugInfo/PDB/Raw/StringTable.h"
+#include "llvm/DebugInfo/PDB/Raw/StringTableBuilder.h"
#include "gtest/gtest.h"
using namespace llvm::pdb;
namespace {
-class NameHashTableBuilderTest : public ::testing::Test {};
+class StringTableBuilderTest : public ::testing::Test {};
}
-TEST_F(NameHashTableBuilderTest, Simple) {
+TEST_F(StringTableBuilderTest, Simple) {
// Create /names table contents.
- NameHashTableBuilder Builder;
+ StringTableBuilder Builder;
EXPECT_EQ(1U, Builder.insert("foo"));
EXPECT_EQ(5U, Builder.insert("bar"));
EXPECT_EQ(1U, Builder.insert("foo"));
// Reads the contents back.
msf::ByteStream InStream(Buffer);
msf::StreamReader Reader(InStream);
- NameHashTable Table;
+ StringTable Table;
EXPECT_NO_ERROR(Table.load(Reader));
EXPECT_EQ(3U, Table.getNameCount());