LCOV - code coverage report
Current view: top level - lib/DebugInfo/Msf - MsfCommon.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 7 12 58.3 %
Date: 2016-07-29 04:53:09 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===- MsfCommon.cpp - Common types and functions for MSF files -*- 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/Msf/MsfCommon.h"
      11             : #include "llvm/DebugInfo/Msf/MsfError.h"
      12             : 
      13             : using namespace llvm;
      14             : using namespace llvm::msf;
      15             : 
      16           8 : Error llvm::msf::validateSuperBlock(const SuperBlock &SB) {
      17             :   // Check the magic bytes.
      18           8 :   if (std::memcmp(SB.MagicBytes, Magic, sizeof(Magic)) != 0)
      19             :     return make_error<MsfError>(msf_error_code::invalid_format,
      20           0 :                                 "MSF magic header doesn't match");
      21             : 
      22          24 :   if (!isValidBlockSize(SB.BlockSize))
      23             :     return make_error<MsfError>(msf_error_code::invalid_format,
      24           0 :                                 "Unsupported block size.");
      25             : 
      26             :   // We don't support directories whose sizes aren't a multiple of four bytes.
      27          16 :   if (SB.NumDirectoryBytes % sizeof(support::ulittle32_t) != 0)
      28             :     return make_error<MsfError>(msf_error_code::invalid_format,
      29           0 :                                 "Directory size is not multiple of 4.");
      30             : 
      31             :   // The number of blocks which comprise the directory is a simple function of
      32             :   // the number of bytes it contains.
      33             :   uint64_t NumDirectoryBlocks =
      34          32 :       bytesToBlocks(SB.NumDirectoryBytes, SB.BlockSize);
      35             : 
      36             :   // The directory, as we understand it, is a block which consists of a list of
      37             :   // block numbers.  It is unclear what would happen if the number of blocks
      38             :   // couldn't fit on a single block.
      39          16 :   if (NumDirectoryBlocks > SB.BlockSize / sizeof(support::ulittle32_t))
      40             :     return make_error<MsfError>(msf_error_code::invalid_format,
      41           0 :                                 "Too many directory blocks.");
      42             : 
      43          16 :   if (SB.BlockMapAddr == 0)
      44             :     return make_error<MsfError>(msf_error_code::invalid_format,
      45           0 :                                 "Block 0 is reserved");
      46             : 
      47             :   return Error::success();
      48             : }

Generated by: LCOV version 1.12