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    :  static_assert(arraysize(IndexedFrequencyDataTypeName) ==
  42    :                    IndexedFrequencyData::MAX_DATA_TYPE,
  43    :                "Length mismatch");
  44    :  
  45    :  bool IndexedFrequencyDataTypeToString(IndexedFrequencyData::DataType type,
  46  E :                                        std::string* result) {
  47  E :    DCHECK(result != NULL);
  48    :    if (type > IndexedFrequencyData::INVALID_DATA_TYPE &&
  49  E :        type < IndexedFrequencyData::MAX_DATA_TYPE) {
  50  E :      *result = IndexedFrequencyDataTypeName[type];
  51  E :      return true;
  52    :    }
  53    :  
  54  i :    return false;
  55  E :  }
  56    :  
  57    :  bool ParseFrequencyDataType(const base::StringPiece& str,
  58  E :                              IndexedFrequencyData::DataType* type) {
  59  E :    DCHECK(type != NULL);
  60  E :    for (int i = 1; i < IndexedFrequencyData::MAX_DATA_TYPE; ++i) {
  61  E :      if (str.compare(IndexedFrequencyDataTypeName[i]) == 0) {
  62  E :        *type = static_cast<IndexedFrequencyData::DataType>(i);
  63  E :        return true;
  64    :      }
  65  E :    }
  66  i :    return false;
  67  E :  }
  68    :  
  69    :  }  // namespace common

Coverage information generated Thu Jan 14 17:40:38 2016.