| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # | 2 # |
| 3 # Copyright 2013 The Chromium Authors. All rights reserved. | 3 # Copyright 2013 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 # | 6 # |
| 7 # Find the most recent tombstone file(s) on all connected devices | 7 # Find the most recent tombstone file(s) on all connected devices |
| 8 # and prints their stacks. | 8 # and prints their stacks. |
| 9 # | 9 # |
| 10 # Assumes tombstone file was created with current symbols. | 10 # Assumes tombstone file was created with current symbols. |
| 11 | 11 |
| 12 import datetime | 12 import datetime |
| 13 import itertools | 13 import itertools |
| 14 import logging | 14 import logging |
| 15 import multiprocessing | 15 import multiprocessing |
| 16 import os | 16 import os |
| 17 import re | 17 import re |
| 18 import subprocess | 18 import subprocess |
| 19 import sys | 19 import sys |
| 20 import optparse | 20 import optparse |
| 21 | 21 |
| 22 from pylib.device import adb_wrapper | 22 from pylib.device import adb_wrapper |
| 23 from pylib.device import device_blacklist | |
| 24 from pylib.device import device_errors | 23 from pylib.device import device_errors |
| 25 from pylib.device import device_utils | 24 from pylib.device import device_utils |
| 26 from pylib.utils import run_tests_helper | 25 from pylib.utils import run_tests_helper |
| 27 | 26 |
| 28 | 27 |
| 29 _TZ_UTC = {'TZ': 'UTC'} | 28 _TZ_UTC = {'TZ': 'UTC'} |
| 30 | 29 |
| 31 def _ListTombstones(device): | 30 def _ListTombstones(device): |
| 32 """List the tombstone files on the device. | 31 """List the tombstone files on the device. |
| 33 | 32 |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 def main(): | 215 def main(): |
| 217 custom_handler = logging.StreamHandler(sys.stdout) | 216 custom_handler = logging.StreamHandler(sys.stdout) |
| 218 custom_handler.setFormatter(run_tests_helper.CustomFormatter()) | 217 custom_handler.setFormatter(run_tests_helper.CustomFormatter()) |
| 219 logging.getLogger().addHandler(custom_handler) | 218 logging.getLogger().addHandler(custom_handler) |
| 220 logging.getLogger().setLevel(logging.INFO) | 219 logging.getLogger().setLevel(logging.INFO) |
| 221 | 220 |
| 222 parser = optparse.OptionParser() | 221 parser = optparse.OptionParser() |
| 223 parser.add_option('--device', | 222 parser.add_option('--device', |
| 224 help='The serial number of the device. If not specified ' | 223 help='The serial number of the device. If not specified ' |
| 225 'will use all devices.') | 224 'will use all devices.') |
| 226 parser.add_option('--blacklist-file', help='Device blacklist JSON file.') | |
| 227 parser.add_option('-a', '--all-tombstones', action='store_true', | 225 parser.add_option('-a', '--all-tombstones', action='store_true', |
| 228 help="""Resolve symbols for all tombstones, rather than just | 226 help="""Resolve symbols for all tombstones, rather than just |
| 229 the most recent""") | 227 the most recent""") |
| 230 parser.add_option('-s', '--stack', action='store_true', | 228 parser.add_option('-s', '--stack', action='store_true', |
| 231 help='Also include symbols for stack data') | 229 help='Also include symbols for stack data') |
| 232 parser.add_option('-w', '--wipe-tombstones', action='store_true', | 230 parser.add_option('-w', '--wipe-tombstones', action='store_true', |
| 233 help='Erase all tombstones from device after processing') | 231 help='Erase all tombstones from device after processing') |
| 234 parser.add_option('-j', '--jobs', type='int', | 232 parser.add_option('-j', '--jobs', type='int', |
| 235 default=4, | 233 default=4, |
| 236 help='Number of jobs to use when processing multiple ' | 234 help='Number of jobs to use when processing multiple ' |
| 237 'crash stacks.') | 235 'crash stacks.') |
| 238 options, _ = parser.parse_args() | 236 options, _ = parser.parse_args() |
| 239 | 237 |
| 240 if options.blacklist_file: | |
| 241 blacklist = device_blacklist.Blacklist(options.blacklist_file) | |
| 242 else: | |
| 243 blacklist = None | |
| 244 | |
| 245 if options.device: | 238 if options.device: |
| 246 devices = [device_utils.DeviceUtils(options.device)] | 239 devices = [device_utils.DeviceUtils(options.device)] |
| 247 else: | 240 else: |
| 248 devices = device_utils.DeviceUtils.HealthyDevices(blacklist) | 241 devices = device_utils.DeviceUtils.HealthyDevices() |
| 249 | 242 |
| 250 # This must be done serially because strptime can hit a race condition if | 243 # This must be done serially because strptime can hit a race condition if |
| 251 # used for the first time in a multithreaded environment. | 244 # used for the first time in a multithreaded environment. |
| 252 # http://bugs.python.org/issue7980 | 245 # http://bugs.python.org/issue7980 |
| 253 tombstones = [] | 246 tombstones = [] |
| 254 for device in devices: | 247 for device in devices: |
| 255 tombstones += _GetTombstonesForDevice(device, options) | 248 tombstones += _GetTombstonesForDevice(device, options) |
| 256 | 249 |
| 257 _ResolveTombstones(options.jobs, tombstones) | 250 _ResolveTombstones(options.jobs, tombstones) |
| 258 | 251 |
| 259 | 252 |
| 260 if __name__ == '__main__': | 253 if __name__ == '__main__': |
| 261 sys.exit(main()) | 254 sys.exit(main()) |
| OLD | NEW |