diff options
Diffstat (limited to 'simpleperf/event_selection_set.h')
-rw-r--r-- | simpleperf/event_selection_set.h | 49 |
1 files changed, 24 insertions, 25 deletions
diff --git a/simpleperf/event_selection_set.h b/simpleperf/event_selection_set.h index 53c8edda..32904c12 100644 --- a/simpleperf/event_selection_set.h +++ b/simpleperf/event_selection_set.h @@ -25,6 +25,7 @@ #include <android-base/macros.h> +#include "event_attr.h" #include "event_fd.h" #include "event_type.h" #include "perf_event.h" @@ -38,25 +39,13 @@ struct CounterInfo { PerfCounter counter; }; -struct EventSelection; - struct CountersInfo { - const EventSelection* selection; - std::vector<CounterInfo> counters; -}; - -struct EventSelection { uint32_t group_id; - uint32_t selection_id; - EventTypeAndModifier event_type_modifier; - perf_event_attr event_attr; - std::vector<std::unique_ptr<EventFd>> event_fds; - // counters for event files closed for cpu hotplug events - std::vector<CounterInfo> hotplugged_counters; + std::string event_name; + std::string event_modifier; + std::vector<CounterInfo> counters; }; -typedef std::vector<EventSelection> EventSelectionGroup; - class IOEventLoop; // EventSelectionSet helps to monitor events. It is used in following steps: @@ -81,21 +70,23 @@ class EventSelectionSet { bool empty() const { return groups_.empty(); } - const std::vector<EventSelectionGroup>& groups() { return groups_; } - bool AddEventType(const std::string& event_name); bool AddEventGroup(const std::vector<std::string>& event_names); + std::vector<const EventType*> GetTracepointEvents() const; + std::vector<EventAttrWithId> GetEventAttrWithId() const; void SetEnableOnExec(bool enable); bool GetEnableOnExec(); void SampleIdAll(); - void SetSampleFreq(const EventSelection& selection, uint64_t sample_freq); - void SetSamplePeriod(const EventSelection& selection, uint64_t sample_period); + void SetSampleFreq(uint64_t sample_freq); + void SetSamplePeriod(uint64_t sample_period); + void UseDefaultSampleFreq(); bool SetBranchSampling(uint64_t branch_sample_type); void EnableFpCallChainSampling(); bool EnableDwarfCallChainSampling(uint32_t dump_stack_size); void SetInherit(bool enable); void SetLowWatermark(); + bool NeedKernelSymbol() const; void AddMonitoredProcesses(const std::set<pid_t>& processes) { processes_.insert(processes.begin(), processes.end()); @@ -105,13 +96,9 @@ class EventSelectionSet { threads_.insert(threads.begin(), threads.end()); } - const std::set<pid_t>& GetMonitoredProcesses() const { - return processes_; - } + const std::set<pid_t>& GetMonitoredProcesses() const { return processes_; } - const std::set<pid_t>& GetMonitoredThreads() const { - return threads_; - } + const std::set<pid_t>& GetMonitoredThreads() const { return threads_; } bool HasMonitoredTarget() const { return !processes_.empty() || !threads_.empty(); @@ -131,9 +118,21 @@ class EventSelectionSet { DEFAULT_PERIOD_TO_DETECT_CPU_HOTPLUG_EVENTS_IN_SEC); private: + struct EventSelection { + EventTypeAndModifier event_type_modifier; + perf_event_attr event_attr; + std::vector<std::unique_ptr<EventFd>> event_fds; + // counters for event files closed for cpu hotplug events + std::vector<CounterInfo> hotplugged_counters; + }; + typedef std::vector<EventSelection> EventSelectionGroup; + bool BuildAndCheckEventSelection(const std::string& event_name, EventSelection* selection); void UnionSampleType(); + bool OpenEventFilesOnGroup(EventSelectionGroup& group, pid_t tid, int cpu, + std::string* failed_event_type); + bool MmapEventFiles(size_t mmap_pages, bool report_error); bool ReadMmapEventDataForFd(EventFd* event_fd); |