[llvm] r307946 - [PDB] Fix type server handling for archives

Reid Kleckner via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 13 13:12:23 PDT 2017


Author: rnk
Date: Thu Jul 13 13:12:23 2017
New Revision: 307946

URL: http://llvm.org/viewvc/llvm-project?rev=307946&view=rev
Log:
[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

Modified:
    llvm/trunk/include/llvm/DebugInfo/PDB/GenericError.h
    llvm/trunk/lib/DebugInfo/CodeView/TypeStreamMerger.cpp
    llvm/trunk/lib/DebugInfo/PDB/GenericError.cpp
    llvm/trunk/lib/DebugInfo/PDB/Native/PDBTypeServerHandler.cpp

Modified: llvm/trunk/include/llvm/DebugInfo/PDB/GenericError.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/GenericError.h?rev=307946&r1=307945&r2=307946&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/GenericError.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/GenericError.h Thu Jul 13 13:12:23 2017
@@ -19,6 +19,7 @@ namespace pdb {
 enum class generic_error_code {
   invalid_path = 1,
   dia_sdk_not_present,
+  type_server_not_found,
   unspecified,
 };
 

Modified: llvm/trunk/lib/DebugInfo/CodeView/TypeStreamMerger.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/TypeStreamMerger.cpp?rev=307946&r1=307945&r2=307946&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/CodeView/TypeStreamMerger.cpp (original)
+++ llvm/trunk/lib/DebugInfo/CodeView/TypeStreamMerger.cpp Thu Jul 13 13:12:23 2017
@@ -273,16 +273,13 @@ Error TypeStreamMerger::mergeIdRecords(T
 
 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 CVTyp
   // 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 CVTyp
 
     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(Typ
 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);
 }

Modified: llvm/trunk/lib/DebugInfo/PDB/GenericError.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/GenericError.cpp?rev=307946&r1=307945&r2=307946&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/GenericError.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/GenericError.cpp Thu Jul 13 13:12:23 2017
@@ -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 "

Modified: llvm/trunk/lib/DebugInfo/PDB/Native/PDBTypeServerHandler.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Native/PDBTypeServerHandler.cpp?rev=307946&r1=307945&r2=307946&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/Native/PDBTypeServerHandler.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/Native/PDBTypeServerHandler.cpp Thu Jul 13 13:12:23 2017
@@ -58,10 +58,8 @@ PDBTypeServerHandler::handleInternal(PDB
     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::han
   }
 
   // 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);
 }




More information about the llvm-commits mailing list