summaryrefslogtreecommitdiffstats
path: root/llvm/lib/DebugInfo/CodeView/ModuleDebugFileChecksumFragment.cpp
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2017-05-01 23:27:42 +0000
committerZachary Turner <zturner@google.com>2017-05-01 23:27:42 +0000
commit8a2ebfb1cdff1af0c3b670ac889d50e640cf4abb (patch)
tree29c8ec2121aa674d31c0ecf6c7fc238ceae2c001 /llvm/lib/DebugInfo/CodeView/ModuleDebugFileChecksumFragment.cpp
parent3bb6eb238e3f0bf571f96a6214eebfdf2d2dcf09 (diff)
downloadbcm5719-llvm-8a2ebfb1cdff1af0c3b670ac889d50e640cf4abb.tar.gz
bcm5719-llvm-8a2ebfb1cdff1af0c3b670ac889d50e640cf4abb.zip
[CodeView] Write CodeView line information.
Differential Revision: https://reviews.llvm.org/D32716 llvm-svn: 301882
Diffstat (limited to 'llvm/lib/DebugInfo/CodeView/ModuleDebugFileChecksumFragment.cpp')
-rw-r--r--llvm/lib/DebugInfo/CodeView/ModuleDebugFileChecksumFragment.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/llvm/lib/DebugInfo/CodeView/ModuleDebugFileChecksumFragment.cpp b/llvm/lib/DebugInfo/CodeView/ModuleDebugFileChecksumFragment.cpp
index 4bbfe285423..79e5b9d690d 100644
--- a/llvm/lib/DebugInfo/CodeView/ModuleDebugFileChecksumFragment.cpp
+++ b/llvm/lib/DebugInfo/CodeView/ModuleDebugFileChecksumFragment.cpp
@@ -48,3 +48,50 @@ Error ModuleDebugFileChecksumFragmentRef::initialize(
return Error::success();
}
+
+ModuleDebugFileChecksumFragment::ModuleDebugFileChecksumFragment()
+ : ModuleDebugFragment(ModuleDebugFragmentKind::FileChecksums) {}
+
+void ModuleDebugFileChecksumFragment::addChecksum(uint32_t StringTableOffset,
+ FileChecksumKind Kind,
+ ArrayRef<uint8_t> Bytes) {
+ FileChecksumEntry Entry;
+ if (!Bytes.empty()) {
+ uint8_t *Copy = Storage.Allocate<uint8_t>(Bytes.size());
+ ::memcpy(Copy, Bytes.data(), Bytes.size());
+ Entry.Checksum = makeArrayRef(Copy, Bytes.size());
+ }
+ Entry.FileNameOffset = StringTableOffset;
+ Entry.Kind = Kind;
+ Checksums.push_back(Entry);
+
+ // This maps the offset of this string in the string table to the offset
+ // of this checksum entry in the checksum buffer.
+ OffsetMap[StringTableOffset] = SerializedSize;
+ SerializedSize += sizeof(FileChecksumEntryHeader) + Bytes.size();
+}
+
+uint32_t ModuleDebugFileChecksumFragment::calculateSerializedLength() {
+ return SerializedSize;
+}
+
+Error ModuleDebugFileChecksumFragment::commit(BinaryStreamWriter &Writer) {
+ for (const auto &FC : Checksums) {
+ FileChecksumEntryHeader Header;
+ Header.ChecksumKind = uint8_t(FC.Kind);
+ Header.ChecksumSize = FC.Checksum.size();
+ Header.FileNameOffset = FC.FileNameOffset;
+ if (auto EC = Writer.writeObject(Header))
+ return EC;
+ if (auto EC = Writer.writeArray(makeArrayRef(FC.Checksum)))
+ return EC;
+ }
+ return Error::success();
+}
+
+uint32_t ModuleDebugFileChecksumFragment::mapChecksumOffset(
+ uint32_t StringTableOffset) const {
+ auto Iter = OffsetMap.find(StringTableOffset);
+ assert(Iter != OffsetMap.end());
+ return Iter->second;
+}
OpenPOWER on IntegriCloud