summaryrefslogtreecommitdiffstats
path: root/llvm/lib/DebugInfo/PDB/Raw/DbiStream.cpp
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2016-06-03 05:52:57 +0000
committerZachary Turner <zturner@google.com>2016-06-03 05:52:57 +0000
commit3df1bfaaec1c70c6501f01868bcd81764c9582e9 (patch)
treeb1451ece7ed3236beda44a10c3e9f514decd66dd /llvm/lib/DebugInfo/PDB/Raw/DbiStream.cpp
parente7ae106147bfa93390e1b275829c93cc60712aa4 (diff)
downloadbcm5719-llvm-3df1bfaaec1c70c6501f01868bcd81764c9582e9.tar.gz
bcm5719-llvm-3df1bfaaec1c70c6501f01868bcd81764c9582e9.zip
[pdb] Print out file names instead of file offsets.
When printing line information and file checksums, we were printing the file offset field from the struct header. This teaches llvm-pdbdump how to turn those numbers into the filename. In the case of file checksums, this is done by looking in the global string table. In the case of line contributions, this is done by indexing into the file names buffer of the DBI stream. Why they use a different technique I don't know. llvm-svn: 271630
Diffstat (limited to 'llvm/lib/DebugInfo/PDB/Raw/DbiStream.cpp')
-rw-r--r--llvm/lib/DebugInfo/PDB/Raw/DbiStream.cpp26
1 files changed, 18 insertions, 8 deletions
diff --git a/llvm/lib/DebugInfo/PDB/Raw/DbiStream.cpp b/llvm/lib/DebugInfo/PDB/Raw/DbiStream.cpp
index 8c46957706e..e79d6572be1 100644
--- a/llvm/lib/DebugInfo/PDB/Raw/DbiStream.cpp
+++ b/llvm/lib/DebugInfo/PDB/Raw/DbiStream.cpp
@@ -345,7 +345,6 @@ Error DbiStream::initializeFileInfo() {
FixedStreamArray<ulittle16_t> ModIndexArray;
FixedStreamArray<ulittle16_t> ModFileCountArray;
- FixedStreamArray<little32_t> FileNameOffsets;
// First is an array of `NumModules` module indices. This is not used for the
// same reason that `NumSourceFiles` is not used. It's an array of uint16's,
@@ -373,10 +372,8 @@ Error DbiStream::initializeFileInfo() {
if (auto EC = FISR.readArray(FileNameOffsets, NumSourceFiles))
return EC;
- StreamRef NamesBufferRef;
- if (auto EC = FISR.readStreamRef(NamesBufferRef))
+ if (auto EC = FISR.readStreamRef(NamesBuffer))
return EC;
- StreamReader Names(NamesBufferRef);
// We go through each ModuleInfo, determine the number N of source files for
// that module, and then get the next N offsets from the Offsets array, using
@@ -387,10 +384,10 @@ Error DbiStream::initializeFileInfo() {
uint32_t NumFiles = ModFileCountArray[I];
ModuleInfos[I].SourceFiles.resize(NumFiles);
for (size_t J = 0; J < NumFiles; ++J, ++NextFileIndex) {
- uint32_t FileOffset = FileNameOffsets[NextFileIndex];
- Names.setOffset(FileOffset);
- if (auto EC = Names.readZeroString(ModuleInfos[I].SourceFiles[J]))
- return EC;
+ if (auto Name = getFileNameForIndex(NextFileIndex))
+ ModuleInfos[I].SourceFiles[J] = Name.get();
+ else
+ return Name.takeError();
}
}
@@ -400,3 +397,16 @@ Error DbiStream::initializeFileInfo() {
uint32_t DbiStream::getDebugStreamIndex(DbgHeaderType Type) const {
return DbgStreams[static_cast<uint16_t>(Type)];
}
+
+Expected<StringRef> DbiStream::getFileNameForIndex(uint32_t Index) const {
+ StreamReader Names(NamesBuffer);
+ if (Index >= FileNameOffsets.size())
+ return make_error<RawError>(raw_error_code::index_out_of_bounds);
+
+ uint32_t FileOffset = FileNameOffsets[Index];
+ Names.setOffset(FileOffset);
+ StringRef Name;
+ if (auto EC = Names.readZeroString(Name))
+ return std::move(EC);
+ return Name;
+}
OpenPOWER on IntegriCloud