summaryrefslogtreecommitdiffstats
path: root/llvm/tools
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2017-06-09 00:28:08 +0000
committerZachary Turner <zturner@google.com>2017-06-09 00:28:08 +0000
commitdeb391309c9861dcdc995b2c70c2d64189611c3b (patch)
tree10fcd1c2eaef9f3a7c3fc6ce3693cc5c756ea3db /llvm/tools
parent4fcdaa9423daa465a40bacfe21846276f96059bc (diff)
downloadbcm5719-llvm-deb391309c9861dcdc995b2c70c2d64189611c3b.tar.gz
bcm5719-llvm-deb391309c9861dcdc995b2c70c2d64189611c3b.zip
[CodeView] Support remaining debug subsection types
This adds support for Symbols, StringTable, and FrameData subsection types. Even though these subsections rarely if ever appear in a PDB file (they are usually in object files), there's no theoretical reason why they *couldn't* appear in a PDB. The real issue though is that in order to add support for dumping and writing them (which will be useful for object files), we need a way to test them. And since there is no support for reading and writing them to / from object files yet, making PDB support them is the best way to both add support for the underlying format and add support for tests at the same time. Later, when we go to add support for reading / writing them from object files, we'll need only minimal changes in the underlying read/write code. llvm-svn: 305037
Diffstat (limited to 'llvm/tools')
-rw-r--r--llvm/tools/llvm-pdbdump/LLVMOutputStyle.cpp95
-rw-r--r--llvm/tools/llvm-pdbdump/YAMLOutputStyle.cpp6
-rw-r--r--llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp12
-rw-r--r--llvm/tools/llvm-pdbdump/llvm-pdbdump.h3
4 files changed, 102 insertions, 14 deletions
diff --git a/llvm/tools/llvm-pdbdump/LLVMOutputStyle.cpp b/llvm/tools/llvm-pdbdump/LLVMOutputStyle.cpp
index 8e861e96c5d..8d688d094ee 100644
--- a/llvm/tools/llvm-pdbdump/LLVMOutputStyle.cpp
+++ b/llvm/tools/llvm-pdbdump/LLVMOutputStyle.cpp
@@ -17,9 +17,12 @@
#include "llvm/DebugInfo/CodeView/DebugChecksumsSubsection.h"
#include "llvm/DebugInfo/CodeView/DebugCrossExSubsection.h"
#include "llvm/DebugInfo/CodeView/DebugCrossImpSubsection.h"
+#include "llvm/DebugInfo/CodeView/DebugFrameDataSubsection.h"
#include "llvm/DebugInfo/CodeView/DebugInlineeLinesSubsection.h"
#include "llvm/DebugInfo/CodeView/DebugLinesSubsection.h"
+#include "llvm/DebugInfo/CodeView/DebugStringTableSubsection.h"
#include "llvm/DebugInfo/CodeView/DebugSubsectionVisitor.h"
+#include "llvm/DebugInfo/CodeView/DebugSymbolsSubsection.h"
#include "llvm/DebugInfo/CodeView/DebugUnknownSubsection.h"
#include "llvm/DebugInfo/CodeView/EnumTables.h"
#include "llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h"
@@ -84,8 +87,9 @@ struct PageStats {
class C13RawVisitor : public DebugSubsectionVisitor {
public:
- C13RawVisitor(ScopedPrinter &P, LazyRandomTypeCollection &IPI)
- : P(P), IPI(IPI) {}
+ C13RawVisitor(ScopedPrinter &P, LazyRandomTypeCollection &TPI,
+ LazyRandomTypeCollection &IPI)
+ : P(P), TPI(TPI), IPI(IPI) {}
Error visitLines(DebugLinesSubsectionRef &Lines,
const DebugSubsectionState &State) override {
@@ -204,6 +208,72 @@ public:
return Error::success();
}
+ Error visitFrameData(DebugFrameDataSubsectionRef &FD,
+ const DebugSubsectionState &State) override {
+ if (!opts::checkModuleSubsection(opts::ModuleSubsection::FrameData))
+ return Error::success();
+
+ ListScope L(P, "FrameData");
+ for (const auto &Frame : FD) {
+ DictScope D(P, "Frame");
+ auto Name = getNameFromStringTable(Frame.FrameFunc, State);
+ if (!Name)
+ return joinErrors(make_error<RawError>(raw_error_code::invalid_format,
+ "Invalid Frame.FrameFunc index"),
+ std::move(Name.takeError()));
+ P.printNumber("Rva", Frame.RvaStart);
+ P.printNumber("CodeSize", Frame.CodeSize);
+ P.printNumber("LocalSize", Frame.LocalSize);
+ P.printNumber("ParamsSize", Frame.ParamsSize);
+ P.printNumber("MaxStackSize", Frame.MaxStackSize);
+ P.printString("FrameFunc", *Name);
+ P.printNumber("PrologSize", Frame.PrologSize);
+ P.printNumber("SavedRegsSize", Frame.SavedRegsSize);
+ P.printNumber("Flags", Frame.Flags);
+ }
+ return Error::success();
+ }
+
+ Error visitSymbols(DebugSymbolsSubsectionRef &Symbols,
+ const DebugSubsectionState &State) override {
+ if (!opts::checkModuleSubsection(opts::ModuleSubsection::Symbols))
+ return Error::success();
+ ListScope L(P, "Symbols");
+
+ // This section should not actually appear in a PDB file, it really only
+ // appears in object files. But we support it here for testing. So we
+ // specify the Object File container type.
+ codeview::CVSymbolDumper SD(P, TPI, CodeViewContainer::ObjectFile, nullptr,
+ false);
+ for (auto S : Symbols) {
+ DictScope LL(P, "");
+ if (auto EC = SD.dump(S)) {
+ return make_error<RawError>(
+ raw_error_code::corrupt_file,
+ "DEBUG_S_SYMBOLS subsection contained corrupt symbol record");
+ }
+ }
+ return Error::success();
+ }
+
+ Error visitStringTable(DebugStringTableSubsectionRef &Strings,
+ const DebugSubsectionState &State) override {
+ if (!opts::checkModuleSubsection(opts::ModuleSubsection::StringTable))
+ return Error::success();
+
+ ListScope D(P, "String Table");
+ BinaryStreamReader Reader(Strings.getBuffer());
+ StringRef S;
+ consumeError(Reader.readCString(S));
+ while (Reader.bytesRemaining() > 0) {
+ consumeError(Reader.readCString(S));
+ if (S.empty() && Reader.bytesRemaining() < 4)
+ break;
+ P.printString(S);
+ }
+ return Error::success();
+ }
+
private:
Error dumpTypeRecord(StringRef Label, TypeIndex Index) {
CompactTypeDumpVisitor CTDV(IPI, Index, &P);
@@ -245,6 +315,7 @@ private:
}
ScopedPrinter &P;
+ LazyRandomTypeCollection &TPI;
LazyRandomTypeCollection &IPI;
};
}
@@ -847,14 +918,14 @@ Error LLVMOutputStyle::dumpDbiStream() {
if (auto EC = ModS.reload())
return EC;
+ auto ExpectedTpi = initializeTypeDatabase(StreamTPI);
+ if (!ExpectedTpi)
+ return ExpectedTpi.takeError();
+ auto &Tpi = *ExpectedTpi;
if (ShouldDumpSymbols) {
- auto ExpectedTypes = initializeTypeDatabase(StreamTPI);
- if (!ExpectedTypes)
- return ExpectedTypes.takeError();
- auto &Types = *ExpectedTypes;
ListScope SS(P, "Symbols");
- codeview::CVSymbolDumper SD(P, Types, CodeViewContainer::Pdb, nullptr,
+ codeview::CVSymbolDumper SD(P, Tpi, CodeViewContainer::Pdb, nullptr,
false);
bool HadError = false;
for (auto S : ModS.symbols(&HadError)) {
@@ -876,10 +947,10 @@ Error LLVMOutputStyle::dumpDbiStream() {
}
if (!opts::shared::DumpModuleSubsections.empty()) {
ListScope SS(P, "Subsections");
- auto ExpectedTypes = initializeTypeDatabase(StreamIPI);
- if (!ExpectedTypes)
- return ExpectedTypes.takeError();
- auto &IpiItems = *ExpectedTypes;
+ auto ExpectedIpi = initializeTypeDatabase(StreamIPI);
+ if (!ExpectedIpi)
+ return ExpectedIpi.takeError();
+ auto &Ipi = *ExpectedIpi;
auto ExpectedStrings = File.getStringTable();
if (!ExpectedStrings)
return joinErrors(
@@ -887,7 +958,7 @@ Error LLVMOutputStyle::dumpDbiStream() {
"Could not get string table!"),
std::move(ExpectedStrings.takeError()));
- C13RawVisitor V(P, IpiItems);
+ C13RawVisitor V(P, Tpi, Ipi);
if (auto EC = codeview::visitDebugSubsections(
ModS.subsections(), V, ExpectedStrings->getStringTable()))
return EC;
diff --git a/llvm/tools/llvm-pdbdump/YAMLOutputStyle.cpp b/llvm/tools/llvm-pdbdump/YAMLOutputStyle.cpp
index 26891e6b79d..56175856097 100644
--- a/llvm/tools/llvm-pdbdump/YAMLOutputStyle.cpp
+++ b/llvm/tools/llvm-pdbdump/YAMLOutputStyle.cpp
@@ -171,6 +171,12 @@ static opts::ModuleSubsection convertSubsectionKind(DebugSubsectionKind K) {
return opts::ModuleSubsection::InlineeLines;
case DebugSubsectionKind::Lines:
return opts::ModuleSubsection::Lines;
+ case DebugSubsectionKind::Symbols:
+ return opts::ModuleSubsection::Symbols;
+ case DebugSubsectionKind::StringTable:
+ return opts::ModuleSubsection::StringTable;
+ case DebugSubsectionKind::FrameData:
+ return opts::ModuleSubsection::FrameData;
default:
return opts::ModuleSubsection::Unknown;
}
diff --git a/llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp b/llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp
index 4d523098750..68b7abff539 100644
--- a/llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp
+++ b/llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp
@@ -434,6 +434,14 @@ cl::list<ModuleSubsection> DumpModuleSubsections(
"Inlinee lines (DEBUG_S_INLINEELINES subsection)"),
clEnumValN(ModuleSubsection::Lines, "lines",
"Lines (DEBUG_S_LINES subsection)"),
+ clEnumValN(ModuleSubsection::StringTable, "strings",
+ "String Table (DEBUG_S_STRINGTABLE subsection) (not "
+ "typically present in PDB file)"),
+ clEnumValN(ModuleSubsection::FrameData, "frames",
+ "Frame Data (DEBUG_S_FRAMEDATA subsection)"),
+ clEnumValN(ModuleSubsection::Symbols, "symbols",
+ "Symbols (DEBUG_S_SYMBOLS subsection) (not typically "
+ "present in PDB file)"),
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"),
@@ -545,8 +553,8 @@ static void yamlToPdb(StringRef Path) {
}
}
- auto CodeViewSubsections =
- ExitOnErr(CodeViewYAML::convertSubsectionList(MI.Subsections, Strings));
+ auto CodeViewSubsections = ExitOnErr(CodeViewYAML::toCodeViewSubsectionList(
+ Allocator, MI.Subsections, Strings));
for (auto &SS : CodeViewSubsections) {
ModiBuilder.addDebugSubsection(std::move(SS));
}
diff --git a/llvm/tools/llvm-pdbdump/llvm-pdbdump.h b/llvm/tools/llvm-pdbdump/llvm-pdbdump.h
index b1f527516fb..2858ac35a9d 100644
--- a/llvm/tools/llvm-pdbdump/llvm-pdbdump.h
+++ b/llvm/tools/llvm-pdbdump/llvm-pdbdump.h
@@ -34,6 +34,9 @@ enum class ModuleSubsection {
InlineeLines,
CrossScopeImports,
CrossScopeExports,
+ StringTable,
+ Symbols,
+ FrameData,
All
};
OpenPOWER on IntegriCloud