OSDN Git Service

simpleperf: accept different perf_attr sizes.
[android-x86/system-extras.git] / simpleperf / event_type.h
index b486a29..4100125 100644 (file)
@@ -18,6 +18,7 @@
 #define SIMPLE_PERF_EVENT_H_
 
 #include <stdint.h>
+#include <memory>
 #include <string>
 #include <vector>
 
 // the event type is supported by the kernel.
 
 struct EventType {
-  bool IsSupportedByKernel() const;
+  EventType(const std::string& name, uint32_t type, uint64_t config)
+      : name(name), type(type), config(config) {
+  }
 
-  const char* name;
+  EventType() : type(0), config(0) {
+  }
+
+  std::string name;
   uint32_t type;
   uint64_t config;
 };
 
-class EventTypeFactory {
- public:
-  static const std::vector<const EventType>& GetAllEventTypes();
-  static const EventType* FindEventTypeByName(const std::string& name,
-                                              bool report_unsupported_type = true);
-  static const EventType* FindEventTypeByConfig(uint32_t type, uint64_t config);
+const std::vector<EventType>& GetAllEventTypes();
+const EventType* FindEventTypeByConfig(uint32_t type, uint64_t config);
+const EventType* FindEventTypeByName(const std::string& name);
+
+struct EventTypeAndModifier {
+  std::string name;
+  EventType event_type;
+  std::string modifier;
+  bool exclude_user;
+  bool exclude_kernel;
+  bool exclude_hv;
+  bool exclude_host;
+  bool exclude_guest;
+  int precise_ip : 2;
+
+  EventTypeAndModifier()
+      : exclude_user(false),
+        exclude_kernel(false),
+        exclude_hv(false),
+        exclude_host(false),
+        exclude_guest(false),
+        precise_ip(0) {
+  }
 };
 
+std::unique_ptr<EventTypeAndModifier> ParseEventType(const std::string& event_type_str);
+
 #endif  // SIMPLE_PERF_EVENT_H_