[llvm] r305041 - [pdb] Don't crash on unknown debug subsections.
Zachary Turner via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 8 17:54:00 PDT 2017
Author: zturner
Date: Thu Jun 8 19:53:59 2017
New Revision: 305041
URL: http://llvm.org/viewvc/llvm-project?rev=305041&view=rev
Log:
[pdb] Don't crash on unknown debug subsections.
More and more unknown debug subsection kinds are being discovered
so we should make it possible to dump these and display the
bytes.
Modified:
llvm/trunk/include/llvm/DebugInfo/CodeView/DebugSubsectionVisitor.h
llvm/trunk/lib/DebugInfo/CodeView/DebugSubsectionRecord.cpp
llvm/trunk/tools/llvm-pdbdump/LLVMOutputStyle.cpp
llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp
Modified: llvm/trunk/include/llvm/DebugInfo/CodeView/DebugSubsectionVisitor.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/DebugSubsectionVisitor.h?rev=305041&r1=305040&r2=305041&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/CodeView/DebugSubsectionVisitor.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/CodeView/DebugSubsectionVisitor.h Thu Jun 8 19:53:59 2017
@@ -120,7 +120,7 @@ Error visitDebugSubsections(T &&Fragment
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;
}
Modified: llvm/trunk/lib/DebugInfo/CodeView/DebugSubsectionRecord.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/DebugSubsectionRecord.cpp?rev=305041&r1=305040&r2=305041&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/CodeView/DebugSubsectionRecord.cpp (original)
+++ llvm/trunk/lib/DebugInfo/CodeView/DebugSubsectionRecord.cpp Thu Jun 8 19:53:59 2017
@@ -34,19 +34,6 @@ Error DebugSubsectionRecord::initialize(
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;
Modified: llvm/trunk/tools/llvm-pdbdump/LLVMOutputStyle.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbdump/LLVMOutputStyle.cpp?rev=305041&r1=305040&r2=305041&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-pdbdump/LLVMOutputStyle.cpp (original)
+++ llvm/trunk/tools/llvm-pdbdump/LLVMOutputStyle.cpp Thu Jun 8 19:53:59 2017
@@ -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))
Modified: llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp?rev=305041&r1=305040&r2=305041&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp (original)
+++ llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp Thu Jun 8 19:53:59 2017
@@ -442,6 +442,8 @@ cl::list<ModuleSubsection> DumpModuleSub
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"),
More information about the llvm-commits
mailing list