summaryrefslogtreecommitdiffstats
path: root/llvm/tools
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/tools')
-rw-r--r--llvm/tools/llvm-pdbdump/LLVMOutputStyle.cpp20
-rw-r--r--llvm/tools/llvm-pdbdump/YAMLOutputStyle.cpp27
-rw-r--r--llvm/tools/llvm-readobj/COFFDumper.cpp32
3 files changed, 35 insertions, 44 deletions
diff --git a/llvm/tools/llvm-pdbdump/LLVMOutputStyle.cpp b/llvm/tools/llvm-pdbdump/LLVMOutputStyle.cpp
index a4df5d09b4f..20223ac60f4 100644
--- a/llvm/tools/llvm-pdbdump/LLVMOutputStyle.cpp
+++ b/llvm/tools/llvm-pdbdump/LLVMOutputStyle.cpp
@@ -16,7 +16,10 @@
#include "llvm/DebugInfo/CodeView/CVTypeDumper.h"
#include "llvm/DebugInfo/CodeView/CVTypeVisitor.h"
#include "llvm/DebugInfo/CodeView/EnumTables.h"
+#include "llvm/DebugInfo/CodeView/ModuleDebugFileChecksumFragment.h"
#include "llvm/DebugInfo/CodeView/ModuleDebugFragmentVisitor.h"
+#include "llvm/DebugInfo/CodeView/ModuleDebugLineFragment.h"
+#include "llvm/DebugInfo/CodeView/ModuleDebugUnknownFragment.h"
#include "llvm/DebugInfo/CodeView/SymbolDumper.h"
#include "llvm/DebugInfo/CodeView/TypeDatabaseVisitor.h"
#include "llvm/DebugInfo/CodeView/TypeDeserializer.h"
@@ -633,17 +636,15 @@ Error LLVMOutputStyle::dumpDbiStream() {
}
if (opts::raw::DumpLineInfo) {
ListScope SS(P, "LineInfo");
- bool HadError = false;
// Define a locally scoped visitor to print the different
// substream types types.
class RecordVisitor : public codeview::ModuleDebugFragmentVisitor {
public:
RecordVisitor(ScopedPrinter &P, PDBFile &F) : P(P), F(F) {}
- Error visitUnknown(ModuleDebugFragmentKind Kind,
- BinaryStreamRef Stream) override {
+ Error visitUnknown(ModuleDebugUnknownFragment &Fragment) override {
DictScope DD(P, "Unknown");
ArrayRef<uint8_t> Data;
- BinaryStreamReader R(Stream);
+ BinaryStreamReader R(Fragment.getData());
if (auto EC = R.readBytes(Data, R.bytesRemaining())) {
return make_error<RawError>(
raw_error_code::corrupt_file,
@@ -652,9 +653,8 @@ Error LLVMOutputStyle::dumpDbiStream() {
P.printBinaryBlock("Data", Data);
return Error::success();
}
- Error
- visitFileChecksums(BinaryStreamRef Data,
- const FileChecksumArray &Checksums) override {
+ Error visitFileChecksums(
+ ModuleDebugFileChecksumFragment &Checksums) override {
DictScope DD(P, "FileChecksums");
for (const auto &C : Checksums) {
DictScope DDD(P, "Checksum");
@@ -669,9 +669,7 @@ Error LLVMOutputStyle::dumpDbiStream() {
return Error::success();
}
- Error visitLines(BinaryStreamRef Data,
- const LineFragmentHeader *Header,
- const LineInfoArray &Lines) override {
+ Error visitLines(ModuleDebugLineFragment &Lines) override {
DictScope DD(P, "Lines");
for (const auto &L : Lines) {
if (auto Result = getFileNameForOffset2(L.NameIndex))
@@ -720,7 +718,7 @@ Error LLVMOutputStyle::dumpDbiStream() {
};
RecordVisitor V(P, File);
- for (const auto &L : ModS.lines(&HadError)) {
+ for (const auto &L : ModS.linesAndChecksums()) {
if (auto EC = codeview::visitModuleDebugFragment(L, V))
return EC;
}
diff --git a/llvm/tools/llvm-pdbdump/YAMLOutputStyle.cpp b/llvm/tools/llvm-pdbdump/YAMLOutputStyle.cpp
index 8c8b01ddb3f..7264f970759 100644
--- a/llvm/tools/llvm-pdbdump/YAMLOutputStyle.cpp
+++ b/llvm/tools/llvm-pdbdump/YAMLOutputStyle.cpp
@@ -13,8 +13,11 @@
#include "llvm-pdbdump.h"
#include "llvm/DebugInfo/CodeView/Line.h"
+#include "llvm/DebugInfo/CodeView/ModuleDebugFileChecksumFragment.h"
#include "llvm/DebugInfo/CodeView/ModuleDebugFragment.h"
#include "llvm/DebugInfo/CodeView/ModuleDebugFragmentVisitor.h"
+#include "llvm/DebugInfo/CodeView/ModuleDebugLineFragment.h"
+#include "llvm/DebugInfo/CodeView/ModuleDebugUnknownFragment.h"
#include "llvm/DebugInfo/MSF/MappedBlockStream.h"
#include "llvm/DebugInfo/PDB/Native/DbiStream.h"
#include "llvm/DebugInfo/PDB/Native/InfoStream.h"
@@ -24,6 +27,7 @@
#include "llvm/DebugInfo/PDB/Native/TpiStream.h"
using namespace llvm;
+using namespace llvm::codeview;
using namespace llvm::pdb;
YAMLOutputStyle::YAMLOutputStyle(PDBFile &File)
@@ -75,19 +79,17 @@ Error YAMLOutputStyle::dump() {
}
namespace {
-class C13SubstreamVisitor : public codeview::ModuleDebugFragmentVisitor {
+class C13SubstreamVisitor : public ModuleDebugFragmentVisitor {
public:
C13SubstreamVisitor(llvm::pdb::yaml::PdbSourceFileInfo &Info, PDBFile &F)
: Info(Info), F(F) {}
- Error visitUnknown(codeview::ModuleDebugFragmentKind Kind,
- BinaryStreamRef Stream) override {
+ Error visitUnknown(ModuleDebugUnknownFragment &Fragment) override {
return Error::success();
}
Error
- visitFileChecksums(BinaryStreamRef Data,
- const codeview::FileChecksumArray &Checksums) override {
+ visitFileChecksums(ModuleDebugFileChecksumFragment &Checksums) override {
for (const auto &C : Checksums) {
llvm::pdb::yaml::PdbSourceFileChecksumEntry Entry;
if (auto Result = getGlobalString(C.FileNameOffset))
@@ -102,15 +104,13 @@ public:
return Error::success();
}
- Error visitLines(BinaryStreamRef Data,
- const codeview::LineFragmentHeader *Header,
- const codeview::LineInfoArray &Lines) override {
+ Error visitLines(ModuleDebugLineFragment &Lines) override {
- Info.Lines.CodeSize = Header->CodeSize;
+ Info.Lines.CodeSize = Lines.header()->CodeSize;
Info.Lines.Flags =
- static_cast<codeview::LineFlags>(uint16_t(Header->Flags));
- Info.Lines.RelocOffset = Header->RelocOffset;
- Info.Lines.RelocSegment = Header->RelocSegment;
+ static_cast<codeview::LineFlags>(uint16_t(Lines.header()->Flags));
+ Info.Lines.RelocOffset = Lines.header()->RelocOffset;
+ Info.Lines.RelocSegment = Lines.header()->RelocSegment;
for (const auto &L : Lines) {
llvm::pdb::yaml::PdbSourceLineBlock Block;
@@ -170,9 +170,8 @@ YAMLOutputStyle::getFileLineInfo(const pdb::ModuleDebugStream &ModS) {
return None;
yaml::PdbSourceFileInfo Info;
- bool Error = false;
C13SubstreamVisitor Visitor(Info, File);
- for (auto &Frag : ModS.lines(&Error)) {
+ for (auto &Frag : ModS.linesAndChecksums()) {
if (auto E = codeview::visitModuleDebugFragment(Frag, Visitor))
return std::move(E);
}
diff --git a/llvm/tools/llvm-readobj/COFFDumper.cpp b/llvm/tools/llvm-readobj/COFFDumper.cpp
index 3c37d3cd371..635949733a5 100644
--- a/llvm/tools/llvm-readobj/COFFDumper.cpp
+++ b/llvm/tools/llvm-readobj/COFFDumper.cpp
@@ -25,6 +25,7 @@
#include "llvm/DebugInfo/CodeView/CVTypeDumper.h"
#include "llvm/DebugInfo/CodeView/CodeView.h"
#include "llvm/DebugInfo/CodeView/Line.h"
+#include "llvm/DebugInfo/CodeView/ModuleDebugFileChecksumFragment.h"
#include "llvm/DebugInfo/CodeView/RecordSerialization.h"
#include "llvm/DebugInfo/CodeView/SymbolDeserializer.h"
#include "llvm/DebugInfo/CodeView/SymbolDumpDelegate.h"
@@ -985,29 +986,22 @@ void COFFDumper::printCodeViewSymbolsSubsection(StringRef Subsection,
void COFFDumper::printCodeViewFileChecksums(StringRef Subsection) {
BinaryByteStream S(Subsection, llvm::support::little);
BinaryStreamReader SR(S);
- while (!SR.empty()) {
+ ModuleDebugFileChecksumFragment Checksums;
+ error(Checksums.initialize(SR));
+
+ for (auto &FC : Checksums) {
DictScope S(W, "FileChecksum");
- const FileChecksum *FC;
- error(SR.readObject(FC));
- if (FC->FileNameOffset >= CVStringTable.size())
+
+ if (FC.FileNameOffset >= CVStringTable.size())
error(object_error::parse_failed);
StringRef Filename =
- CVStringTable.drop_front(FC->FileNameOffset).split('\0').first;
- W.printHex("Filename", Filename, FC->FileNameOffset);
- W.printHex("ChecksumSize", FC->ChecksumSize);
- W.printEnum("ChecksumKind", uint8_t(FC->ChecksumKind),
+ CVStringTable.drop_front(FC.FileNameOffset).split('\0').first;
+ W.printHex("Filename", Filename, FC.FileNameOffset);
+ W.printHex("ChecksumSize", FC.Checksum.size());
+ W.printEnum("ChecksumKind", uint8_t(FC.Kind),
makeArrayRef(FileChecksumKindNames));
- if (FC->ChecksumSize >= SR.bytesRemaining())
- error(object_error::parse_failed);
- ArrayRef<uint8_t> ChecksumBytes;
- error(SR.readBytes(ChecksumBytes, FC->ChecksumSize));
- W.printBinary("ChecksumBytes", ChecksumBytes);
- unsigned PaddedSize = alignTo(FC->ChecksumSize + sizeof(FileChecksum), 4) -
- sizeof(FileChecksum);
- PaddedSize -= ChecksumBytes.size();
- if (PaddedSize > SR.bytesRemaining())
- error(object_error::parse_failed);
- error(SR.skip(PaddedSize));
+
+ W.printBinary("ChecksumBytes", FC.Checksum);
}
}
OpenPOWER on IntegriCloud