diff options
Diffstat (limited to 'llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp')
-rw-r--r-- | llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp | 65 |
1 files changed, 48 insertions, 17 deletions
diff --git a/llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp b/llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp index 0bbc49eadbb..642e169613b 100644 --- a/llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp +++ b/llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp @@ -31,6 +31,9 @@ #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringExtras.h" #include "llvm/Config/config.h" +#include "llvm/DebugInfo/CodeView/ModuleDebugFileChecksumFragment.h" +#include "llvm/DebugInfo/CodeView/ModuleDebugInlineeLinesFragment.h" +#include "llvm/DebugInfo/CodeView/ModuleDebugLineFragment.h" #include "llvm/DebugInfo/MSF/MSFBuilder.h" #include "llvm/DebugInfo/PDB/GenericError.h" #include "llvm/DebugInfo/PDB/IPDBEnumChildren.h" @@ -421,6 +424,21 @@ cl::list<std::string> InputFilename(cl::Positional, static ExitOnError ExitOnErr; +static uint32_t +getFileChecksumOffset(StringRef FileName, + ModuleDebugFileChecksumFragment &Checksums, + StringTableBuilder &Strings) { + // The offset in the line info record is the offset of the checksum + // entry for the corresponding file. That entry then contains an + // offset into the global string table of the file name. So to + // compute the proper offset to write into the line info record, we + // must first get its offset in the global string table, then ask the + // checksum builder to find the offset in its serialized buffer that + // it mapped that filename string table offset to. + uint32_t StringOffset = Strings.insert(FileName); + return Checksums.mapChecksumOffset(StringOffset); +} + static void yamlToPdb(StringRef Path) { BumpPtrAllocator Allocator; ErrorOr<std::unique_ptr<MemoryBuffer>> ErrorOrBuffer = @@ -503,12 +521,19 @@ static void yamlToPdb(StringRef Path) { if (!FLI.FileChecksums.empty()) { auto &Strings = Builder.getStringTableBuilder(); for (auto &FC : FLI.FileChecksums) { - uint32_t STOffset = Strings.getStringIndex(FC.FileName); + uint32_t STOffset = Strings.insert(FC.FileName); Checksums->addChecksum(STOffset, FC.Kind, FC.ChecksumBytes.Bytes); } } ModiBuilder.setC13FileChecksums(std::move(Checksums)); + // FIXME: StringTable / StringTableBuilder should really be in + // DebugInfoCodeView. This would allow us to construct the + // ModuleDebugLineFragment with a reference to the string table, + // and we could just pass strings around rather than having to + // remember how to calculate the right offset. + auto &Strings = Builder.getStringTableBuilder(); + for (const auto &Fragment : FLI.LineFragments) { auto Lines = llvm::make_unique<ModuleDebugLineFragment>(); Lines->setCodeSize(Fragment.CodeSize); @@ -516,21 +541,8 @@ static void yamlToPdb(StringRef Path) { Fragment.RelocOffset); Lines->setFlags(Fragment.Flags); for (const auto &LC : Fragment.Blocks) { - // FIXME: StringTable / StringTableBuilder should really be in - // DebugInfoCodeView. This would allow us to construct the - // ModuleDebugLineFragment with a reference to the string table, - // and we could just pass strings around rather than having to - // remember how to calculate the right offset. - auto &Strings = Builder.getStringTableBuilder(); - // The offset in the line info record is the offset of the checksum - // entry for the corresponding file. That entry then contains an - // offset into the global string table of the file name. So to - // compute the proper offset to write into the line info record, we - // must first get its offset in the global string table, then ask the - // checksum builder to find the offset in its serialized buffer that - // it mapped that filename string table offset to. - uint32_t StringOffset = Strings.getStringIndex(LC.FileName); - uint32_t ChecksumOffset = ChecksumRef.mapChecksumOffset(StringOffset); + uint32_t ChecksumOffset = + getFileChecksumOffset(LC.FileName, ChecksumRef, Strings); Lines->createBlock(ChecksumOffset); if (Lines->hasColumnInfo()) { @@ -550,7 +562,26 @@ static void yamlToPdb(StringRef Path) { } } } - ModiBuilder.addC13LineFragment(std::move(Lines)); + ModiBuilder.addC13Fragment(std::move(Lines)); + } + + for (const auto &Inlinee : FLI.Inlinees) { + auto Inlinees = llvm::make_unique<ModuleDebugInlineeLineFragment>( + Inlinee.HasExtraFiles); + for (const auto &Site : Inlinee.Sites) { + uint32_t FileOff = + getFileChecksumOffset(Site.FileName, ChecksumRef, Strings); + + Inlinees->addInlineSite(Site.Inlinee, FileOff, Site.SourceLineNum); + if (!Inlinee.HasExtraFiles) + continue; + + for (auto EF : Site.ExtraFiles) { + FileOff = getFileChecksumOffset(EF, ChecksumRef, Strings); + Inlinees->addExtraFile(FileOff); + } + } + ModiBuilder.addC13Fragment(std::move(Inlinees)); } } } |