Commit 466c5890 authored by Michael Spang's avatar Michael Spang Committed by Commit Bot

chromecast: trace.py: Switch to new tracing config style

The tracing request format currently in use is deprecated and does not
support enabling some features such as system tracing. Switch to the new
format. This requires us to tokenize the category filter ourselves;
this is done using the same algorithm as chrome.

This also fixes a regression where the category filter was set to '"*"'
(double quotes included) which does not work properly, disabling all
events. We should use the empty string, which simply means to apply the
defaults. The android backend appears to be prepared to handle this as
well (mapping it to "_DEFAULT_CHROME_CATEGORIES").

BUG=786091

Change-Id: Ic60a3db7f4decc5ee046ce50bfc58d3c22211558
Reviewed-on: https://chromium-review.googlesource.com/804857Reviewed-by: default avatarLuke Halliwell <halliwell@chromium.org>
Commit-Queue: Michael Spang <spang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#521417}
parent e1ccd581
...@@ -63,7 +63,7 @@ def _CreateOptionParser(): ...@@ -63,7 +63,7 @@ def _CreateOptionParser():
'-c', '--category-filter', '-c', '--category-filter',
help='Apply filter to control what category groups should be traced.', help='Apply filter to control what category groups should be traced.',
type='string', type='string',
default='"*"') default='')
tracing_opts.add_option( tracing_opts.add_option(
'--record-continuously', '--record-continuously',
help='Keep recording until stopped. The trace buffer is of fixed size ' help='Keep recording until stopped. The trace buffer is of fixed size '
......
...@@ -41,6 +41,8 @@ class TracingBackend(object): ...@@ -41,6 +41,8 @@ class TracingBackend(object):
self._devtools_port = devtools_port self._devtools_port = devtools_port
self._timeout = timeout self._timeout = timeout
self._buffer_usage_reporting_interval = buffer_usage_reporting_interval self._buffer_usage_reporting_interval = buffer_usage_reporting_interval
self._included_categories = []
self._excluded_categories = []
def Connect(self): def Connect(self):
"""Connect to cast_shell.""" """Connect to cast_shell."""
...@@ -71,14 +73,23 @@ class TracingBackend(object): ...@@ -71,14 +73,23 @@ class TracingBackend(object):
""" """
self._tracing_client = TracingClient() self._tracing_client = TracingClient()
self._socket.settimeout(self._timeout) self._socket.settimeout(self._timeout)
self._ParseCustomCategories(custom_categories)
req = { req = {
'method': 'Tracing.start', 'method': 'Tracing.start',
'params': { 'params': {
'categories': custom_categories, 'transferMode': 'ReportEvents',
'bufferUsageReportingInterval': self._buffer_usage_reporting_interval, 'traceConfig': {
'options': 'record-continuously' if record_continuously else 'recordMode':
'record-until-full' 'recordContinuously'
} if record_continuously else 'recordUntilFull',
'includedCategories':
self._included_categories,
'excludedCategories':
self._excluded_categories,
},
'bufferUsageReportingInterval':
self._buffer_usage_reporting_interval,
}
} }
self._SendRequest(req) self._SendRequest(req)
...@@ -147,6 +158,22 @@ class TracingBackend(object): ...@@ -147,6 +158,22 @@ class TracingBackend(object):
elif 'Tracing.tracingComplete' == method: elif 'Tracing.tracingComplete' == method:
return True return True
def _ParseCustomCategories(self, custom_categories):
"""Parse a category filter into trace config format"""
self._included_categories = []
self._excluded_categories = []
# See TraceConfigCategoryFilter::InitializeFromString in chromium.
categories = (token.strip() for token in custom_categories.split(','))
for category in categories:
if not category:
continue
if category.startswith('-'):
self._excluded_categories.append(category[1:])
else:
self._included_categories.append(category)
class TracingBackendAndroid(object): class TracingBackendAndroid(object):
"""Android version of TracingBackend.""" """Android version of TracingBackend."""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment