| 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 logging | 13 import logging |
| 14 import multiprocessing | 14 import multiprocessing |
| 15 import os | 15 import os |
| 16 import re | 16 import re |
| 17 import subprocess | 17 import subprocess |
| 18 import sys | 18 import sys |
| 19 import optparse | 19 import optparse |
| 20 | 20 |
| 21 import devil_chromium |
| 22 |
| 21 from devil.android import device_blacklist | 23 from devil.android import device_blacklist |
| 22 from devil.android import device_errors | 24 from devil.android import device_errors |
| 23 from devil.android import device_utils | 25 from devil.android import device_utils |
| 24 from devil.utils import run_tests_helper | 26 from devil.utils import run_tests_helper |
| 25 | 27 |
| 26 _TZ_UTC = {'TZ': 'UTC'} | 28 _TZ_UTC = {'TZ': 'UTC'} |
| 27 | 29 |
| 28 def _ListTombstones(device): | 30 def _ListTombstones(device): |
| 29 """List the tombstone files on the device. | 31 """List the tombstone files on the device. |
| 30 | 32 |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 parser.add_option('-j', '--jobs', type='int', | 236 parser.add_option('-j', '--jobs', type='int', |
| 235 default=4, | 237 default=4, |
| 236 help='Number of jobs to use when processing multiple ' | 238 help='Number of jobs to use when processing multiple ' |
| 237 'crash stacks.') | 239 'crash stacks.') |
| 238 options, _ = parser.parse_args() | 240 options, _ = parser.parse_args() |
| 239 | 241 |
| 240 blacklist = (device_blacklist.Blacklist(options.blacklist_file) | 242 blacklist = (device_blacklist.Blacklist(options.blacklist_file) |
| 241 if options.blacklist_file | 243 if options.blacklist_file |
| 242 else None) | 244 else None) |
| 243 | 245 |
| 246 devil_chromium.Initialize() |
| 247 |
| 244 if options.device: | 248 if options.device: |
| 245 devices = [device_utils.DeviceUtils(options.device)] | 249 devices = [device_utils.DeviceUtils(options.device)] |
| 246 else: | 250 else: |
| 247 devices = device_utils.DeviceUtils.HealthyDevices(blacklist) | 251 devices = device_utils.DeviceUtils.HealthyDevices(blacklist) |
| 248 | 252 |
| 249 # This must be done serially because strptime can hit a race condition if | 253 # This must be done serially because strptime can hit a race condition if |
| 250 # used for the first time in a multithreaded environment. | 254 # used for the first time in a multithreaded environment. |
| 251 # http://bugs.python.org/issue7980 | 255 # http://bugs.python.org/issue7980 |
| 252 tombstones = [] | 256 tombstones = [] |
| 253 for device in devices: | 257 for device in devices: |
| 254 tombstones += _GetTombstonesForDevice(device, options) | 258 tombstones += _GetTombstonesForDevice(device, options) |
| 255 | 259 |
| 256 _ResolveTombstones(options.jobs, tombstones) | 260 _ResolveTombstones(options.jobs, tombstones) |
| 257 | 261 |
| 258 | 262 |
| 259 if __name__ == '__main__': | 263 if __name__ == '__main__': |
| 260 sys.exit(main()) | 264 sys.exit(main()) |
| OLD | NEW |