blob: 3b7e7029f73100ba3b02fe6d4715291d5446d3a5 [file] [log] [blame]
// Copyright 2012 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "syzygy/common/indexed_frequency_data.h"
#include "base/logging.h"
namespace common {
const uint32 kBasicBlockCoverageAgentId = 0xC05E4A6E;
const uint32 kBasicBlockEntryAgentId = 0xBBEABBEA;
const uint32 kJumpTableCountAgentId = 0x07AB1E0C;
// This should be incremented when incompatible changes are made to a tracing
// client.
const uint32 kBasicBlockFrequencyDataVersion = 1;
const uint32 kBranchFrequencyDataVersion = 1;
const uint32 kJumpTableFrequencyDataVersion = 1;
const char kBasicBlockRangesStreamName[] = "/Syzygy/BasicBlockRanges";
// This must be kept in sync with IndexedFrequencyDataType::DataType.
const char* IndexedFrequencyDataTypeName[] = {
NULL,
"basic-block",
"branch",
"coverage",
"jumptable",
};
COMPILE_ASSERT(arraysize(IndexedFrequencyDataTypeName) ==
IndexedFrequencyData::MAX_DATA_TYPE, length_mismatch);
bool IndexedFrequencyDataTypeToString(IndexedFrequencyData::DataType type,
std::string* result) {
DCHECK(result != NULL);
if (type > IndexedFrequencyData::INVALID_DATA_TYPE &&
type < IndexedFrequencyData::MAX_DATA_TYPE) {
*result = IndexedFrequencyDataTypeName[type];
return true;
}
return false;
}
bool ParseFrequencyDataType(const base::StringPiece& str,
IndexedFrequencyData::DataType* type) {
DCHECK(type != NULL);
for (int i = 1; i < IndexedFrequencyData::MAX_DATA_TYPE; ++i) {
if (str.compare(IndexedFrequencyDataTypeName[i]) == 0) {
*type = static_cast<IndexedFrequencyData::DataType>(i);
return true;
}
}
return false;
}
} // namespace common