#include <android-base/file.h>
#include <android-base/logging.h>
+#include <android-base/strings.h>
#include "event_attr.h"
-#include "event_fd.h"
#include "utils.h"
-#define EVENT_TYPE_TABLE_ENTRY(name, type, config) {name, type, config},
+#define EVENT_TYPE_TABLE_ENTRY(name, type, config, description, limited_arch) \
+ {name, type, config, description, limited_arch},
static const std::vector<EventType> static_event_type_array = {
#include "event_type_table.h"
static const std::vector<EventType> GetTracepointEventTypes() {
std::vector<EventType> result;
+ if (!IsRoot()) {
+ // Not having permission to profile tracing events.
+ return result;
+ }
const std::string tracepoint_dirname = "/sys/kernel/debug/tracing/events";
- std::vector<std::string> system_dirs;
- GetEntriesInDir(tracepoint_dirname, nullptr, &system_dirs);
- for (auto& system_name : system_dirs) {
+ for (const auto& system_name : GetSubDirs(tracepoint_dirname)) {
std::string system_path = tracepoint_dirname + "/" + system_name;
- std::vector<std::string> event_dirs;
- GetEntriesInDir(system_path, nullptr, &event_dirs);
- for (auto& event_name : event_dirs) {
+ for (const auto& event_name : GetSubDirs(system_path)) {
std::string id_path = system_path + "/" + event_name + "/id";
std::string id_content;
if (!android::base::ReadFileToString(id_path, &id_content)) {
LOG(DEBUG) << "unexpected id '" << id_content << "' in " << id_path;
continue;
}
- result.push_back(EventType(system_name + ":" + event_name, PERF_TYPE_TRACEPOINT, id));
+ result.push_back(EventType(system_name + ":" + event_name, PERF_TYPE_TRACEPOINT, id, "", ""));
}
}
std::sort(result.begin(), result.end(),
return event_type_array;
}
-const EventType* FindEventTypeByConfig(uint32_t type, uint64_t config) {
- for (auto& event_type : GetAllEventTypes()) {
- if (event_type.type == type && event_type.config == config) {
- return &event_type;
- }
- }
- return nullptr;
-}
-
const EventType* FindEventTypeByName(const std::string& name) {
const EventType* result = nullptr;
for (auto& event_type : GetAllEventTypes()) {
- if (event_type.name == name) {
+ if (android::base::EqualsIgnoreCase(event_type.name, name)) {
result = &event_type;
break;
}