summaryrefslogtreecommitdiff
path: root/simpleperf/event_selection_set.h
diff options
context:
space:
mode:
authorYabin Cui <yabinc@google.com>2016-04-01 20:22:35 -0700
committerYabin Cui <yabinc@google.com>2016-04-05 16:52:47 -0700
commit2d6efe4b167da4e6b77f168b1820239ee65599e2 (patch)
tree631aced5c7cb30b3c93345c55e67fe329fdf1d1a /simpleperf/event_selection_set.h
parent96e12e78722988e912664b7323341799fdd12b9b (diff)
downloadextras-2d6efe4b167da4e6b77f168b1820239ee65599e2.tar.gz
simpleperf: support reporting more than one event type.
When sampling kernel trace points, it is like to sample more than one even type. Like `simpleperf record -e kmem:mm_page_alloc,kmem:mm_page_free`. 1. change record command to dump event_id for all records. 2. change report command and record reader to support multiple event attrs. 3. hide record_cache inside EventSelectionSet. 4. add test to report multiple event types. Bug: 27403614 Change-Id: Ic22a5527d68e7a843e3cf95e85381f8ad6bcb196
Diffstat (limited to 'simpleperf/event_selection_set.h')
-rw-r--r--simpleperf/event_selection_set.h14
1 files changed, 12 insertions, 2 deletions
diff --git a/simpleperf/event_selection_set.h b/simpleperf/event_selection_set.h
index 746abfa7..d2e2511a 100644
--- a/simpleperf/event_selection_set.h
+++ b/simpleperf/event_selection_set.h
@@ -19,6 +19,7 @@
#include <functional>
#include <map>
+#include <unordered_map>
#include <vector>
#include <android-base/macros.h>
@@ -26,6 +27,7 @@
#include "event_fd.h"
#include "event_type.h"
#include "perf_event.h"
+#include "record.h"
struct CountersInfo {
const EventTypeAndModifier* event_type;
@@ -72,9 +74,11 @@ class EventSelectionSet {
bool OpenEventFilesForCpus(const std::vector<int>& cpus);
bool OpenEventFilesForThreadsOnCpus(const std::vector<pid_t>& threads, std::vector<int> cpus);
bool ReadCounters(std::vector<CountersInfo>* counters);
- void PreparePollForEventFiles(std::vector<pollfd>* pollfds);
+ void PrepareToPollForEventFiles(std::vector<pollfd>* pollfds);
bool MmapEventFiles(size_t mmap_pages);
- bool ReadMmapEventData(std::function<bool(const char*, size_t)> callback);
+ void PrepareToReadMmapEventData(std::function<bool (Record*)> callback);
+ bool ReadMmapEventData();
+ bool FinishReadMmapEventData();
const perf_event_attr* FindEventAttrByType(const EventTypeAndModifier& event_type_modifier);
const std::vector<std::unique_ptr<EventFd>>* FindEventFdsByType(
@@ -83,6 +87,8 @@ class EventSelectionSet {
private:
void UnionSampleType();
bool OpenEventFiles(const std::vector<pid_t>& threads, const std::vector<int>& cpus);
+ bool ReadMmapEventDataForFd(std::unique_ptr<EventFd>& event_fd, const perf_event_attr& attr,
+ bool* has_data);
struct EventSelection {
EventTypeAndModifier event_type_modifier;
@@ -93,6 +99,10 @@ class EventSelectionSet {
std::vector<EventSelection> selections_;
+ std::function<bool (Record*)> record_callback_;
+ std::unique_ptr<RecordCache> record_cache_;
+ std::unordered_map<uint64_t, const perf_event_attr*> event_id_to_attr_map_;
+
DISALLOW_COPY_AND_ASSIGN(EventSelectionSet);
};