• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===- DebugFrameDataSubsection.cpp -----------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #include "llvm/DebugInfo/CodeView/DebugFrameDataSubsection.h"
11 #include "llvm/DebugInfo/CodeView/CodeViewError.h"
12 
13 using namespace llvm;
14 using namespace llvm::codeview;
15 
initialize(BinaryStreamReader Reader)16 Error DebugFrameDataSubsectionRef::initialize(BinaryStreamReader Reader) {
17   if (auto EC = Reader.readObject(RelocPtr))
18     return EC;
19   if (Reader.bytesRemaining() % sizeof(FrameData) != 0)
20     return make_error<CodeViewError>(cv_error_code::corrupt_record,
21                                      "Invalid frame data record format!");
22 
23   uint32_t Count = Reader.bytesRemaining() / sizeof(FrameData);
24   if (auto EC = Reader.readArray(Frames, Count))
25     return EC;
26   return Error::success();
27 }
28 
calculateSerializedSize() const29 uint32_t DebugFrameDataSubsection::calculateSerializedSize() const {
30   return 4 + sizeof(FrameData) * Frames.size();
31 }
32 
commit(BinaryStreamWriter & Writer) const33 Error DebugFrameDataSubsection::commit(BinaryStreamWriter &Writer) const {
34   if (auto EC = Writer.writeInteger<uint32_t>(0))
35     return EC;
36 
37   if (auto EC = Writer.writeArray(makeArrayRef(Frames)))
38     return EC;
39   return Error::success();
40 }
41 
addFrameData(const FrameData & Frame)42 void DebugFrameDataSubsection::addFrameData(const FrameData &Frame) {
43   Frames.push_back(Frame);
44 }
45