| 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. |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 found_abi = re.search('ABI: \'(.+?)\'', line) | 123 found_abi = re.search('ABI: \'(.+?)\'', line) |
| 124 if found_abi: | 124 if found_abi: |
| 125 device_abi = found_abi.group(1) | 125 device_abi = found_abi.group(1) |
| 126 arch = _DeviceAbiToArch(device_abi) | 126 arch = _DeviceAbiToArch(device_abi) |
| 127 if not arch: | 127 if not arch: |
| 128 return | 128 return |
| 129 | 129 |
| 130 stack_tool = os.path.join(os.path.dirname(__file__), '..', '..', | 130 stack_tool = os.path.join(os.path.dirname(__file__), '..', '..', |
| 131 'third_party', 'android_platform', 'development', | 131 'third_party', 'android_platform', 'development', |
| 132 'scripts', 'stack') | 132 'scripts', 'stack') |
| 133 proc = subprocess.Popen([stack_tool, '--arch', arch], stdin=subprocess.PIPE, | 133 cmd = [stack_tool, '--arch', arch, '--output-directory', |
| 134 stdout=subprocess.PIPE) | 134 constants.GetOutDirectory()] |
| 135 proc = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE) |
| 135 output = proc.communicate(input='\n'.join(tombstone_data))[0] | 136 output = proc.communicate(input='\n'.join(tombstone_data))[0] |
| 136 for line in output.split('\n'): | 137 for line in output.split('\n'): |
| 137 if not include_stack and 'Stack Data:' in line: | 138 if not include_stack and 'Stack Data:' in line: |
| 138 break | 139 break |
| 139 yield line | 140 yield line |
| 140 | 141 |
| 141 | 142 |
| 142 def _ResolveTombstone(tombstone): | 143 def _ResolveTombstone(tombstone): |
| 143 lines = [] | 144 lines = [] |
| 144 lines += [tombstone['file'] + ' created on ' + str(tombstone['time']) + | 145 lines += [tombstone['file'] + ' created on ' + str(tombstone['time']) + |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 options, _ = parser.parse_args() | 244 options, _ = parser.parse_args() |
| 244 | 245 |
| 245 devil_chromium.Initialize() | 246 devil_chromium.Initialize() |
| 246 | 247 |
| 247 blacklist = (device_blacklist.Blacklist(options.blacklist_file) | 248 blacklist = (device_blacklist.Blacklist(options.blacklist_file) |
| 248 if options.blacklist_file | 249 if options.blacklist_file |
| 249 else None) | 250 else None) |
| 250 | 251 |
| 251 if options.output_directory: | 252 if options.output_directory: |
| 252 constants.SetOutputDirectory(options.output_directory) | 253 constants.SetOutputDirectory(options.output_directory) |
| 254 # Do an up-front test that the output directory is known. |
| 255 constants.CheckOutputDirectory() |
| 253 | 256 |
| 254 if options.device: | 257 if options.device: |
| 255 devices = [device_utils.DeviceUtils(options.device)] | 258 devices = [device_utils.DeviceUtils(options.device)] |
| 256 else: | 259 else: |
| 257 devices = device_utils.DeviceUtils.HealthyDevices(blacklist) | 260 devices = device_utils.DeviceUtils.HealthyDevices(blacklist) |
| 258 | 261 |
| 259 # This must be done serially because strptime can hit a race condition if | 262 # This must be done serially because strptime can hit a race condition if |
| 260 # used for the first time in a multithreaded environment. | 263 # used for the first time in a multithreaded environment. |
| 261 # http://bugs.python.org/issue7980 | 264 # http://bugs.python.org/issue7980 |
| 262 tombstones = [] | 265 tombstones = [] |
| 263 for device in devices: | 266 for device in devices: |
| 264 tombstones += _GetTombstonesForDevice(device, options) | 267 tombstones += _GetTombstonesForDevice(device, options) |
| 265 | 268 |
| 266 _ResolveTombstones(options.jobs, tombstones) | 269 _ResolveTombstones(options.jobs, tombstones) |
| 267 | 270 |
| 268 | 271 |
| 269 if __name__ == '__main__': | 272 if __name__ == '__main__': |
| 270 sys.exit(main()) | 273 sys.exit(main()) |
| OLD | NEW |