diff options
Diffstat (limited to 'simpleperf/event_selection_set.cpp')
-rw-r--r-- | simpleperf/event_selection_set.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/simpleperf/event_selection_set.cpp b/simpleperf/event_selection_set.cpp index 240f9d42..ebd34773 100644 --- a/simpleperf/event_selection_set.cpp +++ b/simpleperf/event_selection_set.cpp @@ -103,6 +103,19 @@ bool IsDumpingRegsForTracepointEventsSupported() { return false; } +bool IsSettingClockIdSupported() { + const EventType* type = FindEventTypeByName("cpu-cycles"); + if (type == nullptr) { + return false; + } + // Check if the kernel supports setting clockid, which was added in kernel 4.0. Just check with + // one clockid is enough. Because all needed clockids were supported before kernel 4.0. + perf_event_attr attr = CreateDefaultPerfEventAttr(*type); + attr.use_clockid = 1; + attr.clockid = CLOCK_MONOTONIC; + return IsEventAttrSupported(attr); +} + bool EventSelectionSet::BuildAndCheckEventSelection( const std::string& event_name, EventSelection* selection) { std::unique_ptr<EventTypeAndModifier> event_type = ParseEventType(event_name); @@ -372,6 +385,15 @@ void EventSelectionSet::SetInherit(bool enable) { } } +void EventSelectionSet::SetClockId(int clock_id) { + for (auto& group : groups_) { + for (auto& selection : group) { + selection.event_attr.use_clockid = 1; + selection.event_attr.clockid = clock_id; + } + } +} + bool EventSelectionSet::NeedKernelSymbol() const { for (const auto& group : groups_) { for (const auto& selection : group) { |