summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2017-05-02 16:56:09 +0000
committerZachary Turner <zturner@google.com>2017-05-02 16:56:09 +0000
commitedef14510e36f307dff256faf030abbfb27be674 (patch)
tree5fd726720d7bd48b7b9059d2ac99826ffffb1580 /llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp
parentbb34f278a2e12f8af526b34725fd2b61c5c8c189 (diff)
downloadbcm5719-llvm-edef14510e36f307dff256faf030abbfb27be674.tar.gz
bcm5719-llvm-edef14510e36f307dff256faf030abbfb27be674.zip
[PDB/CodeView] Read/write codeview inlinee line information.
Previously we wrote line information and file checksum information, but we did not write information about inlinee lines and functions. This patch adds support for that. llvm-svn: 301936
Diffstat (limited to 'llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp')
-rw-r--r--llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp65
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));
}
}
}
OpenPOWER on IntegriCloud