LCOV - code coverage report
Current view: top level - lib/DebugInfo/CodeView - SymbolSerializer.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 20 24 83.3 %
Date: 2017-09-14 15:23:50 Functions: 3 3 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===- SymbolSerializer.cpp -----------------------------------------------===//
       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/SymbolSerializer.h"
      11             : #include "llvm/ADT/ArrayRef.h"
      12             : #include "llvm/DebugInfo/CodeView/SymbolRecord.h"
      13             : #include "llvm/Support/Endian.h"
      14             : #include "llvm/Support/Error.h"
      15             : #include <cassert>
      16             : #include <cstdint>
      17             : #include <cstring>
      18             : 
      19             : using namespace llvm;
      20             : using namespace llvm::codeview;
      21             : 
      22         625 : SymbolSerializer::SymbolSerializer(BumpPtrAllocator &Allocator,
      23         625 :                                    CodeViewContainer Container)
      24             :     : Storage(Allocator), Stream(RecordBuffer, support::little), Writer(Stream),
      25        3125 :       Mapping(Writer, Container) {}
      26             : 
      27         585 : Error SymbolSerializer::visitSymbolBegin(CVSymbol &Record) {
      28             :   assert(!CurrentSymbol.hasValue() && "Already in a symbol mapping!");
      29             : 
      30        1170 :   Writer.setOffset(0);
      31             : 
      32        1755 :   if (auto EC = writeRecordPrefix(Record.kind()))
      33           0 :     return EC;
      34             : 
      35        1170 :   CurrentSymbol = Record.kind();
      36        1755 :   if (auto EC = Mapping.visitSymbolBegin(Record))
      37           0 :     return EC;
      38             : 
      39        1755 :   return Error::success();
      40             : }
      41             : 
      42         585 : Error SymbolSerializer::visitSymbolEnd(CVSymbol &Record) {
      43             :   assert(CurrentSymbol.hasValue() && "Not in a symbol mapping!");
      44             : 
      45        1755 :   if (auto EC = Mapping.visitSymbolEnd(Record))
      46           0 :     return EC;
      47             : 
      48         585 :   uint32_t RecordEnd = Writer.getOffset();
      49         585 :   uint16_t Length = RecordEnd - 2;
      50        1170 :   Writer.setOffset(0);
      51        1755 :   if (auto EC = Writer.writeInteger(Length))
      52           0 :     return EC;
      53             : 
      54        1170 :   uint8_t *StableStorage = Storage.Allocate<uint8_t>(RecordEnd);
      55        1170 :   ::memcpy(StableStorage, &RecordBuffer[0], RecordEnd);
      56         585 :   Record.RecordData = ArrayRef<uint8_t>(StableStorage, RecordEnd);
      57        1170 :   CurrentSymbol.reset();
      58             : 
      59        1755 :   return Error::success();
      60             : }

Generated by: LCOV version 1.13