From e7bd2a5b2203ff065bfe34f3d6c1c3f5044a5da6 Mon Sep 17 00:00:00 2001 From: Valentin Schneider Date: Tue, 26 Nov 2019 17:50:35 +0000 Subject: [PATCH] trace/ftrace: Memoize tracable functions This is similar to what is already done for events and tracers. Also, use this opportunity to use read_value() instead of target.execute('cat {}'). --- devlib/trace/ftrace.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/devlib/trace/ftrace.py b/devlib/trace/ftrace.py index c258b3e..20cc935 100644 --- a/devlib/trace/ftrace.py +++ b/devlib/trace/ftrace.py @@ -162,13 +162,10 @@ class FtraceCollector(TraceCollector): # Check for function tracing support if self.functions: # Validate required functions to be traced - available_functions = self.target.execute( - 'cat {}'.format(self.available_functions_file), - as_root=True).splitlines() selected_functions = [] for function in self.functions: - if function not in available_functions: - message = 'Function [{}] not available for profiling'.format(function) + if function not in self.available_functions: + message = 'Function [{}] not available for tracing/profiling'.format(function) if self.strict: raise TargetStableError(message) self.target.logger.warning(message) @@ -209,6 +206,14 @@ class FtraceCollector(TraceCollector): """ return self.target.read_value(self.available_events_file).splitlines() + @property + @memoized + def available_functions(self): + """ + List of functions whose tracing/profiling is supported by the target's kernel. + """ + return self.target.read_value(self.available_functions_file).splitlines() + def reset(self): if self.buffer_size: self._set_buffer_size()