summaryrefslogtreecommitdiffstats
path: root/llvm/lib/DebugInfo/PDB/Native/DbiStream.cpp
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2018-04-04 17:29:09 +0000
committerZachary Turner <zturner@google.com>2018-04-04 17:29:09 +0000
commit15b2bdfd8b1572acc51bbf018d3ae84bbd70b512 (patch)
treed6a5f6cbdd38d50a84bc3037cfeefbbbcadb0bf9 /llvm/lib/DebugInfo/PDB/Native/DbiStream.cpp
parent09fda63af04b6e93d10072a33b4b1b1fa61604b9 (diff)
downloadbcm5719-llvm-15b2bdfd8b1572acc51bbf018d3ae84bbd70b512.tar.gz
bcm5719-llvm-15b2bdfd8b1572acc51bbf018d3ae84bbd70b512.zip
[llvm-pdbutil] Add the ability to explain binary files.
Using this, you can use llvm-pdbutil to export the contents of a stream to a binary file, then run explain on the binary file so that it treats the offset as an offset into the stream instead of an offset into a file. This makes it easy to compare the contents of the same stream from two different files. llvm-svn: 329207
Diffstat (limited to 'llvm/lib/DebugInfo/PDB/Native/DbiStream.cpp')
-rw-r--r--llvm/lib/DebugInfo/PDB/Native/DbiStream.cpp28
1 files changed, 17 insertions, 11 deletions
diff --git a/llvm/lib/DebugInfo/PDB/Native/DbiStream.cpp b/llvm/lib/DebugInfo/PDB/Native/DbiStream.cpp
index 04e6664c68d..edaa783398c 100644
--- a/llvm/lib/DebugInfo/PDB/Native/DbiStream.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/DbiStream.cpp
@@ -45,12 +45,12 @@ static Error loadSectionContribs(FixedStreamArray<ContribType> &Output,
return Error::success();
}
-DbiStream::DbiStream(PDBFile &File, std::unique_ptr<MappedBlockStream> Stream)
- : Pdb(File), Stream(std::move(Stream)), Header(nullptr) {}
+DbiStream::DbiStream(std::unique_ptr<BinaryStream> Stream)
+ : Stream(std::move(Stream)), Header(nullptr) {}
DbiStream::~DbiStream() = default;
-Error DbiStream::reload() {
+Error DbiStream::reload(PDBFile *Pdb) {
BinaryStreamReader Reader(*Stream);
if (Stream->getLength() < sizeof(DbiStreamHeader))
@@ -123,11 +123,11 @@ Error DbiStream::reload() {
if (auto EC = initializeSectionContributionData())
return EC;
- if (auto EC = initializeSectionHeadersData())
+ if (auto EC = initializeSectionHeadersData(Pdb))
return EC;
if (auto EC = initializeSectionMapData())
return EC;
- if (auto EC = initializeFpoRecords())
+ if (auto EC = initializeFpoRecords(Pdb))
return EC;
if (Reader.bytesRemaining() > 0)
@@ -246,7 +246,10 @@ Error DbiStream::initializeSectionContributionData() {
}
// Initializes this->SectionHeaders.
-Error DbiStream::initializeSectionHeadersData() {
+Error DbiStream::initializeSectionHeadersData(PDBFile *Pdb) {
+ if (!Pdb)
+ return Error::success();
+
if (DbgStreams.size() == 0)
return Error::success();
@@ -254,11 +257,11 @@ Error DbiStream::initializeSectionHeadersData() {
if (StreamNum == kInvalidStreamIndex)
return Error::success();
- if (StreamNum >= Pdb.getNumStreams())
+ if (StreamNum >= Pdb->getNumStreams())
return make_error<RawError>(raw_error_code::no_stream);
auto SHS = MappedBlockStream::createIndexedStream(
- Pdb.getMsfLayout(), Pdb.getMsfBuffer(), StreamNum, Pdb.getAllocator());
+ Pdb->getMsfLayout(), Pdb->getMsfBuffer(), StreamNum, Pdb->getAllocator());
size_t StreamLen = SHS->getLength();
if (StreamLen % sizeof(object::coff_section))
@@ -276,7 +279,10 @@ Error DbiStream::initializeSectionHeadersData() {
}
// Initializes this->Fpos.
-Error DbiStream::initializeFpoRecords() {
+Error DbiStream::initializeFpoRecords(PDBFile *Pdb) {
+ if (!Pdb)
+ return Error::success();
+
if (DbgStreams.size() == 0)
return Error::success();
@@ -286,11 +292,11 @@ Error DbiStream::initializeFpoRecords() {
if (StreamNum == kInvalidStreamIndex)
return Error::success();
- if (StreamNum >= Pdb.getNumStreams())
+ if (StreamNum >= Pdb->getNumStreams())
return make_error<RawError>(raw_error_code::no_stream);
auto FS = MappedBlockStream::createIndexedStream(
- Pdb.getMsfLayout(), Pdb.getMsfBuffer(), StreamNum, Pdb.getAllocator());
+ Pdb->getMsfLayout(), Pdb->getMsfBuffer(), StreamNum, Pdb->getAllocator());
size_t StreamLen = FS->getLength();
if (StreamLen % sizeof(object::FpoData))
OpenPOWER on IntegriCloud