[llvm] r311117 - [llvm-pdbutil] Fix some dumping issues.

Zachary Turner via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 17 13:04:51 PDT 2017


Author: zturner
Date: Thu Aug 17 13:04:51 2017
New Revision: 311117

URL: http://llvm.org/viewvc/llvm-project?rev=311117&view=rev
Log:
[llvm-pdbutil] Fix some dumping issues.

When dumping, we were treating the S_INLINESITESYM as referring
to a type record, when it actually refers to an id record.  We
had this correct in TypeIndexDiscovery, so our merging algorithm
should be fine, but we had it wrong in the dumper, which means it
would appear to work most of the time, unless the index was out
of bounds in the type stream, when it would fail.  Fixed this, and
audited a few other cases to make them match the behavior in
TypeIndexDiscovery.

Also, I've now observed a new symbol record with kind 0x1168 which
I have no clue what it is, so to avoid crashing we have to just
print "Unknown Symbol Kind".

Modified:
    llvm/trunk/lib/DebugInfo/CodeView/LazyRandomTypeCollection.cpp
    llvm/trunk/tools/llvm-pdbutil/MinimalSymbolDumper.cpp

Modified: llvm/trunk/lib/DebugInfo/CodeView/LazyRandomTypeCollection.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/LazyRandomTypeCollection.cpp?rev=311117&r1=311116&r2=311117&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/CodeView/LazyRandomTypeCollection.cpp (original)
+++ llvm/trunk/lib/DebugInfo/CodeView/LazyRandomTypeCollection.cpp Thu Aug 17 13:04:51 2017
@@ -83,7 +83,9 @@ uint32_t LazyRandomTypeCollection::getOf
 }
 
 CVType LazyRandomTypeCollection::getType(TypeIndex Index) {
-  error(ensureTypeExists(Index));
+  uint32_t I = Index.getIndex();
+  auto EC = ensureTypeExists(Index);
+  error(std::move(EC));
   assert(contains(Index));
 
   return Records[Index.toArrayIndex()].Type;

Modified: llvm/trunk/tools/llvm-pdbutil/MinimalSymbolDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbutil/MinimalSymbolDumper.cpp?rev=311117&r1=311116&r2=311117&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-pdbutil/MinimalSymbolDumper.cpp (original)
+++ llvm/trunk/tools/llvm-pdbutil/MinimalSymbolDumper.cpp Thu Aug 17 13:04:51 2017
@@ -24,15 +24,16 @@ using namespace llvm;
 using namespace llvm::codeview;
 using namespace llvm::pdb;
 
-static StringRef getSymbolKindName(SymbolKind K) {
+static std::string getSymbolKindName(SymbolKind K) {
   switch (K) {
 #define SYMBOL_RECORD(EnumName, value, name)                                   \
   case EnumName:                                                               \
     return #EnumName;
 #define CV_SYMBOL(EnumName, value) SYMBOL_RECORD(EnumName, value, EnumName)
 #include "llvm/DebugInfo/CodeView/CodeViewSymbols.def"
-  default:
-    llvm_unreachable("Unknown symbol kind!");
+  default: {
+    return formatv("Unknown Symbol Kind [{0:X}]", uint32_t(K)).str();
+  }
   }
   return "";
 }
@@ -674,7 +675,7 @@ Error MinimalSymbolDumper::visitKnownRec
 Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR,
                                             HeapAllocationSiteSym &HAS) {
   AutoIndent Indent(P, 7);
-  P.formatLine("type = {0}, addr = {1} call size = {2}", typeIndex(HAS.Type),
+  P.formatLine("type = {0}, addr = {1} call size = {2}", idIndex(HAS.Type),
                formatSegmentOffset(HAS.Segment, HAS.CodeOffset),
                HAS.CallInstructionSize);
   return Error::success();
@@ -686,7 +687,7 @@ Error MinimalSymbolDumper::visitKnownRec
   StringRef Annotations(reinterpret_cast<const char *>(Bytes.begin()),
                         Bytes.size());
 
-  P.formatLine("inlinee = {0}, parent = {1}, end = {2}", typeIndex(IS.Inlinee),
+  P.formatLine("inlinee = {0}, parent = {1}, end = {2}", idIndex(IS.Inlinee),
                IS.Parent, IS.End);
   P.formatLine("annotations = {0}", toHex(Annotations));
   return Error::success();
@@ -776,7 +777,7 @@ Error MinimalSymbolDumper::visitKnownRec
 Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, CallerSym &Caller) {
   AutoIndent Indent(P, 7);
   for (const auto &I : Caller.Indices) {
-    P.formatLine("callee: {0}", typeIndex(I));
+    P.formatLine("callee: {0}", idIndex(I));
   }
   return Error::success();
 }




More information about the llvm-commits mailing list