LCOV - code coverage report
Current view: top level - lib/DebugInfo/PDB/Raw - ModStream.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 25 36 69.4 %
Date: 2017-01-24 23:09:07 Functions: 4 5 80.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===- ModStream.cpp - PDB Module Info Stream Access ----------------------===//
       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/ADT/iterator_range.h"
      11             : #include "llvm/DebugInfo/CodeView/SymbolRecord.h"
      12             : #include "llvm/DebugInfo/MSF/StreamReader.h"
      13             : #include "llvm/DebugInfo/MSF/StreamRef.h"
      14             : #include "llvm/DebugInfo/PDB/Raw/ModInfo.h"
      15             : #include "llvm/DebugInfo/PDB/Raw/ModStream.h"
      16             : #include "llvm/DebugInfo/PDB/Raw/PDBFile.h"
      17             : #include "llvm/DebugInfo/PDB/Raw/RawError.h"
      18             : #include "llvm/DebugInfo/PDB/Raw/RawTypes.h"
      19             : #include "llvm/Support/Error.h"
      20             : #include <algorithm>
      21             : #include <cstdint>
      22             : 
      23             : using namespace llvm;
      24             : using namespace llvm::msf;
      25             : using namespace llvm::pdb;
      26             : 
      27           6 : ModStream::ModStream(const ModInfo &Module,
      28           6 :                      std::unique_ptr<MappedBlockStream> Stream)
      29          42 :     : Mod(Module), Stream(std::move(Stream)) {}
      30             : 
      31             : ModStream::~ModStream() = default;
      32             : 
      33           6 : Error ModStream::reload() {
      34          18 :   StreamReader Reader(*Stream);
      35             : 
      36           6 :   uint32_t SymbolSize = Mod.getSymbolDebugInfoByteSize();
      37           6 :   uint32_t C11Size = Mod.getLineInfoByteSize();
      38           6 :   uint32_t C13Size = Mod.getC13LineInfoByteSize();
      39             : 
      40           6 :   if (C11Size > 0 && C13Size > 0)
      41             :     return make_error<RawError>(raw_error_code::corrupt_file,
      42           0 :                                 "Module has both C11 and C13 line info");
      43             : 
      44           6 :   ReadableStreamRef S;
      45             : 
      46          18 :   if (auto EC = Reader.readInteger(Signature))
      47           0 :     return EC;
      48          18 :   if (auto EC = Reader.readArray(SymbolsSubstream, SymbolSize - 4))
      49           0 :     return EC;
      50             : 
      51          18 :   if (auto EC = Reader.readStreamRef(LinesSubstream, C11Size))
      52           0 :     return EC;
      53          18 :   if (auto EC = Reader.readStreamRef(C13LinesSubstream, C13Size))
      54           0 :     return EC;
      55             : 
      56           6 :   StreamReader LineReader(C13LinesSubstream);
      57          18 :   if (auto EC = LineReader.readArray(LineInfo, LineReader.bytesRemaining()))
      58           0 :     return EC;
      59             : 
      60             :   uint32_t GlobalRefsSize;
      61          18 :   if (auto EC = Reader.readInteger(GlobalRefsSize))
      62           0 :     return EC;
      63          18 :   if (auto EC = Reader.readStreamRef(GlobalRefsSubstream, GlobalRefsSize))
      64           0 :     return EC;
      65           6 :   if (Reader.bytesRemaining() > 0)
      66             :     return make_error<RawError>(raw_error_code::corrupt_file,
      67           0 :                                 "Unexpected bytes in module stream.");
      68             : 
      69          18 :   return Error::success();
      70             : }
      71             : 
      72             : iterator_range<codeview::CVSymbolArray::Iterator>
      73           6 : ModStream::symbols(bool *HadError) const {
      74             :   // It's OK if the stream is empty.
      75           6 :   if (SymbolsSubstream.getUnderlyingStream().getLength() == 0)
      76           0 :     return make_range(SymbolsSubstream.end(), SymbolsSubstream.end());
      77          30 :   return make_range(SymbolsSubstream.begin(HadError), SymbolsSubstream.end());
      78             : }
      79             : 
      80             : iterator_range<codeview::ModuleSubstreamArray::Iterator>
      81           4 : ModStream::lines(bool *HadError) const {
      82          16 :   return make_range(LineInfo.begin(HadError), LineInfo.end());
      83             : }
      84             : 
      85           0 : Error ModStream::commit() { return Error::success(); }

Generated by: LCOV version 1.13