1
0
mirror of https://github.com/ARM-software/devlib.git synced 2025-01-31 10:10:46 +00:00

Merge pull request #59 from derkling/fix-ftrace

ftrace: ensure ftrace commands are executed as root
This commit is contained in:
setrofim 2016-09-28 08:20:10 +01:00 committed by GitHub
commit f8440cf354

View File

@ -107,7 +107,8 @@ class FtraceCollector(TraceCollector):
# Validate required events to be traced # Validate required events to be traced
available_events = self.target.execute( available_events = self.target.execute(
'cat {}'.format(self.available_events_file)).splitlines() 'cat {}'.format(self.available_events_file),
as_root=True).splitlines()
selected_events = [] selected_events = []
for event in self.events: for event in self.events:
# Convert globs supported by FTrace into valid regexp globs # Convert globs supported by FTrace into valid regexp globs
@ -138,7 +139,8 @@ class FtraceCollector(TraceCollector):
'A kernel build with CONFIG_FUNCTION_PROFILER enable is required') 'A kernel build with CONFIG_FUNCTION_PROFILER enable is required')
# Validate required functions to be traced # Validate required functions to be traced
available_functions = self.target.execute( available_functions = self.target.execute(
'cat {}'.format(self.available_functions_file)).splitlines() 'cat {}'.format(self.available_functions_file),
as_root=True).splitlines()
selected_functions = [] selected_functions = []
for function in self.functions: for function in self.functions:
if function not in available_functions: if function not in available_functions:
@ -153,14 +155,16 @@ class FtraceCollector(TraceCollector):
def reset(self): def reset(self):
if self.buffer_size: if self.buffer_size:
self._set_buffer_size() self._set_buffer_size()
self.target.execute('{} reset'.format(self.target_binary), as_root=True, timeout=TIMEOUT) self.target.execute('{} reset'.format(self.target_binary),
as_root=True, timeout=TIMEOUT)
self._reset_needed = False self._reset_needed = False
def start(self): def start(self):
self.start_time = time.time() self.start_time = time.time()
if self._reset_needed: if self._reset_needed:
self.reset() self.reset()
self.target.execute('{} start {}'.format(self.target_binary, self.event_string), as_root=True) self.target.execute('{} start {}'.format(self.target_binary, self.event_string),
as_root=True)
if self.automark: if self.automark:
self.mark_start() self.mark_start()
if 'cpufreq' in self.target.modules: if 'cpufreq' in self.target.modules:
@ -168,22 +172,29 @@ class FtraceCollector(TraceCollector):
self.target.cpufreq.trace_frequencies() self.target.cpufreq.trace_frequencies()
# Enable kernel function profiling # Enable kernel function profiling
if self.functions: if self.functions:
self.target.execute('echo nop > {}'.format(self.current_tracer_file)) self.target.execute('echo nop > {}'.format(self.current_tracer_file),
self.target.execute('echo 0 > {}'.format(self.function_profile_file)) as_root=True)
self.target.execute('echo {} > {}'.format(self.function_string, self.ftrace_filter_file)) self.target.execute('echo 0 > {}'.format(self.function_profile_file),
self.target.execute('echo 1 > {}'.format(self.function_profile_file)) as_root=True)
self.target.execute('echo {} > {}'.format(self.function_string, self.ftrace_filter_file),
as_root=True)
self.target.execute('echo 1 > {}'.format(self.function_profile_file),
as_root=True)
def stop(self): def stop(self):
# Disable kernel function profiling # Disable kernel function profiling
if self.functions: if self.functions:
self.target.execute('echo 1 > {}'.format(self.function_profile_file)) self.target.execute('echo 1 > {}'.format(self.function_profile_file),
as_root=True)
if 'cpufreq' in self.target.modules: if 'cpufreq' in self.target.modules:
self.logger.debug('Trace CPUFreq frequencies') self.logger.debug('Trace CPUFreq frequencies')
self.target.cpufreq.trace_frequencies() self.target.cpufreq.trace_frequencies()
self.stop_time = time.time() self.stop_time = time.time()
if self.automark: if self.automark:
self.mark_stop() self.mark_stop()
self.target.execute('{} stop'.format(self.target_binary), timeout=TIMEOUT, as_root=True) self.target.execute('{} stop'.format(self.target_binary),
timeout=TIMEOUT, as_root=True)
self._reset_needed = True self._reset_needed = True
def get_trace(self, outfile): def get_trace(self, outfile):