Coverage for /Syzygy/common/indexed_frequency_data.cc

CoverageLines executed / instrumented / missingexe / inst / missLanguageGroup
87.5%14160.C++source

Line-by-line coverage:

   1    :  // Copyright 2012 Google Inc. All Rights Reserved.
   2    :  //
   3    :  // Licensed under the Apache License, Version 2.0 (the "License");
   4    :  // you may not use this file except in compliance with the License.
   5    :  // You may obtain a copy of the License at
   6    :  //
   7    :  //     http://www.apache.org/licenses/LICENSE-2.0
   8    :  //
   9    :  // Unless required by applicable law or agreed to in writing, software
  10    :  // distributed under the License is distributed on an "AS IS" BASIS,
  11    :  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12    :  // See the License for the specific language governing permissions and
  13    :  // limitations under the License.
  14    :  
  15    :  #include "syzygy/common/indexed_frequency_data.h"
  16    :  
  17    :  #include "base/logging.h"
  18    :  
  19    :  namespace common {
  20    :  
  21    :  const uint32 kBasicBlockCoverageAgentId = 0xC05E4A6E;
  22    :  const uint32 kBasicBlockEntryAgentId = 0xBBEABBEA;
  23    :  const uint32 kJumpTableCountAgentId = 0x07AB1E0C;
  24    :  
  25    :  // This should be incremented when incompatible changes are made to a tracing
  26    :  // client.
  27    :  const uint32 kBasicBlockFrequencyDataVersion = 1;
  28    :  const uint32 kBranchFrequencyDataVersion = 1;
  29    :  const uint32 kJumpTableFrequencyDataVersion = 1;
  30    :  
  31    :  const char kBasicBlockRangesStreamName[] = "/Syzygy/BasicBlockRanges";
  32    :  
  33    :  // This must be kept in sync with IndexedFrequencyDataType::DataType.
  34    :  const char* IndexedFrequencyDataTypeName[] = {
  35    :    NULL,
  36    :    "basic-block",
  37    :    "branch",
  38    :    "coverage",
  39    :    "jumptable",
  40    :  };
  41    :  COMPILE_ASSERT(arraysize(IndexedFrequencyDataTypeName) ==
  42    :      IndexedFrequencyData::MAX_DATA_TYPE, length_mismatch);
  43    :  
  44    :  bool IndexedFrequencyDataTypeToString(IndexedFrequencyData::DataType type,
  45  E :                                        std::string* result) {
  46  E :    DCHECK(result != NULL);
  47    :    if (type > IndexedFrequencyData::INVALID_DATA_TYPE &&
  48  E :        type < IndexedFrequencyData::MAX_DATA_TYPE) {
  49  E :      *result = IndexedFrequencyDataTypeName[type];
  50  E :      return true;
  51    :    }
  52    :  
  53  i :    return false;
  54  E :  }
  55    :  
  56    :  bool ParseFrequencyDataType(const base::StringPiece& str,
  57  E :                              IndexedFrequencyData::DataType* type) {
  58  E :    DCHECK(type != NULL);
  59  E :    for (int i = 1; i < IndexedFrequencyData::MAX_DATA_TYPE; ++i) {
  60  E :      if (str.compare(IndexedFrequencyDataTypeName[i]) == 0) {
  61  E :        *type = static_cast<IndexedFrequencyData::DataType>(i);
  62  E :        return true;
  63    :      }
  64  E :    }
  65  i :    return false;
  66  E :  }
  67    :  
  68    :  }  // namespace common

Coverage information generated Thu Mar 26 16:15:41 2015.