aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/DebugInfo/CodeView/DebugFrameDataSubsection.cpp
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2018-09-11 22:35:01 +0000
committerZachary Turner <zturner@google.com>2018-09-11 22:35:01 +0000
commit42e7cc1b0fdf3428ebd0dfd70a6e4efe162e1cd3 (patch)
tree82a5c036ed41571d180b2a01d2cf3f5c01381b00 /llvm/lib/DebugInfo/CodeView/DebugFrameDataSubsection.cpp
parent697d6cb8eebc3449295e4f5952b21b4e8db37dc5 (diff)
downloadllvm-42e7cc1b0fdf3428ebd0dfd70a6e4efe162e1cd3.zip
llvm-42e7cc1b0fdf3428ebd0dfd70a6e4efe162e1cd3.tar.gz
llvm-42e7cc1b0fdf3428ebd0dfd70a6e4efe162e1cd3.tar.bz2
[PDB] Write FPO Data to the PDB.
llvm-svn: 342003
Diffstat (limited to 'llvm/lib/DebugInfo/CodeView/DebugFrameDataSubsection.cpp')
-rw-r--r--llvm/lib/DebugInfo/CodeView/DebugFrameDataSubsection.cpp32
1 files changed, 25 insertions, 7 deletions
diff --git a/llvm/lib/DebugInfo/CodeView/DebugFrameDataSubsection.cpp b/llvm/lib/DebugInfo/CodeView/DebugFrameDataSubsection.cpp
index fd558aa..5881bf1 100644
--- a/llvm/lib/DebugInfo/CodeView/DebugFrameDataSubsection.cpp
+++ b/llvm/lib/DebugInfo/CodeView/DebugFrameDataSubsection.cpp
@@ -14,8 +14,11 @@ using namespace llvm;
using namespace llvm::codeview;
Error DebugFrameDataSubsectionRef::initialize(BinaryStreamReader Reader) {
- if (auto EC = Reader.readObject(RelocPtr))
- return EC;
+ if (Reader.bytesRemaining() % sizeof(FrameData) != 0) {
+ if (auto EC = Reader.readObject(RelocPtr))
+ return EC;
+ }
+
if (Reader.bytesRemaining() % sizeof(FrameData) != 0)
return make_error<CodeViewError>(cv_error_code::corrupt_record,
"Invalid frame data record format!");
@@ -26,15 +29,30 @@ Error DebugFrameDataSubsectionRef::initialize(BinaryStreamReader Reader) {
return Error::success();
}
+Error DebugFrameDataSubsectionRef::initialize(BinaryStreamRef Section) {
+ BinaryStreamReader Reader(Section);
+ return initialize(Reader);
+}
+
uint32_t DebugFrameDataSubsection::calculateSerializedSize() const {
- return 4 + sizeof(FrameData) * Frames.size();
+ uint32_t Size = sizeof(FrameData) * Frames.size();
+ if (IncludeRelocPtr)
+ Size += sizeof(uint32_t);
+ return Size;
}
Error DebugFrameDataSubsection::commit(BinaryStreamWriter &Writer) const {
- if (auto EC = Writer.writeInteger<uint32_t>(0))
- return EC;
-
- if (auto EC = Writer.writeArray(makeArrayRef(Frames)))
+ if (IncludeRelocPtr) {
+ if (auto EC = Writer.writeInteger<uint32_t>(0))
+ return EC;
+ }
+
+ std::vector<FrameData> SortedFrames(Frames.begin(), Frames.end());
+ std::sort(SortedFrames.begin(), SortedFrames.end(),
+ [](const FrameData &LHS, const FrameData &RHS) {
+ return LHS.RvaStart < RHS.RvaStart;
+ });
+ if (auto EC = Writer.writeArray(makeArrayRef(SortedFrames)))
return EC;
return Error::success();
}