From d7bbad3aac72ab83a5e6a284f64f0adddd47eab1 Mon Sep 17 00:00:00 2001 From: Patrick Bellasi Date: Wed, 27 Jan 2016 15:53:20 +0000 Subject: [PATCH] ftrace: disable tracing of functions not available in the target kernel In general we could be interested to defined a common configuration to use across different kernels. Thus, for a given set of experiments, some functions can be present only on some kernels and not others. This patch updates the check for the availability of functions to profile by ensuring that we consider only functions available in the kernel in use in the target. In case of a function cannot be profiled in the target kernel we log a warning instead of raising an exception. Signed-off-by: Patrick Bellasi --- devlib/trace/ftrace.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/devlib/trace/ftrace.py b/devlib/trace/ftrace.py index 9e0f199..7644dfb 100644 --- a/devlib/trace/ftrace.py +++ b/devlib/trace/ftrace.py @@ -59,6 +59,7 @@ class FtraceCollector(TraceCollector): autoreport=True, autoview=False, no_install=False, + strict=False, ): super(FtraceCollector, self).__init__(target) self.events = events if events is not None else DEFAULT_EVENTS @@ -75,7 +76,7 @@ class FtraceCollector(TraceCollector): self.start_time = None self.stop_time = None self.event_string = _build_trace_events(self.events) - self.function_string = _build_trace_functions(self.functions) + self.function_string = None self._reset_needed = True # Setup tracing paths @@ -111,9 +112,16 @@ class FtraceCollector(TraceCollector): # Validate required functions to be traced available_functions = self.target.execute( 'cat {}'.format(self.available_functions_file)).splitlines() + selected_functions = [] for function in self.functions: if function not in available_functions: - raise TargetError('Function [{}] not available for filtering'.format(function)) + message = 'Function [{}] not available for profiling'.format(function) + if strict: + raise TargetError(message) + self.target.logger.warning(message) + else: + selected_functions.append(function) + self.function_string = _build_trace_functions(selected_functions) def reset(self): if self.buffer_size: