Chromium Code Reviews| 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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 cmd = [stack_tool, '--arch', arch, '--output-directory', | 133 cmd = [stack_tool, '--arch', arch, '--output-directory', |
| 134 constants.GetOutDirectory()] | 134 constants.GetOutDirectory()] |
| 135 if os.path.exists(os.path.join(constants.GetOutDirectory(), 'lib')): | |
| 136 for root, _, files in os.walk(os.path.join(constants.GetOutDirectory(), | |
| 137 'lib')): | |
| 138 for file_name in files: | |
| 139 if file_name.endswith('.so'): | |
| 140 cmd.extend(['--packed-lib', os.path.join(root, file_name)]) | |
|
jbudorick
2017/07/17 15:50:45
For symbols, the script will find the lib.unstripp
| |
| 141 | |
| 135 proc = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE) | 142 proc = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE) |
| 136 output = proc.communicate(input='\n'.join(tombstone_data))[0] | 143 output = proc.communicate(input='\n'.join(tombstone_data))[0] |
| 137 for line in output.split('\n'): | 144 for line in output.split('\n'): |
| 138 if not include_stack and 'Stack Data:' in line: | 145 if not include_stack and 'Stack Data:' in line: |
| 139 break | 146 break |
| 140 yield line | 147 yield line |
| 141 | 148 |
| 142 | 149 |
| 143 def _ResolveTombstone(tombstone): | 150 def _ResolveTombstone(tombstone): |
| 144 lines = [] | 151 lines = [] |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 229 """ | 236 """ |
| 230 all_tombstones = list(_ListTombstones(device)) | 237 all_tombstones = list(_ListTombstones(device)) |
| 231 if not all_tombstones: | 238 if not all_tombstones: |
| 232 logging.warning('No tombstones to clear.') | 239 logging.warning('No tombstones to clear.') |
| 233 | 240 |
| 234 for tombstone_file, _ in all_tombstones: | 241 for tombstone_file, _ in all_tombstones: |
| 235 _EraseTombstone(device, tombstone_file) | 242 _EraseTombstone(device, tombstone_file) |
| 236 | 243 |
| 237 | 244 |
| 238 def ResolveTombstones(device, resolve_all_tombstones, include_stack_symbols, | 245 def ResolveTombstones(device, resolve_all_tombstones, include_stack_symbols, |
| 239 wipe_tombstones, jobs=4): | 246 wipe_tombstones, jobs=4, apk_under_test=None): |
| 240 """Resolve tombstones in the device. | 247 """Resolve tombstones in the device. |
| 241 | 248 |
| 242 Args: | 249 Args: |
| 243 device: An instance of DeviceUtils. | 250 device: An instance of DeviceUtils. |
| 244 resolve_all_tombstone: Whether to resolve every tombstone. | 251 resolve_all_tombstone: Whether to resolve every tombstone. |
| 245 include_stack_symbols: Whether to include symbols for stack data. | 252 include_stack_symbols: Whether to include symbols for stack data. |
| 246 wipe_tombstones: Whether to wipe tombstones. | 253 wipe_tombstones: Whether to wipe tombstones. |
| 247 jobs: Number of jobs to use when processing multiple crash stacks. | 254 jobs: Number of jobs to use when processing multiple crash stacks. |
| 248 | 255 |
| 249 Returns: | 256 Returns: |
| 250 A list of resolved tombstones. | 257 A list of resolved tombstones. |
| 251 """ | 258 """ |
| 259 if apk_under_test: | |
| 260 subprocess.check_call( | |
|
jbudorick
2017/07/17 16:43:48
Er, sorry, thought of this after sending the revie
| |
| 261 'unzip -o %s -d %s' % (apk_under_test, | |
|
jbudorick
2017/07/17 15:50:45
nit: pass this as a list, i.e.
['unzip', ...]
| |
| 262 constants.GetOutDirectory()), | |
|
jbudorick
2017/07/17 15:50:45
I don't think we should extract this directly into
| |
| 263 shell=True) | |
|
jbudorick
2017/07/17 15:50:45
This shouldn't need shell features.
| |
| 264 | |
| 252 return _ResolveTombstones(jobs, | 265 return _ResolveTombstones(jobs, |
| 253 _GetTombstonesForDevice(device, | 266 _GetTombstonesForDevice(device, |
| 254 resolve_all_tombstones, | 267 resolve_all_tombstones, |
| 255 include_stack_symbols, | 268 include_stack_symbols, |
| 256 wipe_tombstones)) | 269 wipe_tombstones)) |
| 257 | 270 |
| 258 | 271 |
| 259 def main(): | 272 def main(): |
| 260 custom_handler = logging.StreamHandler(sys.stdout) | 273 custom_handler = logging.StreamHandler(sys.stdout) |
| 261 custom_handler.setFormatter(run_tests_helper.CustomFormatter()) | 274 custom_handler.setFormatter(run_tests_helper.CustomFormatter()) |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 306 for device in devices: | 319 for device in devices: |
| 307 resolved_tombstones = ResolveTombstones( | 320 resolved_tombstones = ResolveTombstones( |
| 308 device, args.all_tombstones, | 321 device, args.all_tombstones, |
| 309 args.stack, args.wipe_tombstones, args.jobs) | 322 args.stack, args.wipe_tombstones, args.jobs) |
| 310 for line in resolved_tombstones: | 323 for line in resolved_tombstones: |
| 311 logging.info(line) | 324 logging.info(line) |
| 312 | 325 |
| 313 | 326 |
| 314 if __name__ == '__main__': | 327 if __name__ == '__main__': |
| 315 sys.exit(main()) | 328 sys.exit(main()) |
| OLD | NEW |