summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/DebugInfo/CodeView/CVTypeVisitor.cpp77
-rw-r--r--llvm/lib/DebugInfo/CodeView/TypeStreamMerger.cpp32
-rw-r--r--llvm/lib/DebugInfo/PDB/CMakeLists.txt1
-rw-r--r--llvm/lib/DebugInfo/PDB/Native/PDBTypeServerHandler.cpp125
-rw-r--r--llvm/lib/DebugInfo/PDB/Native/TpiStream.cpp1
5 files changed, 19 insertions, 217 deletions
diff --git a/llvm/lib/DebugInfo/CodeView/CVTypeVisitor.cpp b/llvm/lib/DebugInfo/CodeView/CVTypeVisitor.cpp
index 22f166a2335..79b9fdefd40 100644
--- a/llvm/lib/DebugInfo/CodeView/CVTypeVisitor.cpp
+++ b/llvm/lib/DebugInfo/CodeView/CVTypeVisitor.cpp
@@ -14,7 +14,6 @@
#include "llvm/DebugInfo/CodeView/TypeCollection.h"
#include "llvm/DebugInfo/CodeView/TypeDeserializer.h"
#include "llvm/DebugInfo/CodeView/TypeRecordMapping.h"
-#include "llvm/DebugInfo/CodeView/TypeServerHandler.h"
#include "llvm/DebugInfo/CodeView/TypeVisitorCallbackPipeline.h"
#include "llvm/Support/BinaryByteStream.h"
#include "llvm/Support/BinaryStreamReader.h"
@@ -42,13 +41,6 @@ static Error visitKnownMember(CVMemberRecord &Record,
return Error::success();
}
-static Expected<TypeServer2Record> deserializeTypeServerRecord(CVType &Record) {
- TypeServer2Record R(TypeRecordKind::TypeServer2);
- if (auto EC = TypeDeserializer::deserializeAs(Record, R))
- return std::move(EC);
- return R;
-}
-
static Error visitMemberRecord(CVMemberRecord &Record,
TypeVisitorCallbacks &Callbacks) {
if (auto EC = Callbacks.visitMemberBegin(Record))
@@ -84,8 +76,6 @@ class CVTypeVisitor {
public:
explicit CVTypeVisitor(TypeVisitorCallbacks &Callbacks);
- void addTypeServerHandler(TypeServerHandler &Handler);
-
Error visitTypeRecord(CVType &Record, TypeIndex Index);
Error visitTypeRecord(CVType &Record);
@@ -98,45 +88,15 @@ public:
Error visitFieldListMemberStream(BinaryStreamReader &Stream);
private:
- Expected<bool> handleTypeServer(CVType &Record);
Error finishVisitation(CVType &Record);
/// The interface to the class that gets notified of each visitation.
TypeVisitorCallbacks &Callbacks;
-
- TinyPtrVector<TypeServerHandler *> Handlers;
};
CVTypeVisitor::CVTypeVisitor(TypeVisitorCallbacks &Callbacks)
: Callbacks(Callbacks) {}
-void CVTypeVisitor::addTypeServerHandler(TypeServerHandler &Handler) {
- Handlers.push_back(&Handler);
-}
-
-Expected<bool> CVTypeVisitor::handleTypeServer(CVType &Record) {
- if (Record.Type == TypeLeafKind::LF_TYPESERVER2 && !Handlers.empty()) {
- auto TS = deserializeTypeServerRecord(Record);
- if (!TS)
- return TS.takeError();
-
- for (auto Handler : Handlers) {
- auto ExpectedResult = Handler->handle(*TS, Callbacks);
- // If there was an error, return the error.
- if (!ExpectedResult)
- return ExpectedResult.takeError();
-
- // If the handler processed the record, return success.
- if (*ExpectedResult)
- return true;
-
- // Otherwise keep searching for a handler, eventually falling out and
- // using the default record handler.
- }
- }
- return false;
-}
-
Error CVTypeVisitor::finishVisitation(CVType &Record) {
switch (Record.Type) {
default:
@@ -163,12 +123,6 @@ Error CVTypeVisitor::finishVisitation(CVType &Record) {
}
Error CVTypeVisitor::visitTypeRecord(CVType &Record, TypeIndex Index) {
- auto ExpectedResult = handleTypeServer(Record);
- if (!ExpectedResult)
- return ExpectedResult.takeError();
- if (*ExpectedResult)
- return Error::success();
-
if (auto EC = Callbacks.visitTypeBegin(Record, Index))
return EC;
@@ -176,12 +130,6 @@ Error CVTypeVisitor::visitTypeRecord(CVType &Record, TypeIndex Index) {
}
Error CVTypeVisitor::visitTypeRecord(CVType &Record) {
- auto ExpectedResult = handleTypeServer(Record);
- if (!ExpectedResult)
- return ExpectedResult.takeError();
- if (*ExpectedResult)
- return Error::success();
-
if (auto EC = Callbacks.visitTypeBegin(Record))
return EC;
@@ -271,52 +219,37 @@ struct VisitHelper {
Error llvm::codeview::visitTypeRecord(CVType &Record, TypeIndex Index,
TypeVisitorCallbacks &Callbacks,
- VisitorDataSource Source,
- TypeServerHandler *TS) {
+ VisitorDataSource Source) {
VisitHelper V(Callbacks, Source);
- if (TS)
- V.Visitor.addTypeServerHandler(*TS);
return V.Visitor.visitTypeRecord(Record, Index);
}
Error llvm::codeview::visitTypeRecord(CVType &Record,
TypeVisitorCallbacks &Callbacks,
- VisitorDataSource Source,
- TypeServerHandler *TS) {
+ VisitorDataSource Source) {
VisitHelper V(Callbacks, Source);
- if (TS)
- V.Visitor.addTypeServerHandler(*TS);
return V.Visitor.visitTypeRecord(Record);
}
Error llvm::codeview::visitTypeStream(const CVTypeArray &Types,
TypeVisitorCallbacks &Callbacks,
- VisitorDataSource Source,
- TypeServerHandler *TS) {
+ VisitorDataSource Source) {
VisitHelper V(Callbacks, Source);
- if (TS)
- V.Visitor.addTypeServerHandler(*TS);
return V.Visitor.visitTypeStream(Types);
}
Error llvm::codeview::visitTypeStream(CVTypeRange Types,
- TypeVisitorCallbacks &Callbacks,
- TypeServerHandler *TS) {
+ TypeVisitorCallbacks &Callbacks) {
VisitHelper V(Callbacks, VDS_BytesPresent);
- if (TS)
- V.Visitor.addTypeServerHandler(*TS);
return V.Visitor.visitTypeStream(Types);
}
Error llvm::codeview::visitTypeStream(TypeCollection &Types,
- TypeVisitorCallbacks &Callbacks,
- TypeServerHandler *TS) {
+ TypeVisitorCallbacks &Callbacks) {
// When the internal visitor calls Types.getType(Index) the interface is
// required to return a CVType with the bytes filled out. So we can assume
// that the bytes will be present when individual records are visited.
VisitHelper V(Callbacks, VDS_BytesPresent);
- if (TS)
- V.Visitor.addTypeServerHandler(*TS);
return V.Visitor.visitTypeStream(Types);
}
diff --git a/llvm/lib/DebugInfo/CodeView/TypeStreamMerger.cpp b/llvm/lib/DebugInfo/CodeView/TypeStreamMerger.cpp
index b21ea5975b5..8d4887c56b0 100644
--- a/llvm/lib/DebugInfo/CodeView/TypeStreamMerger.cpp
+++ b/llvm/lib/DebugInfo/CodeView/TypeStreamMerger.cpp
@@ -59,9 +59,8 @@ namespace {
/// looking at the record kind.
class TypeStreamMerger : public TypeVisitorCallbacks {
public:
- explicit TypeStreamMerger(SmallVectorImpl<TypeIndex> &SourceToDest,
- TypeServerHandler *Handler)
- : Handler(Handler), IndexMap(SourceToDest) {
+ explicit TypeStreamMerger(SmallVectorImpl<TypeIndex> &SourceToDest)
+ : IndexMap(SourceToDest) {
SourceToDest.clear();
}
@@ -71,10 +70,10 @@ public:
Error visitTypeEnd(CVType &Record) override;
Error mergeTypesAndIds(TypeTableBuilder &DestIds, TypeTableBuilder &DestTypes,
- const CVTypeArray &IdsAndTypes);
+ const CVTypeArray &IdsAndTypes);
Error mergeIdRecords(TypeTableBuilder &Dest,
ArrayRef<TypeIndex> TypeSourceToDest,
- const CVTypeArray &Ids);
+ const CVTypeArray &Ids);
Error mergeTypeRecords(TypeTableBuilder &Dest, const CVTypeArray &Types);
private:
@@ -153,7 +152,6 @@ private:
TypeTableBuilder *DestIdStream = nullptr;
TypeTableBuilder *DestTypeStream = nullptr;
- TypeServerHandler *Handler = nullptr;
// If we're only mapping id records, this array contains the mapping for
// type records.
@@ -256,7 +254,7 @@ bool TypeStreamMerger::remapItemIndex(TypeIndex &Idx) {
}
Error TypeStreamMerger::mergeTypeRecords(TypeTableBuilder &Dest,
- const CVTypeArray &Types) {
+ const CVTypeArray &Types) {
DestTypeStream = &Dest;
return doit(Types);
@@ -264,7 +262,7 @@ Error TypeStreamMerger::mergeTypeRecords(TypeTableBuilder &Dest,
Error TypeStreamMerger::mergeIdRecords(TypeTableBuilder &Dest,
ArrayRef<TypeIndex> TypeSourceToDest,
- const CVTypeArray &Ids) {
+ const CVTypeArray &Ids) {
DestIdStream = &Dest;
TypeLookup = TypeSourceToDest;
@@ -288,7 +286,7 @@ Error TypeStreamMerger::doit(const CVTypeArray &Types) {
// would buy us much since it's already pretty fast, but it's probably worth
// a few cycles.
if (auto EC =
- codeview::visitTypeStream(Types, *this, VDS_BytesExternal, Handler))
+ codeview::visitTypeStream(Types, *this, VDS_BytesExternal))
return EC;
// If we found bad indices but no other errors, try doing another pass and see
@@ -305,7 +303,7 @@ Error TypeStreamMerger::doit(const CVTypeArray &Types) {
CurIndex = TypeIndex(TypeIndex::FirstNonSimpleIndex);
if (auto EC =
- codeview::visitTypeStream(Types, *this, VDS_BytesExternal, Handler))
+ codeview::visitTypeStream(Types, *this, VDS_BytesExternal))
return EC;
assert(NumBadIndices <= BadIndicesRemaining &&
@@ -323,24 +321,22 @@ Error TypeStreamMerger::doit(const CVTypeArray &Types) {
Error llvm::codeview::mergeTypeRecords(TypeTableBuilder &Dest,
SmallVectorImpl<TypeIndex> &SourceToDest,
- TypeServerHandler *Handler,
- const CVTypeArray &Types) {
- TypeStreamMerger M(SourceToDest, Handler);
+ const CVTypeArray &Types) {
+ TypeStreamMerger M(SourceToDest);
return M.mergeTypeRecords(Dest, Types);
}
Error llvm::codeview::mergeIdRecords(TypeTableBuilder &Dest,
ArrayRef<TypeIndex> TypeSourceToDest,
SmallVectorImpl<TypeIndex> &SourceToDest,
- const CVTypeArray &Ids) {
- TypeStreamMerger M(SourceToDest, nullptr);
+ const CVTypeArray &Ids) {
+ TypeStreamMerger M(SourceToDest);
return M.mergeIdRecords(Dest, TypeSourceToDest, Ids);
}
Error llvm::codeview::mergeTypeAndIdRecords(
TypeTableBuilder &DestIds, TypeTableBuilder &DestTypes,
- SmallVectorImpl<TypeIndex> &SourceToDest, TypeServerHandler *Handler,
- const CVTypeArray &IdsAndTypes) {
- TypeStreamMerger M(SourceToDest, Handler);
+ SmallVectorImpl<TypeIndex> &SourceToDest, const CVTypeArray &IdsAndTypes) {
+ TypeStreamMerger M(SourceToDest);
return M.mergeTypesAndIds(DestIds, DestTypes, IdsAndTypes);
}
diff --git a/llvm/lib/DebugInfo/PDB/CMakeLists.txt b/llvm/lib/DebugInfo/PDB/CMakeLists.txt
index ff01c948e09..9b1f37943e6 100644
--- a/llvm/lib/DebugInfo/PDB/CMakeLists.txt
+++ b/llvm/lib/DebugInfo/PDB/CMakeLists.txt
@@ -52,7 +52,6 @@ add_pdb_impl_folder(Native
Native/PDBFileBuilder.cpp
Native/PDBStringTable.cpp
Native/PDBStringTableBuilder.cpp
- Native/PDBTypeServerHandler.cpp
Native/PublicsStream.cpp
Native/PublicsStreamBuilder.cpp
Native/RawError.cpp
diff --git a/llvm/lib/DebugInfo/PDB/Native/PDBTypeServerHandler.cpp b/llvm/lib/DebugInfo/PDB/Native/PDBTypeServerHandler.cpp
deleted file mode 100644
index e2f841ee893..00000000000
--- a/llvm/lib/DebugInfo/PDB/Native/PDBTypeServerHandler.cpp
+++ /dev/null
@@ -1,125 +0,0 @@
-//===- PDBTypeServerHandler.cpp ---------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-// Handles CodeView LF_TYPESERVER2 records by attempting to locate a matching
-// PDB file, then loading the PDB file and visiting all types from the
-// referenced PDB using the original supplied visitor.
-//
-// The net effect of this is that when visiting a PDB containing a TypeServer
-// record, the TypeServer record is "replaced" with all of the records in
-// the referenced PDB file. If a single instance of PDBTypeServerHandler
-// encounters the same TypeServer multiple times (for example reusing one
-// PDBTypeServerHandler across multiple visitations of distinct object files or
-// PDB files), PDBTypeServerHandler will optionally revisit all the records
-// again, or simply consume the record and do nothing.
-//===----------------------------------------------------------------------===//
-
-#include "llvm/DebugInfo/PDB/Native/PDBTypeServerHandler.h"
-
-#include "llvm/DebugInfo/CodeView/CVTypeVisitor.h"
-#include "llvm/DebugInfo/CodeView/CodeViewError.h"
-#include "llvm/DebugInfo/PDB/GenericError.h"
-#include "llvm/DebugInfo/PDB/Native/InfoStream.h"
-#include "llvm/DebugInfo/PDB/Native/NativeSession.h"
-#include "llvm/DebugInfo/PDB/Native/PDBFile.h"
-#include "llvm/DebugInfo/PDB/Native/TpiStream.h"
-#include "llvm/DebugInfo/PDB/PDB.h"
-#include "llvm/Support/FileSystem.h"
-#include "llvm/Support/Path.h"
-
-using namespace llvm;
-using namespace llvm::codeview;
-using namespace llvm::pdb;
-
-static void ignoreErrors(Error EC) {
- llvm::handleAllErrors(std::move(EC), [&](ErrorInfoBase &EIB) {});
-}
-
-PDBTypeServerHandler::PDBTypeServerHandler(bool RevisitAlways)
- : RevisitAlways(RevisitAlways) {}
-
-void PDBTypeServerHandler::addSearchPath(StringRef Path) {
- if (Path.empty() || !sys::fs::is_directory(Path))
- return;
-
- SearchPaths.insert(Path);
-}
-
-Expected<bool>
-PDBTypeServerHandler::handleInternal(PDBFile &File,
- TypeVisitorCallbacks &Callbacks) {
- auto ExpectedTpi = File.getPDBTpiStream();
- if (!ExpectedTpi)
- return ExpectedTpi.takeError();
-
- // For handling a type server, we should be using whatever the callback array
- // was that is being used for the original file. We shouldn't allow the
- // visitor to arbitrarily stick a deserializer in there.
- if (auto EC = codeview::visitTypeStream(ExpectedTpi->typeArray(), Callbacks,
- VDS_BytesExternal))
- return std::move(EC);
-
- return true;
-}
-
-Expected<bool> PDBTypeServerHandler::handle(TypeServer2Record &TS,
- TypeVisitorCallbacks &Callbacks) {
- if (Session) {
- // If we've already handled this TypeServer and we only want to handle each
- // TypeServer once, consume the record without doing anything.
- if (!RevisitAlways)
- return true;
-
- return handleInternal(Session->getPDBFile(), Callbacks);
- }
-
- StringRef File = sys::path::filename(TS.Name);
- if (File.empty())
- return make_error<CodeViewError>(
- cv_error_code::corrupt_record,
- "TypeServer2Record does not contain filename!");
-
- for (auto &Path : SearchPaths) {
- SmallString<64> PathStr = Path.getKey();
- sys::path::append(PathStr, File);
- if (!sys::fs::exists(PathStr))
- continue;
-
- std::unique_ptr<IPDBSession> ThisSession;
- if (auto EC = loadDataForPDB(PDB_ReaderType::Native, PathStr, ThisSession)) {
- // It is not an error if this PDB fails to load, it just means that it
- // doesn't match and we should continue searching.
- ignoreErrors(std::move(EC));
- continue;
- }
-
- std::unique_ptr<NativeSession> NS(
- static_cast<NativeSession *>(ThisSession.release()));
- PDBFile &File = NS->getPDBFile();
- auto ExpectedInfo = File.getPDBInfoStream();
- // All PDB Files should have an Info stream.
- if (!ExpectedInfo)
- return ExpectedInfo.takeError();
-
- // Just because a file with a matching name was found and it was an actual
- // PDB file doesn't mean it matches. For it to match the InfoStream's GUID
- // must match the GUID specified in the TypeServer2 record.
- ArrayRef<uint8_t> GuidBytes(ExpectedInfo->getGuid().Guid);
- StringRef GuidStr(reinterpret_cast<const char *>(GuidBytes.begin()),
- GuidBytes.size());
- if (GuidStr != TS.Guid)
- continue;
-
- Session = std::move(NS);
- return handleInternal(File, Callbacks);
- }
-
- // We couldn't find a matching PDB, so let it be handled by someone else.
- return make_error<GenericError>(generic_error_code::type_server_not_found,
- File);
-}
diff --git a/llvm/lib/DebugInfo/PDB/Native/TpiStream.cpp b/llvm/lib/DebugInfo/PDB/Native/TpiStream.cpp
index f917ef91f63..d3ef87d9009 100644
--- a/llvm/lib/DebugInfo/PDB/Native/TpiStream.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/TpiStream.cpp
@@ -14,7 +14,6 @@
#include "llvm/DebugInfo/CodeView/TypeRecord.h"
#include "llvm/DebugInfo/MSF/MappedBlockStream.h"
#include "llvm/DebugInfo/PDB/Native/PDBFile.h"
-#include "llvm/DebugInfo/PDB/Native/PDBTypeServerHandler.h"
#include "llvm/DebugInfo/PDB/Native/RawConstants.h"
#include "llvm/DebugInfo/PDB/Native/RawError.h"
#include "llvm/DebugInfo/PDB/Native/RawTypes.h"
OpenPOWER on IntegriCloud