diff options
Diffstat (limited to 'catapult/systrace/systrace/tracing_agents/atrace_agent.py')
-rw-r--r-- | catapult/systrace/systrace/tracing_agents/atrace_agent.py | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/catapult/systrace/systrace/tracing_agents/atrace_agent.py b/catapult/systrace/systrace/tracing_agents/atrace_agent.py index f699fc05..caf78f44 100644 --- a/catapult/systrace/systrace/tracing_agents/atrace_agent.py +++ b/catapult/systrace/systrace/tracing_agents/atrace_agent.py @@ -241,19 +241,28 @@ class AtraceAgent(tracing_agents.TracingAgent): def _stop_collect_trace(self): """Stops atrace. - Note that prior to Api 23, --async-stop may not actually stop tracing. - Thus, this uses a fallback method of running a zero-length synchronous - trace if tracing is still on.""" - result = self._device_utils.RunShellCommand( - self._tracer_args + ['--async_stop'], raw_output=True, - large_output=True, check_return=True, timeout=ADB_LARGE_OUTPUT_TIMEOUT) - is_trace_enabled_file = '/sys/kernel/debug/tracing/tracing_on' - + Note that prior to Api 23, --async-stop isn't working correctly. It + doesn't stop tracing and clears trace buffer before dumping it rendering + results unusable.""" if self._device_sdk_version < version_codes.MARSHMALLOW: - if int(self._device_utils.ReadFile(is_trace_enabled_file)): - # tracing was incorrectly left on, disable it - self._device_utils.RunShellCommand( - self._tracer_args + ['-t 0'], check_return=True) + is_trace_enabled_file = '/sys/kernel/debug/tracing/tracing_on' + # Stop tracing first so new data won't arrive while dump is performed (it + # may take a non-trivial time and tracing buffer may overflow). + self._device_utils.WriteFile(is_trace_enabled_file, '0') + result = self._device_utils.RunShellCommand( + self._tracer_args + ['--async_dump'], raw_output=True, + large_output=True, check_return=True, + timeout=ADB_LARGE_OUTPUT_TIMEOUT) + # Run synchronous tracing for 0 seconds to stop tracing, clear buffers + # and other state. + self._device_utils.RunShellCommand( + self._tracer_args + ['-t 0'], check_return=True) + else: + # On M+ --async_stop does everything necessary + result = self._device_utils.RunShellCommand( + self._tracer_args + ['--async_stop'], raw_output=True, + large_output=True, check_return=True, + timeout=ADB_LARGE_OUTPUT_TIMEOUT) return result |