LCOV - code coverage report
Current view: top level - lib/DebugInfo/CodeView - DebugFrameDataSubsection.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 23 24 95.8 %
Date: 2018-10-20 13:21:21 Functions: 5 5 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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             : 
      16          94 : Error DebugFrameDataSubsectionRef::initialize(BinaryStreamReader Reader) {
      17          94 :   if (Reader.bytesRemaining() % sizeof(FrameData) != 0) {
      18         184 :     if (auto EC = Reader.readObject(RelocPtr))
      19             :       return EC;
      20             :   }
      21             : 
      22          94 :   if (Reader.bytesRemaining() % sizeof(FrameData) != 0)
      23             :     return make_error<CodeViewError>(cv_error_code::corrupt_record,
      24             :                                      "Invalid frame data record format!");
      25             : 
      26          94 :   uint32_t Count = Reader.bytesRemaining() / sizeof(FrameData);
      27         188 :   if (auto EC = Reader.readArray(Frames, Count))
      28             :     return EC;
      29             :   return Error::success();
      30             : }
      31             : 
      32          14 : Error DebugFrameDataSubsectionRef::initialize(BinaryStreamRef Section) {
      33          14 :   BinaryStreamReader Reader(Section);
      34          28 :   return initialize(Reader);
      35             : }
      36             : 
      37          12 : uint32_t DebugFrameDataSubsection::calculateSerializedSize() const {
      38          12 :   uint32_t Size = sizeof(FrameData) * Frames.size();
      39          12 :   if (IncludeRelocPtr)
      40           7 :     Size += sizeof(uint32_t);
      41          12 :   return Size;
      42             : }
      43             : 
      44           8 : Error DebugFrameDataSubsection::commit(BinaryStreamWriter &Writer) const {
      45           8 :   if (IncludeRelocPtr) {
      46           6 :     if (auto EC = Writer.writeInteger<uint32_t>(0))
      47             :       return EC;
      48             :   }
      49             : 
      50           8 :   std::vector<FrameData> SortedFrames(Frames.begin(), Frames.end());
      51           8 :   std::sort(SortedFrames.begin(), SortedFrames.end(),
      52             :             [](const FrameData &LHS, const FrameData &RHS) {
      53           0 :               return LHS.RvaStart < RHS.RvaStart;
      54             :             });
      55          16 :   if (auto EC = Writer.writeArray(makeArrayRef(SortedFrames)))
      56             :     return EC;
      57             :   return Error::success();
      58             : }
      59             : 
      60          46 : void DebugFrameDataSubsection::addFrameData(const FrameData &Frame) {
      61          46 :   Frames.push_back(Frame);
      62          46 : }

Generated by: LCOV version 1.13