]> granicus.if.org Git - llvm/commitdiff
[pdb] Don't crash on unknown debug subsections.
authorZachary Turner <zturner@google.com>
Fri, 9 Jun 2017 00:53:59 +0000 (00:53 +0000)
committerZachary Turner <zturner@google.com>
Fri, 9 Jun 2017 00:53:59 +0000 (00:53 +0000)
More and more unknown debug subsection kinds are being discovered
so we should make it possible to dump these and display the
bytes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305041 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/DebugInfo/CodeView/DebugSubsectionVisitor.h
lib/DebugInfo/CodeView/DebugSubsectionRecord.cpp
tools/llvm-pdbdump/LLVMOutputStyle.cpp
tools/llvm-pdbdump/llvm-pdbdump.cpp

index 22615828fa77bc824bca7114d5a020313931330d..419ce34922e54ba68eb31ac53eede07de7c44e7f 100644 (file)
@@ -120,7 +120,7 @@ Error visitDebugSubsections(T &&FragmentRange, DebugSubsectionVisitor &V,
                             DebugSubsectionState &State) {
   State.initialize(std::forward<T>(FragmentRange));
 
-  for (const auto &L : FragmentRange) {
+  for (const DebugSubsectionRecord &L : FragmentRange) {
     if (auto EC = visitDebugSubsection(L, V, State))
       return EC;
   }
index eed8edac283d79c73cb4e16546e56392221d438b..e9124e68fe82182bb1b3289c064484a1e187fc10 100644 (file)
@@ -34,19 +34,6 @@ Error DebugSubsectionRecord::initialize(BinaryStreamRef Stream,
 
   DebugSubsectionKind Kind =
       static_cast<DebugSubsectionKind>(uint32_t(Header->Kind));
-  switch (Kind) {
-  case DebugSubsectionKind::FileChecksums:
-  case DebugSubsectionKind::Lines:
-  case DebugSubsectionKind::InlineeLines:
-  case DebugSubsectionKind::CrossScopeExports:
-  case DebugSubsectionKind::CrossScopeImports:
-  case DebugSubsectionKind::Symbols:
-  case DebugSubsectionKind::StringTable:
-  case DebugSubsectionKind::FrameData:
-    break;
-  default:
-    llvm_unreachable("Unexpected debug fragment kind!");
-  }
   if (auto EC = Reader.readStreamRef(Info.Data, Header->Length))
     return EC;
   Info.Container = Container;
index 8d688d094ee52038b47931ec4ef856df370e6a93..53036994970515638f39e7f0249aab86e6ad2137 100644 (file)
@@ -91,6 +91,18 @@ public:
                 LazyRandomTypeCollection &IPI)
       : P(P), TPI(TPI), IPI(IPI) {}
 
+  Error visitUnknown(DebugUnknownSubsectionRef &Unknown) override {
+    if (!opts::checkModuleSubsection(opts::ModuleSubsection::Unknown))
+      return Error::success();
+    DictScope DD(P, "Unknown");
+    P.printHex("Kind", static_cast<uint32_t>(Unknown.kind()));
+    ArrayRef<uint8_t> Data;
+    BinaryStreamReader Reader(Unknown.getData());
+    consumeError(Reader.readBytes(Data, Reader.bytesRemaining()));
+    P.printBinaryBlock("Data", Data);
+    return Error::success();
+  }
+
   Error visitLines(DebugLinesSubsectionRef &Lines,
                    const DebugSubsectionState &State) override {
     if (!opts::checkModuleSubsection(opts::ModuleSubsection::Lines))
index 68b7abff5397436fee4f406f6dd92c91810645df..c6e2b613f4d1d008fba4b7ef6e5ef415e50c1411 100644 (file)
@@ -442,6 +442,8 @@ cl::list<ModuleSubsection> DumpModuleSubsections(
         clEnumValN(ModuleSubsection::Symbols, "symbols",
                    "Symbols (DEBUG_S_SYMBOLS subsection) (not typically "
                    "present in PDB file)"),
+        clEnumValN(ModuleSubsection::Unknown, "unknown",
+                   "Any subsection not covered by another option"),
         clEnumValN(ModuleSubsection::All, "all", "All known subsections")),
     cl::cat(FileOptions), cl::sub(RawSubcommand), cl::sub(PdbToYamlSubcommand));
 cl::opt<bool> DumpModuleSyms("module-syms", cl::desc("dump module symbols"),