summaryrefslogtreecommitdiffstats
path: root/llvm/lib/DebugInfo/CodeView/ModuleDebugFragmentRecord.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/ModuleDebugFragmentRecord.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/ModuleDebugFragmentRecord.cpp')
-rw-r--r--llvm/lib/DebugInfo/CodeView/ModuleDebugFragmentRecord.cpp38
1 files changed, 37 insertions, 1 deletions
diff --git a/llvm/lib/DebugInfo/CodeView/ModuleDebugFragmentRecord.cpp b/llvm/lib/DebugInfo/CodeView/ModuleDebugFragmentRecord.cpp
index 20c06e9bebe..263b632da3f 100644
--- a/llvm/lib/DebugInfo/CodeView/ModuleDebugFragmentRecord.cpp
+++ b/llvm/lib/DebugInfo/CodeView/ModuleDebugFragmentRecord.cpp
@@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//
#include "llvm/DebugInfo/CodeView/ModuleDebugFragmentRecord.h"
+#include "llvm/DebugInfo/CodeView/ModuleDebugFragment.h"
#include "llvm/Support/BinaryStreamReader.h"
@@ -30,6 +31,13 @@ Error ModuleDebugFragmentRecord::initialize(BinaryStreamRef Stream,
ModuleDebugFragmentKind Kind =
static_cast<ModuleDebugFragmentKind>(uint32_t(Header->Kind));
+ switch (Kind) {
+ case ModuleDebugFragmentKind::FileChecksums:
+ case ModuleDebugFragmentKind::Lines:
+ break;
+ default:
+ llvm_unreachable("Unexpected debug fragment kind!");
+ }
if (auto EC = Reader.readStreamRef(Info.Data, Header->Length))
return EC;
Info.Kind = Kind;
@@ -37,7 +45,9 @@ Error ModuleDebugFragmentRecord::initialize(BinaryStreamRef Stream,
}
uint32_t ModuleDebugFragmentRecord::getRecordLength() const {
- return sizeof(ModuleDebugFragmentHeader) + Data.getLength();
+ uint32_t Result = sizeof(ModuleDebugFragmentHeader) + Data.getLength();
+ assert(Result % 4 == 0);
+ return Result;
}
ModuleDebugFragmentKind ModuleDebugFragmentRecord::kind() const { return Kind; }
@@ -45,3 +55,29 @@ ModuleDebugFragmentKind ModuleDebugFragmentRecord::kind() const { return Kind; }
BinaryStreamRef ModuleDebugFragmentRecord::getRecordData() const {
return Data;
}
+
+ModuleDebugFragmentRecordBuilder::ModuleDebugFragmentRecordBuilder(
+ ModuleDebugFragmentKind Kind, ModuleDebugFragment &Frag)
+ : Kind(Kind), Frag(Frag) {}
+
+uint32_t ModuleDebugFragmentRecordBuilder::calculateSerializedLength() {
+ uint32_t Size = sizeof(ModuleDebugFragmentHeader) +
+ alignTo(Frag.calculateSerializedLength(), 4);
+ return Size;
+}
+
+Error ModuleDebugFragmentRecordBuilder::commit(BinaryStreamWriter &Writer) {
+ ModuleDebugFragmentHeader Header;
+ Header.Kind = uint32_t(Kind);
+ Header.Length =
+ calculateSerializedLength() - sizeof(ModuleDebugFragmentHeader);
+
+ if (auto EC = Writer.writeObject(Header))
+ return EC;
+ if (auto EC = Frag.commit(Writer))
+ return EC;
+ if (auto EC = Writer.padToAlignment(4))
+ return EC;
+
+ return Error::success();
+}
OpenPOWER on IntegriCloud