[PDB] Fix type server handling for archives

Summary:
This fixes type indices for SDK or CRT static archives. Previously we'd
try to look next to the archive object file path, which would not exist
on the local machine.

Also error out if we can't resolve a type server record. Hypothetically
we can recover from this error by discarding debug info for this object,
but that is not yet implemented.

Reviewers: ruiu, amccarth

Subscribers: aprantl, hiraditya, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307946 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Reid Kleckner 2017-07-13 20:12:23 +00:00
parent 14382189fa
commit fe30dbf0ab
4 changed files with 14 additions and 16 deletions

View File

@ -19,6 +19,7 @@ namespace pdb {
enum class generic_error_code {
invalid_path = 1,
dia_sdk_not_present,
type_server_not_found,
unspecified,
};

View File

@ -273,16 +273,13 @@ Error TypeStreamMerger::mergeIdRecords(TypeTableBuilder &Dest,
Error TypeStreamMerger::mergeTypesAndIds(TypeTableBuilder &DestIds,
TypeTableBuilder &DestTypes,
const CVTypeArray &IdsAndTypes) {
const CVTypeArray &IdsAndTypes) {
DestIdStream = &DestIds;
DestTypeStream = &DestTypes;
return doit(IdsAndTypes);
}
Error TypeStreamMerger::doit(const CVTypeArray &Types) {
LastError = Error::success();
// We don't want to deserialize records. I guess this flag is poorly named,
// but it really means "Don't deserialize records before switching on the
// concrete type.
@ -301,7 +298,7 @@ Error TypeStreamMerger::doit(const CVTypeArray &Types) {
// topologically sorted. The standard library contains MASM-produced objects,
// so this is important to handle correctly, but we don't have to be too
// efficient. MASM type streams are usually very small.
while (!*LastError && NumBadIndices > 0) {
while (!LastError && NumBadIndices > 0) {
unsigned BadIndicesRemaining = NumBadIndices;
IsSecondPass = true;
NumBadIndices = 0;
@ -313,15 +310,15 @@ Error TypeStreamMerger::doit(const CVTypeArray &Types) {
assert(NumBadIndices <= BadIndicesRemaining &&
"second pass found more bad indices");
if (!*LastError && NumBadIndices == BadIndicesRemaining) {
if (!LastError && NumBadIndices == BadIndicesRemaining) {
return llvm::make_error<CodeViewError>(
cv_error_code::corrupt_record, "input type graph contains cycles");
}
}
Error Ret = std::move(*LastError);
LastError.reset();
return Ret;
if (LastError)
return std::move(*LastError);
return Error::success();
}
Error llvm::codeview::mergeTypeRecords(TypeTableBuilder &Dest,
@ -343,8 +340,7 @@ Error llvm::codeview::mergeIdRecords(TypeTableBuilder &Dest,
Error llvm::codeview::mergeTypeAndIdRecords(
TypeTableBuilder &DestIds, TypeTableBuilder &DestTypes,
SmallVectorImpl<TypeIndex> &SourceToDest, TypeServerHandler *Handler,
const CVTypeArray &IdsAndTypes) {
const CVTypeArray &IdsAndTypes) {
TypeStreamMerger M(SourceToDest, Handler);
return M.mergeTypesAndIds(DestIds, DestTypes, IdsAndTypes);
}

View File

@ -26,6 +26,8 @@ public:
switch (static_cast<generic_error_code>(Condition)) {
case generic_error_code::unspecified:
return "An unknown error has occurred.";
case generic_error_code::type_server_not_found:
return "Type server PDB was not found.";
case generic_error_code::dia_sdk_not_present:
return "LLVM was not compiled with support for DIA. This usually means "
"that you are are not using MSVC, or your Visual Studio "

View File

@ -58,10 +58,8 @@ PDBTypeServerHandler::handleInternal(PDBFile &File,
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.
// 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);
@ -122,5 +120,6 @@ Expected<bool> PDBTypeServerHandler::handle(TypeServer2Record &TS,
}
// We couldn't find a matching PDB, so let it be handled by someone else.
return false;
return make_error<GenericError>(generic_error_code::type_server_not_found,
File);
}