diff options
Diffstat (limited to 'catapult/systrace/systrace/tracing_agents/atrace_agent.py')
-rw-r--r-- | catapult/systrace/systrace/tracing_agents/atrace_agent.py | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/catapult/systrace/systrace/tracing_agents/atrace_agent.py b/catapult/systrace/systrace/tracing_agents/atrace_agent.py index e7e15e93..47ed3fa1 100644 --- a/catapult/systrace/systrace/tracing_agents/atrace_agent.py +++ b/catapult/systrace/systrace/tracing_agents/atrace_agent.py @@ -3,6 +3,7 @@ # found in the LICENSE file. import optparse +import platform import py_utils import re import sys @@ -20,6 +21,8 @@ from systrace import util ADB_IGNORE_REGEXP = r'^capturing trace\.\.\. done|^capturing trace\.\.\.' # The number of seconds to wait on output from ADB. ADB_STDOUT_READ_TIMEOUT = 0.2 +# The number of seconds to wait for large output from ADB. +ADB_LARGE_OUTPUT_TIMEOUT = 600 # The adb shell command to initiate a trace. ATRACE_BASE_ARGS = ['atrace'] # If a custom list of categories is not specified, traces will include @@ -229,14 +232,15 @@ class AtraceAgent(tracing_agents.TracingAgent): shell.RunCommand(cmd, close=True) did_record_sync_marker_callback(t1, sync_id) - def _stop_trace(self): + 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.""" - self._device_utils.RunShellCommand( - self._tracer_args + ['--async_stop'], check_return=True) + 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' if self._device_sdk_version < version_codes.MARSHMALLOW: @@ -245,11 +249,11 @@ class AtraceAgent(tracing_agents.TracingAgent): self._device_utils.RunShellCommand( self._tracer_args + ['-t 0'], check_return=True) + return result + def _collect_trace_data(self): """Reads the output from atrace and stops the trace.""" - dump_cmd = self._tracer_args + ['--async_dump'] - result = self._device_utils.RunShellCommand( - dump_cmd, raw_output=True, large_output=True, check_return=True) + result = self._stop_collect_trace() data_start = re.search(TRACE_START_REGEXP, result) if data_start: @@ -257,7 +261,6 @@ class AtraceAgent(tracing_agents.TracingAgent): else: raise IOError('Unable to get atrace data. Did you forget adb root?') output = re.sub(ADB_IGNORE_REGEXP, '', result[data_start:]) - self._stop_trace() return output def _preprocess_trace_data(self, trace_data): @@ -414,7 +417,10 @@ class AtraceConfig(tracing_agents.TracingConfig): self.trace_buf_size = trace_buf_size self.kfuncs = kfuncs self.app_name = app_name - self.compress_trace_data = compress_trace_data + # Trace compression is broken on Windows. + # TODO: Fix https://crbug.com/739751. + self.compress_trace_data = \ + compress_trace_data and platform.system() != 'Windows' self.from_file = from_file self.device_serial_number = device_serial_number self.trace_time = trace_time |