[llvm] r301948 - Rename pdb::StringTable -> pdb::PDBStringTable.
Zachary Turner via llvm-commits
llvm-commits at lists.llvm.org
Tue May 2 11:00:14 PDT 2017
Author: zturner
Date: Tue May 2 13:00:13 2017
New Revision: 301948
URL: http://llvm.org/viewvc/llvm-project?rev=301948&view=rev
Log:
Rename pdb::StringTable -> pdb::PDBStringTable.
With the forthcoming codeview::StringTable which a pdb::StringTable
would hold an instance of as one member, this ambiguity becomes
confusing. Rename to PDBStringTable to avoid this.
Added:
llvm/trunk/include/llvm/DebugInfo/PDB/Native/PDBStringTable.h
llvm/trunk/include/llvm/DebugInfo/PDB/Native/PDBStringTableBuilder.h
llvm/trunk/lib/DebugInfo/PDB/Native/PDBStringTable.cpp
llvm/trunk/lib/DebugInfo/PDB/Native/PDBStringTableBuilder.cpp
Removed:
llvm/trunk/include/llvm/DebugInfo/PDB/Native/StringTable.h
llvm/trunk/include/llvm/DebugInfo/PDB/Native/StringTableBuilder.h
llvm/trunk/lib/DebugInfo/PDB/Native/StringTable.cpp
llvm/trunk/lib/DebugInfo/PDB/Native/StringTableBuilder.cpp
Modified:
llvm/trunk/include/llvm/DebugInfo/PDB/Native/DbiStream.h
llvm/trunk/include/llvm/DebugInfo/PDB/Native/PDBFile.h
llvm/trunk/include/llvm/DebugInfo/PDB/Native/PDBFileBuilder.h
llvm/trunk/include/llvm/DebugInfo/PDB/Native/RawTypes.h
llvm/trunk/lib/DebugInfo/PDB/CMakeLists.txt
llvm/trunk/lib/DebugInfo/PDB/Native/PDBFile.cpp
llvm/trunk/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp
llvm/trunk/tools/llvm-pdbdump/C13DebugFragmentVisitor.cpp
llvm/trunk/tools/llvm-pdbdump/Diff.cpp
llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp
llvm/trunk/unittests/DebugInfo/PDB/StringTableBuilderTest.cpp
Modified: llvm/trunk/include/llvm/DebugInfo/PDB/Native/DbiStream.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Native/DbiStream.h?rev=301948&r1=301947&r2=301948&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/Native/DbiStream.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/Native/DbiStream.h Tue May 2 13:00:13 2017
@@ -13,9 +13,9 @@
#include "llvm/DebugInfo/CodeView/ModuleDebugFragment.h"
#include "llvm/DebugInfo/MSF/MappedBlockStream.h"
#include "llvm/DebugInfo/PDB/Native/DbiModuleDescriptor.h"
+#include "llvm/DebugInfo/PDB/Native/PDBStringTable.h"
#include "llvm/DebugInfo/PDB/Native/RawConstants.h"
#include "llvm/DebugInfo/PDB/Native/RawTypes.h"
-#include "llvm/DebugInfo/PDB/Native/StringTable.h"
#include "llvm/DebugInfo/PDB/PDBTypes.h"
#include "llvm/Support/BinaryStreamArray.h"
#include "llvm/Support/BinaryStreamArray.h"
@@ -91,7 +91,7 @@ private:
std::unique_ptr<msf::MappedBlockStream> Stream;
std::vector<ModuleInfoEx> ModuleInfos;
- StringTable ECNames;
+ PDBStringTable ECNames;
BinaryStreamRef ModInfoSubstream;
BinaryStreamRef SecContrSubstream;
Modified: llvm/trunk/include/llvm/DebugInfo/PDB/Native/PDBFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Native/PDBFile.h?rev=301948&r1=301947&r2=301948&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/Native/PDBFile.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/Native/PDBFile.h Tue May 2 13:00:13 2017
@@ -33,7 +33,7 @@ namespace pdb {
class DbiStream;
class GlobalsStream;
class InfoStream;
-class StringTable;
+class PDBStringTable;
class PDBFileBuilder;
class PublicsStream;
class SymbolStream;
@@ -95,7 +95,7 @@ public:
Expected<TpiStream &> getPDBIpiStream();
Expected<PublicsStream &> getPDBPublicsStream();
Expected<SymbolStream &> getPDBSymbolStream();
- Expected<StringTable &> getStringTable();
+ Expected<PDBStringTable &> getStringTable();
BumpPtrAllocator &getAllocator() { return Allocator; }
@@ -106,7 +106,7 @@ public:
bool hasPDBPublicsStream();
bool hasPDBSymbolStream();
bool hasPDBTpiStream() const;
- bool hasStringTable();
+ bool hasPDBStringTable();
private:
Expected<std::unique_ptr<msf::MappedBlockStream>>
@@ -130,8 +130,8 @@ private:
std::unique_ptr<PublicsStream> Publics;
std::unique_ptr<SymbolStream> Symbols;
std::unique_ptr<msf::MappedBlockStream> DirectoryStream;
- std::unique_ptr<msf::MappedBlockStream> StringTableStream;
- std::unique_ptr<StringTable> Strings;
+ std::unique_ptr<msf::MappedBlockStream> PDBStringTableStream;
+ std::unique_ptr<PDBStringTable> Strings;
};
}
}
Modified: llvm/trunk/include/llvm/DebugInfo/PDB/Native/PDBFileBuilder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Native/PDBFileBuilder.h?rev=301948&r1=301947&r2=301948&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/Native/PDBFileBuilder.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/Native/PDBFileBuilder.h Tue May 2 13:00:13 2017
@@ -15,8 +15,8 @@
#include "llvm/ADT/Optional.h"
#include "llvm/DebugInfo/PDB/Native/NamedStreamMap.h"
#include "llvm/DebugInfo/PDB/Native/PDBFile.h"
+#include "llvm/DebugInfo/PDB/Native/PDBStringTableBuilder.h"
#include "llvm/DebugInfo/PDB/Native/RawConstants.h"
-#include "llvm/DebugInfo/PDB/Native/StringTableBuilder.h"
#include "llvm/Support/Allocator.h"
#include "llvm/Support/Endian.h"
#include "llvm/Support/Error.h"
@@ -46,7 +46,7 @@ public:
DbiStreamBuilder &getDbiBuilder();
TpiStreamBuilder &getTpiBuilder();
TpiStreamBuilder &getIpiBuilder();
- StringTableBuilder &getStringTableBuilder();
+ PDBStringTableBuilder &getStringTableBuilder();
Error commit(StringRef Filename);
@@ -62,7 +62,7 @@ private:
std::unique_ptr<TpiStreamBuilder> Tpi;
std::unique_ptr<TpiStreamBuilder> Ipi;
- StringTableBuilder Strings;
+ PDBStringTableBuilder Strings;
NamedStreamMap NamedStreams;
};
}
Added: llvm/trunk/include/llvm/DebugInfo/PDB/Native/PDBStringTable.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Native/PDBStringTable.h?rev=301948&view=auto
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/Native/PDBStringTable.h (added)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/Native/PDBStringTable.h Tue May 2 13:00:13 2017
@@ -0,0 +1,57 @@
+//===- PDBStringTable.h - PDB String Table -------------------------*- C++
+//-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_DEBUGINFO_PDB_RAW_PDBSTRINGTABLE_H
+#define LLVM_DEBUGINFO_PDB_RAW_PDBSTRINGTABLE_H
+
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/BinaryStreamArray.h"
+#include "llvm/Support/BinaryStreamRef.h"
+#include "llvm/Support/Endian.h"
+#include "llvm/Support/Error.h"
+#include <cstdint>
+#include <vector>
+
+namespace llvm {
+class BinaryStreamReader;
+
+namespace pdb {
+
+class PDBStringTable {
+public:
+ PDBStringTable();
+
+ Error load(BinaryStreamReader &Stream);
+
+ uint32_t getByteSize() const;
+
+ uint32_t getNameCount() const { return NameCount; }
+ uint32_t getHashVersion() const { return HashVersion; }
+ uint32_t getSignature() const { return Signature; }
+
+ StringRef getStringForID(uint32_t ID) const;
+ uint32_t getIDForString(StringRef Str) const;
+
+ FixedStreamArray<support::ulittle32_t> name_ids() const;
+
+private:
+ BinaryStreamRef NamesBuffer;
+ FixedStreamArray<support::ulittle32_t> IDs;
+ uint32_t ByteSize = 0;
+ uint32_t Signature = 0;
+ uint32_t HashVersion = 0;
+ uint32_t NameCount = 0;
+};
+
+} // end namespace pdb
+} // end namespace llvm
+
+#endif // LLVM_DEBUGINFO_PDB_RAW_STRINGTABLE_H
Added: llvm/trunk/include/llvm/DebugInfo/PDB/Native/PDBStringTableBuilder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Native/PDBStringTableBuilder.h?rev=301948&view=auto
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/Native/PDBStringTableBuilder.h (added)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/Native/PDBStringTableBuilder.h Tue May 2 13:00:13 2017
@@ -0,0 +1,45 @@
+//===- PDBStringTableBuilder.h - PDB String Table Builder -------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file creates the "/names" stream.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_DEBUGINFO_PDB_RAW_PDBSTRINGTABLEBUILDER_H
+#define LLVM_DEBUGINFO_PDB_RAW_PDBSTRINGTABLEBUILDER_H
+
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Error.h"
+#include <vector>
+
+namespace llvm {
+class BinaryStreamWriter;
+
+namespace pdb {
+
+class PDBStringTableBuilder {
+public:
+ // If string S does not exist in the string table, insert it.
+ // Returns the ID for S.
+ uint32_t insert(StringRef S);
+ uint32_t getStringIndex(StringRef S);
+
+ uint32_t finalize();
+ Error commit(BinaryStreamWriter &Writer) const;
+
+private:
+ DenseMap<StringRef, uint32_t> Strings;
+ uint32_t StringSize = 1;
+};
+
+} // end namespace pdb
+} // end namespace llvm
+
+#endif // LLVM_DEBUGINFO_PDB_RAW_PDBSTRINGTABLEBUILDER_H
Modified: llvm/trunk/include/llvm/DebugInfo/PDB/Native/RawTypes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Native/RawTypes.h?rev=301948&r1=301947&r2=301948&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/Native/RawTypes.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/Native/RawTypes.h Tue May 2 13:00:13 2017
@@ -307,13 +307,13 @@ struct InfoStreamHeader {
};
/// The header preceeding the /names stream.
-struct StringTableHeader {
+struct PDBStringTableHeader {
support::ulittle32_t Signature;
support::ulittle32_t HashVersion;
support::ulittle32_t ByteSize;
};
-const uint32_t StringTableSignature = 0xEFFEEFFE;
+const uint32_t PDBStringTableSignature = 0xEFFEEFFE;
} // namespace pdb
} // namespace llvm
Removed: llvm/trunk/include/llvm/DebugInfo/PDB/Native/StringTable.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Native/StringTable.h?rev=301947&view=auto
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/Native/StringTable.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/Native/StringTable.h (removed)
@@ -1,56 +0,0 @@
-//===- StringTable.h - PDB String Table -------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_DEBUGINFO_PDB_RAW_STRINGTABLE_H
-#define LLVM_DEBUGINFO_PDB_RAW_STRINGTABLE_H
-
-#include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/StringRef.h"
-#include "llvm/Support/BinaryStreamArray.h"
-#include "llvm/Support/BinaryStreamRef.h"
-#include "llvm/Support/Endian.h"
-#include "llvm/Support/Error.h"
-#include <cstdint>
-#include <vector>
-
-namespace llvm {
-class BinaryStreamReader;
-
-namespace pdb {
-
-class StringTable {
-public:
- StringTable();
-
- Error load(BinaryStreamReader &Stream);
-
- uint32_t getByteSize() const;
-
- uint32_t getNameCount() const { return NameCount; }
- uint32_t getHashVersion() const { return HashVersion; }
- uint32_t getSignature() const { return Signature; }
-
- StringRef getStringForID(uint32_t ID) const;
- uint32_t getIDForString(StringRef Str) const;
-
- FixedStreamArray<support::ulittle32_t> name_ids() const;
-
-private:
- BinaryStreamRef NamesBuffer;
- FixedStreamArray<support::ulittle32_t> IDs;
- uint32_t ByteSize = 0;
- uint32_t Signature = 0;
- uint32_t HashVersion = 0;
- uint32_t NameCount = 0;
-};
-
-} // end namespace pdb
-} // end namespace llvm
-
-#endif // LLVM_DEBUGINFO_PDB_RAW_STRINGTABLE_H
Removed: llvm/trunk/include/llvm/DebugInfo/PDB/Native/StringTableBuilder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Native/StringTableBuilder.h?rev=301947&view=auto
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/Native/StringTableBuilder.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/Native/StringTableBuilder.h (removed)
@@ -1,45 +0,0 @@
-//===- StringTableBuilder.h - PDB String Table Builder ----------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file creates the "/names" stream.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_DEBUGINFO_PDB_RAW_STRINGTABLEBUILDER_H
-#define LLVM_DEBUGINFO_PDB_RAW_STRINGTABLEBUILDER_H
-
-#include "llvm/ADT/DenseMap.h"
-#include "llvm/ADT/StringRef.h"
-#include "llvm/Support/Error.h"
-#include <vector>
-
-namespace llvm {
-class BinaryStreamWriter;
-
-namespace pdb {
-
-class StringTableBuilder {
-public:
- // If string S does not exist in the string table, insert it.
- // Returns the ID for S.
- uint32_t insert(StringRef S);
- uint32_t getStringIndex(StringRef S);
-
- uint32_t finalize();
- Error commit(BinaryStreamWriter &Writer) const;
-
-private:
- DenseMap<StringRef, uint32_t> Strings;
- uint32_t StringSize = 1;
-};
-
-} // end namespace pdb
-} // end namespace llvm
-
-#endif // LLVM_DEBUGINFO_PDB_RAW_STRINGTABLEBUILDER_H
Modified: llvm/trunk/lib/DebugInfo/PDB/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/CMakeLists.txt?rev=301948&r1=301947&r2=301948&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/CMakeLists.txt (original)
+++ llvm/trunk/lib/DebugInfo/PDB/CMakeLists.txt Tue May 2 13:00:13 2017
@@ -48,11 +48,11 @@ add_pdb_impl_folder(Native
Native/NativeSession.cpp
Native/PDBFile.cpp
Native/PDBFileBuilder.cpp
+ Native/PDBStringTable.cpp
+ Native/PDBStringTableBuilder.cpp
Native/PDBTypeServerHandler.cpp
Native/PublicsStream.cpp
Native/RawError.cpp
- Native/StringTable.cpp
- Native/StringTableBuilder.cpp
Native/SymbolStream.cpp
Native/TpiHashing.cpp
Native/TpiStream.cpp
Modified: llvm/trunk/lib/DebugInfo/PDB/Native/PDBFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Native/PDBFile.cpp?rev=301948&r1=301947&r2=301948&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/Native/PDBFile.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/Native/PDBFile.cpp Tue May 2 13:00:13 2017
@@ -15,9 +15,9 @@
#include "llvm/DebugInfo/PDB/Native/DbiStream.h"
#include "llvm/DebugInfo/PDB/Native/GlobalsStream.h"
#include "llvm/DebugInfo/PDB/Native/InfoStream.h"
+#include "llvm/DebugInfo/PDB/Native/PDBStringTable.h"
#include "llvm/DebugInfo/PDB/Native/PublicsStream.h"
#include "llvm/DebugInfo/PDB/Native/RawError.h"
-#include "llvm/DebugInfo/PDB/Native/StringTable.h"
#include "llvm/DebugInfo/PDB/Native/SymbolStream.h"
#include "llvm/DebugInfo/PDB/Native/TpiStream.h"
#include "llvm/Support/BinaryStream.h"
@@ -337,8 +337,8 @@ Expected<SymbolStream &> PDBFile::getPDB
return *Symbols;
}
-Expected<StringTable &> PDBFile::getStringTable() {
- if (!Strings || !StringTableStream) {
+Expected<PDBStringTable &> PDBFile::getStringTable() {
+ if (!Strings || !PDBStringTableStream) {
auto IS = getPDBInfoStream();
if (!IS)
return IS.takeError();
@@ -351,11 +351,11 @@ Expected<StringTable &> PDBFile::getStri
return NS.takeError();
BinaryStreamReader Reader(**NS);
- auto N = llvm::make_unique<StringTable>();
+ auto N = llvm::make_unique<PDBStringTable>();
if (auto EC = N->load(Reader))
return std::move(EC);
Strings = std::move(N);
- StringTableStream = std::move(*NS);
+ PDBStringTableStream = std::move(*NS);
}
return *Strings;
}
@@ -389,7 +389,7 @@ bool PDBFile::hasPDBSymbolStream() {
bool PDBFile::hasPDBTpiStream() const { return StreamTPI < getNumStreams(); }
-bool PDBFile::hasStringTable() {
+bool PDBFile::hasPDBStringTable() {
auto IS = getPDBInfoStream();
if (!IS)
return false;
Modified: llvm/trunk/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp?rev=301948&r1=301947&r2=301948&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp Tue May 2 13:00:13 2017
@@ -17,8 +17,8 @@
#include "llvm/DebugInfo/PDB/Native/DbiStreamBuilder.h"
#include "llvm/DebugInfo/PDB/Native/InfoStream.h"
#include "llvm/DebugInfo/PDB/Native/InfoStreamBuilder.h"
+#include "llvm/DebugInfo/PDB/Native/PDBStringTableBuilder.h"
#include "llvm/DebugInfo/PDB/Native/RawError.h"
-#include "llvm/DebugInfo/PDB/Native/StringTableBuilder.h"
#include "llvm/DebugInfo/PDB/Native/TpiStream.h"
#include "llvm/DebugInfo/PDB/Native/TpiStreamBuilder.h"
#include "llvm/Support/BinaryStream.h"
@@ -67,7 +67,9 @@ TpiStreamBuilder &PDBFileBuilder::getIpi
return *Ipi;
}
-StringTableBuilder &PDBFileBuilder::getStringTableBuilder() { return Strings; }
+PDBStringTableBuilder &PDBFileBuilder::getStringTableBuilder() {
+ return Strings;
+}
Error PDBFileBuilder::addNamedStream(StringRef Name, uint32_t Size) {
auto ExpectedStream = Msf->addStream(Size);
@@ -78,9 +80,9 @@ Error PDBFileBuilder::addNamedStream(Str
}
Expected<msf::MSFLayout> PDBFileBuilder::finalizeMsfLayout() {
- uint32_t StringTableSize = Strings.finalize();
+ uint32_t PDBStringTableSize = Strings.finalize();
- if (auto EC = addNamedStream("/names", StringTableSize))
+ if (auto EC = addNamedStream("/names", PDBStringTableSize))
return std::move(EC);
if (auto EC = addNamedStream("/LinkInfo", 0))
return std::move(EC);
@@ -144,12 +146,12 @@ Error PDBFileBuilder::commit(StringRef F
return EC;
}
- uint32_t StringTableStreamNo = 0;
- if (!NamedStreams.get("/names", StringTableStreamNo))
+ uint32_t PDBStringTableStreamNo = 0;
+ if (!NamedStreams.get("/names", PDBStringTableStreamNo))
return llvm::make_error<pdb::RawError>(raw_error_code::no_stream);
- auto NS = WritableMappedBlockStream::createIndexedStream(Layout, Buffer,
- StringTableStreamNo);
+ auto NS = WritableMappedBlockStream::createIndexedStream(
+ Layout, Buffer, PDBStringTableStreamNo);
BinaryStreamWriter NSWriter(*NS);
if (auto EC = Strings.commit(NSWriter))
return EC;
Added: llvm/trunk/lib/DebugInfo/PDB/Native/PDBStringTable.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Native/PDBStringTable.cpp?rev=301948&view=auto
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/Native/PDBStringTable.cpp (added)
+++ llvm/trunk/lib/DebugInfo/PDB/Native/PDBStringTable.cpp Tue May 2 13:00:13 2017
@@ -0,0 +1,108 @@
+//===- PDBStringTable.cpp - PDB String Table -----------------------*- 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/Native/PDBStringTable.h"
+
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/DebugInfo/PDB/Native/Hash.h"
+#include "llvm/DebugInfo/PDB/Native/RawError.h"
+#include "llvm/DebugInfo/PDB/Native/RawTypes.h"
+#include "llvm/Support/BinaryStreamReader.h"
+#include "llvm/Support/Endian.h"
+
+using namespace llvm;
+using namespace llvm::support;
+using namespace llvm::pdb;
+
+PDBStringTable::PDBStringTable() {}
+
+Error PDBStringTable::load(BinaryStreamReader &Stream) {
+ ByteSize = Stream.getLength();
+
+ const PDBStringTableHeader *H;
+ if (auto EC = Stream.readObject(H))
+ return EC;
+
+ if (H->Signature != PDBStringTableSignature)
+ return make_error<RawError>(raw_error_code::corrupt_file,
+ "Invalid hash table signature");
+ if (H->HashVersion != 1 && H->HashVersion != 2)
+ return make_error<RawError>(raw_error_code::corrupt_file,
+ "Unsupported hash version");
+
+ Signature = H->Signature;
+ HashVersion = H->HashVersion;
+ if (auto EC = Stream.readStreamRef(NamesBuffer, H->ByteSize))
+ return joinErrors(std::move(EC),
+ make_error<RawError>(raw_error_code::corrupt_file,
+ "Invalid hash table byte length"));
+
+ const support::ulittle32_t *HashCount;
+ if (auto EC = Stream.readObject(HashCount))
+ return EC;
+
+ if (auto EC = Stream.readArray(IDs, *HashCount))
+ return joinErrors(std::move(EC),
+ make_error<RawError>(raw_error_code::corrupt_file,
+ "Could not read bucket array"));
+
+ if (Stream.bytesRemaining() < sizeof(support::ulittle32_t))
+ return make_error<RawError>(raw_error_code::corrupt_file,
+ "Missing name count");
+
+ if (auto EC = Stream.readInteger(NameCount))
+ return EC;
+
+ if (Stream.bytesRemaining() > 0)
+ return make_error<RawError>(raw_error_code::stream_too_long,
+ "Unexpected bytes found in string table");
+
+ return Error::success();
+}
+
+uint32_t PDBStringTable::getByteSize() const { return ByteSize; }
+
+StringRef PDBStringTable::getStringForID(uint32_t ID) const {
+ if (ID == IDs[0])
+ return StringRef();
+
+ // NamesBuffer is a buffer of null terminated strings back to back. ID is
+ // the starting offset of the string we're looking for. So just seek into
+ // the desired offset and a read a null terminated stream from that offset.
+ StringRef Result;
+ BinaryStreamReader NameReader(NamesBuffer);
+ NameReader.setOffset(ID);
+ if (auto EC = NameReader.readCString(Result))
+ consumeError(std::move(EC));
+ return Result;
+}
+
+uint32_t PDBStringTable::getIDForString(StringRef Str) const {
+ uint32_t Hash = (HashVersion == 1) ? hashStringV1(Str) : hashStringV2(Str);
+ size_t Count = IDs.size();
+ uint32_t Start = Hash % Count;
+ for (size_t I = 0; I < Count; ++I) {
+ // The hash is just a starting point for the search, but if it
+ // doesn't work we should find the string no matter what, because
+ // we iterate the entire array.
+ uint32_t Index = (Start + I) % Count;
+
+ uint32_t ID = IDs[Index];
+ StringRef S = getStringForID(ID);
+ if (S == Str)
+ return ID;
+ }
+ // IDs[0] contains the ID of the "invalid" entry.
+ return IDs[0];
+}
+
+FixedStreamArray<support::ulittle32_t> PDBStringTable::name_ids() const {
+ return IDs;
+}
Added: llvm/trunk/lib/DebugInfo/PDB/Native/PDBStringTableBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Native/PDBStringTableBuilder.cpp?rev=301948&view=auto
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/Native/PDBStringTableBuilder.cpp (added)
+++ llvm/trunk/lib/DebugInfo/PDB/Native/PDBStringTableBuilder.cpp Tue May 2 13:00:13 2017
@@ -0,0 +1,108 @@
+//===- PDBStringTableBuilder.cpp - PDB String Table -------------*- 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/Native/PDBStringTableBuilder.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/DebugInfo/PDB/Native/Hash.h"
+#include "llvm/DebugInfo/PDB/Native/RawTypes.h"
+#include "llvm/Support/BinaryStreamWriter.h"
+#include "llvm/Support/Endian.h"
+
+using namespace llvm;
+using namespace llvm::support;
+using namespace llvm::support::endian;
+using namespace llvm::pdb;
+
+uint32_t PDBStringTableBuilder::insert(StringRef S) {
+ auto P = Strings.insert({S, StringSize});
+
+ // If a given string didn't exist in the string table, we want to increment
+ // the string table size.
+ if (P.second)
+ StringSize += S.size() + 1; // +1 for '\0'
+ return P.first->second;
+}
+
+uint32_t PDBStringTableBuilder::getStringIndex(StringRef S) {
+ auto Iter = Strings.find(S);
+ assert(Iter != Strings.end());
+ return Iter->second;
+}
+
+static uint32_t computeBucketCount(uint32_t NumStrings) {
+ // The /names stream is basically an on-disk open-addressing hash table.
+ // Hash collisions are resolved by linear probing. We cannot make
+ // utilization 100% because it will make the linear probing extremely
+ // slow. But lower utilization wastes disk space. As a reasonable
+ // load factor, we choose 80%. We need +1 because slot 0 is reserved.
+ return (NumStrings + 1) * 1.25;
+}
+
+uint32_t PDBStringTableBuilder::finalize() {
+ uint32_t Size = 0;
+ Size += sizeof(PDBStringTableHeader);
+ Size += StringSize;
+ Size += sizeof(uint32_t); // Hash table begins with 4-byte size field.
+
+ uint32_t BucketCount = computeBucketCount(Strings.size());
+ Size += BucketCount * sizeof(uint32_t);
+
+ Size +=
+ sizeof(uint32_t); // The /names stream ends with the number of strings.
+ return Size;
+}
+
+Error PDBStringTableBuilder::commit(BinaryStreamWriter &Writer) const {
+ // Write a header
+ PDBStringTableHeader H;
+ H.Signature = PDBStringTableSignature;
+ H.HashVersion = 1;
+ H.ByteSize = StringSize;
+ if (auto EC = Writer.writeObject(H))
+ return EC;
+
+ // Write a string table.
+ uint32_t StringStart = Writer.getOffset();
+ for (auto Pair : Strings) {
+ StringRef S = Pair.first;
+ uint32_t Offset = Pair.second;
+ Writer.setOffset(StringStart + Offset);
+ if (auto EC = Writer.writeCString(S))
+ return EC;
+ }
+ Writer.setOffset(StringStart + StringSize);
+
+ // Write a hash table.
+ uint32_t BucketCount = computeBucketCount(Strings.size());
+ if (auto EC = Writer.writeInteger(BucketCount))
+ return EC;
+ std::vector<ulittle32_t> Buckets(BucketCount);
+
+ for (auto Pair : Strings) {
+ StringRef S = Pair.first;
+ uint32_t Offset = Pair.second;
+ uint32_t Hash = hashStringV1(S);
+
+ for (uint32_t I = 0; I != BucketCount; ++I) {
+ uint32_t Slot = (Hash + I) % BucketCount;
+ if (Slot == 0)
+ continue; // Skip reserved slot
+ if (Buckets[Slot] != 0)
+ continue;
+ Buckets[Slot] = Offset;
+ break;
+ }
+ }
+
+ if (auto EC = Writer.writeArray(ArrayRef<ulittle32_t>(Buckets)))
+ return EC;
+ if (auto EC = Writer.writeInteger(static_cast<uint32_t>(Strings.size())))
+ return EC;
+ return Error::success();
+}
Removed: llvm/trunk/lib/DebugInfo/PDB/Native/StringTable.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Native/StringTable.cpp?rev=301947&view=auto
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/Native/StringTable.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/Native/StringTable.cpp (removed)
@@ -1,109 +0,0 @@
-//===- StringTable.cpp - PDB String Table -----------------------*- 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/Native/StringTable.h"
-
-#include "llvm/ADT/ArrayRef.h"
-#include "llvm/DebugInfo/PDB/Native/Hash.h"
-#include "llvm/DebugInfo/PDB/Native/RawError.h"
-#include "llvm/DebugInfo/PDB/Native/RawTypes.h"
-#include "llvm/Support/BinaryStreamReader.h"
-#include "llvm/Support/Endian.h"
-
-using namespace llvm;
-using namespace llvm::support;
-using namespace llvm::pdb;
-
-StringTable::StringTable() {}
-
-Error StringTable::load(BinaryStreamReader &Stream) {
- ByteSize = Stream.getLength();
-
- const StringTableHeader *H;
- if (auto EC = Stream.readObject(H))
- return EC;
-
- 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 make_error<RawError>(raw_error_code::corrupt_file,
- "Unsupported hash version");
-
- Signature = H->Signature;
- HashVersion = H->HashVersion;
- if (auto EC = Stream.readStreamRef(NamesBuffer, H->ByteSize))
- return joinErrors(std::move(EC),
- make_error<RawError>(raw_error_code::corrupt_file,
- "Invalid hash table byte length"));
-
- const support::ulittle32_t *HashCount;
- if (auto EC = Stream.readObject(HashCount))
- return EC;
-
- if (auto EC = Stream.readArray(IDs, *HashCount))
- return joinErrors(std::move(EC),
- make_error<RawError>(raw_error_code::corrupt_file,
- "Could not read bucket array"));
-
- if (Stream.bytesRemaining() < sizeof(support::ulittle32_t))
- return make_error<RawError>(raw_error_code::corrupt_file,
- "Missing name count");
-
- if (auto EC = Stream.readInteger(NameCount))
- return EC;
-
- if (Stream.bytesRemaining() > 0)
- return make_error<RawError>(raw_error_code::stream_too_long,
- "Unexpected bytes found in string table");
-
- return Error::success();
-}
-
-uint32_t StringTable::getByteSize() const {
- return ByteSize;
-}
-
-StringRef StringTable::getStringForID(uint32_t ID) const {
- if (ID == IDs[0])
- return StringRef();
-
- // NamesBuffer is a buffer of null terminated strings back to back. ID is
- // the starting offset of the string we're looking for. So just seek into
- // the desired offset and a read a null terminated stream from that offset.
- StringRef Result;
- BinaryStreamReader NameReader(NamesBuffer);
- NameReader.setOffset(ID);
- if (auto EC = NameReader.readCString(Result))
- consumeError(std::move(EC));
- return Result;
-}
-
-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;
- for (size_t I = 0; I < Count; ++I) {
- // The hash is just a starting point for the search, but if it
- // doesn't work we should find the string no matter what, because
- // we iterate the entire array.
- uint32_t Index = (Start + I) % Count;
-
- uint32_t ID = IDs[Index];
- StringRef S = getStringForID(ID);
- if (S == Str)
- return ID;
- }
- // IDs[0] contains the ID of the "invalid" entry.
- return IDs[0];
-}
-
-FixedStreamArray<support::ulittle32_t> StringTable::name_ids() const {
- return IDs;
-}
Removed: llvm/trunk/lib/DebugInfo/PDB/Native/StringTableBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Native/StringTableBuilder.cpp?rev=301947&view=auto
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/Native/StringTableBuilder.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/Native/StringTableBuilder.cpp (removed)
@@ -1,108 +0,0 @@
-//===- StringTableBuilder.cpp - PDB String Table ----------------*- 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/Native/StringTableBuilder.h"
-#include "llvm/ADT/ArrayRef.h"
-#include "llvm/DebugInfo/PDB/Native/Hash.h"
-#include "llvm/DebugInfo/PDB/Native/RawTypes.h"
-#include "llvm/Support/BinaryStreamWriter.h"
-#include "llvm/Support/Endian.h"
-
-using namespace llvm;
-using namespace llvm::support;
-using namespace llvm::support::endian;
-using namespace llvm::pdb;
-
-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
- // the string table size.
- if (P.second)
- StringSize += S.size() + 1; // +1 for '\0'
- return P.first->second;
-}
-
-uint32_t StringTableBuilder::getStringIndex(StringRef S) {
- auto Iter = Strings.find(S);
- assert(Iter != Strings.end());
- return Iter->second;
-}
-
-static uint32_t computeBucketCount(uint32_t NumStrings) {
- // The /names stream is basically an on-disk open-addressing hash table.
- // Hash collisions are resolved by linear probing. We cannot make
- // utilization 100% because it will make the linear probing extremely
- // slow. But lower utilization wastes disk space. As a reasonable
- // load factor, we choose 80%. We need +1 because slot 0 is reserved.
- return (NumStrings + 1) * 1.25;
-}
-
-uint32_t StringTableBuilder::finalize() {
- uint32_t Size = 0;
- Size += sizeof(StringTableHeader);
- Size += StringSize;
- Size += sizeof(uint32_t); // Hash table begins with 4-byte size field.
-
- uint32_t BucketCount = computeBucketCount(Strings.size());
- Size += BucketCount * sizeof(uint32_t);
-
- Size +=
- sizeof(uint32_t); // The /names stream ends with the number of strings.
- return Size;
-}
-
-Error StringTableBuilder::commit(BinaryStreamWriter &Writer) const {
- // Write a header
- StringTableHeader H;
- H.Signature = StringTableSignature;
- H.HashVersion = 1;
- H.ByteSize = StringSize;
- if (auto EC = Writer.writeObject(H))
- return EC;
-
- // Write a string table.
- uint32_t StringStart = Writer.getOffset();
- for (auto Pair : Strings) {
- StringRef S = Pair.first;
- uint32_t Offset = Pair.second;
- Writer.setOffset(StringStart + Offset);
- if (auto EC = Writer.writeCString(S))
- return EC;
- }
- Writer.setOffset(StringStart + StringSize);
-
- // Write a hash table.
- uint32_t BucketCount = computeBucketCount(Strings.size());
- if (auto EC = Writer.writeInteger(BucketCount))
- return EC;
- std::vector<ulittle32_t> Buckets(BucketCount);
-
- for (auto Pair : Strings) {
- StringRef S = Pair.first;
- uint32_t Offset = Pair.second;
- uint32_t Hash = hashStringV1(S);
-
- for (uint32_t I = 0; I != BucketCount; ++I) {
- uint32_t Slot = (Hash + I) % BucketCount;
- if (Slot == 0)
- continue; // Skip reserved slot
- if (Buckets[Slot] != 0)
- continue;
- Buckets[Slot] = Offset;
- break;
- }
- }
-
- if (auto EC = Writer.writeArray(ArrayRef<ulittle32_t>(Buckets)))
- return EC;
- if (auto EC = Writer.writeInteger(static_cast<uint32_t>(Strings.size())))
- return EC;
- return Error::success();
-}
Modified: llvm/trunk/tools/llvm-pdbdump/C13DebugFragmentVisitor.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbdump/C13DebugFragmentVisitor.cpp?rev=301948&r1=301947&r2=301948&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-pdbdump/C13DebugFragmentVisitor.cpp (original)
+++ llvm/trunk/tools/llvm-pdbdump/C13DebugFragmentVisitor.cpp Tue May 2 13:00:13 2017
@@ -13,8 +13,8 @@
#include "llvm/DebugInfo/CodeView/ModuleDebugInlineeLinesFragment.h"
#include "llvm/DebugInfo/CodeView/ModuleDebugLineFragment.h"
#include "llvm/DebugInfo/PDB/Native/PDBFile.h"
+#include "llvm/DebugInfo/PDB/Native/PDBStringTable.h"
#include "llvm/DebugInfo/PDB/Native/RawError.h"
-#include "llvm/DebugInfo/PDB/Native/StringTable.h"
using namespace llvm;
using namespace llvm::codeview;
Modified: llvm/trunk/tools/llvm-pdbdump/Diff.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbdump/Diff.cpp?rev=301948&r1=301947&r2=301948&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-pdbdump/Diff.cpp (original)
+++ llvm/trunk/tools/llvm-pdbdump/Diff.cpp Tue May 2 13:00:13 2017
@@ -15,8 +15,8 @@
#include "llvm/DebugInfo/PDB/Native/Formatters.h"
#include "llvm/DebugInfo/PDB/Native/InfoStream.h"
#include "llvm/DebugInfo/PDB/Native/PDBFile.h"
+#include "llvm/DebugInfo/PDB/Native/PDBStringTable.h"
#include "llvm/DebugInfo/PDB/Native/RawConstants.h"
-#include "llvm/DebugInfo/PDB/Native/StringTable.h"
#include "llvm/Support/FormatAdapters.h"
#include "llvm/Support/FormatProviders.h"
Modified: llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp?rev=301948&r1=301947&r2=301948&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp (original)
+++ llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp Tue May 2 13:00:13 2017
@@ -47,9 +47,9 @@
#include "llvm/DebugInfo/PDB/Native/NativeSession.h"
#include "llvm/DebugInfo/PDB/Native/PDBFile.h"
#include "llvm/DebugInfo/PDB/Native/PDBFileBuilder.h"
+#include "llvm/DebugInfo/PDB/Native/PDBStringTableBuilder.h"
#include "llvm/DebugInfo/PDB/Native/RawConstants.h"
#include "llvm/DebugInfo/PDB/Native/RawError.h"
-#include "llvm/DebugInfo/PDB/Native/StringTableBuilder.h"
#include "llvm/DebugInfo/PDB/Native/TpiStream.h"
#include "llvm/DebugInfo/PDB/Native/TpiStreamBuilder.h"
#include "llvm/DebugInfo/PDB/PDB.h"
@@ -427,7 +427,7 @@ static ExitOnError ExitOnErr;
static uint32_t
getFileChecksumOffset(StringRef FileName,
ModuleDebugFileChecksumFragment &Checksums,
- StringTableBuilder &Strings) {
+ PDBStringTableBuilder &Strings) {
// The offset in the line info record is the offset of the checksum
// entry for the corresponding file. That entry then contains an
// offset into the global string table of the file name. So to
Modified: llvm/trunk/unittests/DebugInfo/PDB/StringTableBuilderTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/DebugInfo/PDB/StringTableBuilderTest.cpp?rev=301948&r1=301947&r2=301948&view=diff
==============================================================================
--- llvm/trunk/unittests/DebugInfo/PDB/StringTableBuilderTest.cpp (original)
+++ llvm/trunk/unittests/DebugInfo/PDB/StringTableBuilderTest.cpp Tue May 2 13:00:13 2017
@@ -9,8 +9,8 @@
#include "ErrorChecking.h"
-#include "llvm/DebugInfo/PDB/Native/StringTable.h"
-#include "llvm/DebugInfo/PDB/Native/StringTableBuilder.h"
+#include "llvm/DebugInfo/PDB/Native/PDBStringTable.h"
+#include "llvm/DebugInfo/PDB/Native/PDBStringTableBuilder.h"
#include "llvm/Support/BinaryByteStream.h"
#include "llvm/Support/BinaryStreamReader.h"
#include "llvm/Support/BinaryStreamWriter.h"
@@ -27,7 +27,7 @@ class StringTableBuilderTest : public ::
TEST_F(StringTableBuilderTest, Simple) {
// Create /names table contents.
- StringTableBuilder Builder;
+ PDBStringTableBuilder Builder;
EXPECT_EQ(1U, Builder.insert("foo"));
EXPECT_EQ(5U, Builder.insert("bar"));
EXPECT_EQ(1U, Builder.insert("foo"));
@@ -41,7 +41,7 @@ TEST_F(StringTableBuilderTest, Simple) {
// Reads the contents back.
BinaryByteStream InStream(Buffer, little);
BinaryStreamReader Reader(InStream);
- StringTable Table;
+ PDBStringTable Table;
EXPECT_NO_ERROR(Table.load(Reader));
EXPECT_EQ(3U, Table.getNameCount());
More information about the llvm-commits
mailing list