event_type.h revision 67d3abd7b26a741347b33402ad32f5c6735ca0bd
167d3abd7b26a741347b33402ad32f5c6735ca0bdYabin Cui/* 267d3abd7b26a741347b33402ad32f5c6735ca0bdYabin Cui * Copyright (C) 2015 The Android Open Source Project 367d3abd7b26a741347b33402ad32f5c6735ca0bdYabin Cui * 467d3abd7b26a741347b33402ad32f5c6735ca0bdYabin Cui * Licensed under the Apache License, Version 2.0 (the "License"); 567d3abd7b26a741347b33402ad32f5c6735ca0bdYabin Cui * you may not use this file except in compliance with the License. 667d3abd7b26a741347b33402ad32f5c6735ca0bdYabin Cui * You may obtain a copy of the License at 767d3abd7b26a741347b33402ad32f5c6735ca0bdYabin Cui * 867d3abd7b26a741347b33402ad32f5c6735ca0bdYabin Cui * http://www.apache.org/licenses/LICENSE-2.0 967d3abd7b26a741347b33402ad32f5c6735ca0bdYabin Cui * 1067d3abd7b26a741347b33402ad32f5c6735ca0bdYabin Cui * Unless required by applicable law or agreed to in writing, software 1167d3abd7b26a741347b33402ad32f5c6735ca0bdYabin Cui * distributed under the License is distributed on an "AS IS" BASIS, 1267d3abd7b26a741347b33402ad32f5c6735ca0bdYabin Cui * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1367d3abd7b26a741347b33402ad32f5c6735ca0bdYabin Cui * See the License for the specific language governing permissions and 1467d3abd7b26a741347b33402ad32f5c6735ca0bdYabin Cui * limitations under the License. 1567d3abd7b26a741347b33402ad32f5c6735ca0bdYabin Cui */ 1667d3abd7b26a741347b33402ad32f5c6735ca0bdYabin Cui 1767d3abd7b26a741347b33402ad32f5c6735ca0bdYabin Cui#ifndef SIMPLE_PERF_EVENT_H_ 1867d3abd7b26a741347b33402ad32f5c6735ca0bdYabin Cui#define SIMPLE_PERF_EVENT_H_ 1967d3abd7b26a741347b33402ad32f5c6735ca0bdYabin Cui 2067d3abd7b26a741347b33402ad32f5c6735ca0bdYabin Cui#include <stdint.h> 2167d3abd7b26a741347b33402ad32f5c6735ca0bdYabin Cui#include <string> 2267d3abd7b26a741347b33402ad32f5c6735ca0bdYabin Cui#include <vector> 2367d3abd7b26a741347b33402ad32f5c6735ca0bdYabin Cui 2467d3abd7b26a741347b33402ad32f5c6735ca0bdYabin Cui// EventType represents one type of event, like cpu_cycle_event, cache_misses_event. 2567d3abd7b26a741347b33402ad32f5c6735ca0bdYabin Cui// The user knows one event type by its name, and the kernel knows one event type by its 2667d3abd7b26a741347b33402ad32f5c6735ca0bdYabin Cui// (type, config) pair. EventType connects the two representations, and tells the user if 2767d3abd7b26a741347b33402ad32f5c6735ca0bdYabin Cui// the event type is supported by the kernel. 2867d3abd7b26a741347b33402ad32f5c6735ca0bdYabin Cui 2967d3abd7b26a741347b33402ad32f5c6735ca0bdYabin Cuistruct EventType { 3067d3abd7b26a741347b33402ad32f5c6735ca0bdYabin Cui bool IsSupportedByKernel() const; 3167d3abd7b26a741347b33402ad32f5c6735ca0bdYabin Cui 3267d3abd7b26a741347b33402ad32f5c6735ca0bdYabin Cui const char* name; 3367d3abd7b26a741347b33402ad32f5c6735ca0bdYabin Cui uint32_t type; 3467d3abd7b26a741347b33402ad32f5c6735ca0bdYabin Cui uint64_t config; 3567d3abd7b26a741347b33402ad32f5c6735ca0bdYabin Cui}; 3667d3abd7b26a741347b33402ad32f5c6735ca0bdYabin Cui 3767d3abd7b26a741347b33402ad32f5c6735ca0bdYabin Cuiclass EventTypeFactory { 3867d3abd7b26a741347b33402ad32f5c6735ca0bdYabin Cui public: 3967d3abd7b26a741347b33402ad32f5c6735ca0bdYabin Cui static const std::vector<const EventType>& GetAllEventTypes(); 4067d3abd7b26a741347b33402ad32f5c6735ca0bdYabin Cui static const EventType* FindEventTypeByName(const std::string& name); 4167d3abd7b26a741347b33402ad32f5c6735ca0bdYabin Cui static const EventType* FindEventTypeByConfig(uint32_t type, uint64_t config); 4267d3abd7b26a741347b33402ad32f5c6735ca0bdYabin Cui}; 4367d3abd7b26a741347b33402ad32f5c6735ca0bdYabin Cui 4467d3abd7b26a741347b33402ad32f5c6735ca0bdYabin Cui#endif // SIMPLE_PERF_EVENT_H_ 45