Index: build/android/adb_profile_chrome.py |
diff --git a/build/android/adb_profile_chrome.py b/build/android/adb_profile_chrome.py |
index 37f250c19a2b4b9c38c0e2cb1f87cf96b4406d13..db9d418622fbda208221a06a70d2e71783dc5791 100755 |
--- a/build/android/adb_profile_chrome.py |
+++ b/build/android/adb_profile_chrome.py |
@@ -53,6 +53,37 @@ class ChromeTracingController(object): |
def __str__(self): |
return 'chrome trace' |
+ @staticmethod |
+ def GetCategories(device, package_info): |
+ device.old_interface.BroadcastIntent( |
+ package_info.package, 'GPU_PROFILER_LIST_CATEGORY') |
+ try: |
+ trace_list_category_re = re.compile(r'{"traceCategoriesList": \[(.*)\]}') |
+ category_list = device.old_interface.WaitForLogMatch( |
Xianzhu
2014/05/05 16:32:21
You may want to use 'import json'.
r.kasibhatla
2014/05/06 11:04:06
Done.
|
+ trace_list_category_re, None, timeout=5).group(1).split(',') |
+ |
+ record_categories = [] |
+ disabled_by_default_categories = [] |
+ # Divide the list into default and debug lists. |
+ for item in category_list: |
+ item = item.strip("\"") |
+ if item.startswith('disabled-by-default'): |
+ disabled_by_default_categories.append(item) |
+ else: |
+ record_categories.append(item) |
+ |
+ # Sort the individual lists. |
+ record_categories = list(set(record_categories)) |
+ record_categories.sort() |
+ disabled_by_default_categories = list(set(disabled_by_default_categories)) |
+ disabled_by_default_categories.sort() |
+ |
+ return record_categories, disabled_by_default_categories |
+ |
+ except pexpect.TIMEOUT: |
+ raise RuntimeError('Performance trace category list marker not found. ' |
+ 'Is the correct version of the browser running?') |
+ |
def StartTracing(self, interval): |
self._trace_interval = interval |
self._device.old_interface.SyncLogCat() |
@@ -324,7 +355,8 @@ def main(): |
'categories with comma-delimited wildcards, ' |
'e.g., "*", "cat1*,-cat1a". Omit this option to trace ' |
'Chrome\'s default categories. Chrome tracing can be ' |
- 'disabled with "--categories=\'\'".', |
+ 'disabled with "--categories=\'\'". Use "list" to see ' |
+ 'the available categories.', |
metavar='CHROME_CATEGORIES', dest='chrome_categories', |
default=_DEFAULT_CHROME_CATEGORIES) |
categories.add_option('-s', '--systrace', help='Capture a systrace with the ' |
@@ -383,6 +415,24 @@ When in doubt, just try out --trace-frame-viewer. |
if len(devices) != 1: |
parser.error('Exactly 1 device much be attached.') |
device = device_utils.DeviceUtils(devices[0]) |
+ package_info = _GetSupportedBrowsers()[options.browser] |
+ |
+ if options.chrome_categories in ['list', 'help']: |
+ _PrintMessage('Fetching the record categories list ...') |
+ record_categories = [] |
+ disabled_by_default_categories = [] |
+ record_categories, disabled_by_default_categories = \ |
+ ChromeTracingController.GetCategories(device, package_info) |
+ |
+ _PrintMessage('\nRecord Categories -\n') |
+ for item in record_categories: |
+ _PrintMessage(item) |
+ |
+ _PrintMessage('\nDisabled by Default Categories -\n') |
+ for item in disabled_by_default_categories: |
+ _PrintMessage(item) |
+ |
+ return 0 |
if options.systrace_categories in ['list', 'help']: |
_PrintMessage('\n'.join(SystraceController.GetCategories(device))) |
@@ -394,7 +444,6 @@ When in doubt, just try out --trace-frame-viewer. |
chrome_categories = _ComputeChromeCategories(options) |
systrace_categories = _ComputeSystraceCategories(options) |
- package_info = _GetSupportedBrowsers()[options.browser] |
if chrome_categories and 'webview' in systrace_categories: |
logging.warning('Using the "webview" category in systrace together with ' |