From bbe3bb6adb5c348d790170f065fe221946da2164 Mon Sep 17 00:00:00 2001 From: Douglas RAILLARD Date: Mon, 4 Nov 2019 12:25:00 +0000 Subject: [PATCH] ftrace: Expose FtraceCollector.available_events Expose the list of events the kernel supports. Signed-off-by: Douglas RAILLARD --- devlib/trace/ftrace.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/devlib/trace/ftrace.py b/devlib/trace/ftrace.py index 0f5cefe..e132a9b 100644 --- a/devlib/trace/ftrace.py +++ b/devlib/trace/ftrace.py @@ -125,9 +125,6 @@ class FtraceCollector(TraceCollector): self.target_binary = 'trace-cmd' # Validate required events to be traced - available_events = self.target.execute( - 'cat {}'.format(self.available_events_file), - as_root=True).splitlines() selected_events = [] for event in self.events: # Convert globs supported by FTrace into valid regexp globs @@ -136,7 +133,7 @@ class FtraceCollector(TraceCollector): _event = '*' + event event_re = re.compile(_event.replace('*', '.*')) # Select events matching the required ones - if not list(filter(event_re.match, available_events)): + if not list(filter(event_re.match, self.available_events)): message = 'Event [{}] not available for tracing'.format(event) if strict: raise TargetStableError(message) @@ -189,6 +186,14 @@ class FtraceCollector(TraceCollector): """ return self.target.read_value(self.available_tracers_file).split(' ') + @property + @memoized + def available_events(self): + """ + List of ftrace events supported by the target's kernel. + """ + return self.target.read_value(self.available_events_file).splitlines() + def reset(self): if self.buffer_size: self._set_buffer_size()