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 11 matching lines...) Expand all Loading... |
22 | 22 |
23 def _ListTombstones(device): | 23 def _ListTombstones(device): |
24 """List the tombstone files on the device. | 24 """List the tombstone files on the device. |
25 | 25 |
26 Args: | 26 Args: |
27 device: An instance of DeviceUtils. | 27 device: An instance of DeviceUtils. |
28 | 28 |
29 Yields: | 29 Yields: |
30 Tuples of (tombstone filename, date time of file on device). | 30 Tuples of (tombstone filename, date time of file on device). |
31 """ | 31 """ |
32 lines = device.old_interface.RunShellCommand( | 32 lines = device.RunShellCommand('TZ=UTC su -c ls -a -l /data/tombstones') |
33 'TZ=UTC su -c ls -a -l /data/tombstones') | |
34 for line in lines: | 33 for line in lines: |
35 if 'tombstone' in line and not 'No such file or directory' in line: | 34 if 'tombstone' in line and not 'No such file or directory' in line: |
36 details = line.split() | 35 details = line.split() |
37 t = datetime.datetime.strptime(details[-3] + ' ' + details[-2], | 36 t = datetime.datetime.strptime(details[-3] + ' ' + details[-2], |
38 '%Y-%m-%d %H:%M') | 37 '%Y-%m-%d %H:%M') |
39 yield details[-1], t | 38 yield details[-1], t |
40 | 39 |
41 | 40 |
42 def _GetDeviceDateTime(device): | 41 def _GetDeviceDateTime(device): |
43 """Determine the date time on the device. | 42 """Determine the date time on the device. |
44 | 43 |
45 Args: | 44 Args: |
46 device: An instance of DeviceUtils. | 45 device: An instance of DeviceUtils. |
47 | 46 |
48 Returns: | 47 Returns: |
49 A datetime instance. | 48 A datetime instance. |
50 """ | 49 """ |
51 device_now_string = device.old_interface.RunShellCommand('TZ=UTC date') | 50 device_now_string = device.RunShellCommand('TZ=UTC date') |
52 return datetime.datetime.strptime( | 51 return datetime.datetime.strptime( |
53 device_now_string[0], '%a %b %d %H:%M:%S %Z %Y') | 52 device_now_string[0], '%a %b %d %H:%M:%S %Z %Y') |
54 | 53 |
55 | 54 |
56 def _GetTombstoneData(device, tombstone_file): | 55 def _GetTombstoneData(device, tombstone_file): |
57 """Retrieve the tombstone data from the device | 56 """Retrieve the tombstone data from the device |
58 | 57 |
59 Args: | 58 Args: |
60 device: An instance of DeviceUtils. | 59 device: An instance of DeviceUtils. |
61 tombstone_file: the tombstone to retrieve | 60 tombstone_file: the tombstone to retrieve |
62 | 61 |
63 Returns: | 62 Returns: |
64 A list of lines | 63 A list of lines |
65 """ | 64 """ |
66 return device.old_interface.GetProtectedFileContents( | 65 return device.old_interface.GetProtectedFileContents( |
67 '/data/tombstones/' + tombstone_file) | 66 '/data/tombstones/' + tombstone_file) |
68 | 67 |
69 | 68 |
70 def _EraseTombstone(device, tombstone_file): | 69 def _EraseTombstone(device, tombstone_file): |
71 """Deletes a tombstone from the device. | 70 """Deletes a tombstone from the device. |
72 | 71 |
73 Args: | 72 Args: |
74 device: An instance of DeviceUtils. | 73 device: An instance of DeviceUtils. |
75 tombstone_file: the tombstone to delete. | 74 tombstone_file: the tombstone to delete. |
76 """ | 75 """ |
77 return device.old_interface.RunShellCommandWithSU( | 76 return device.RunShellCommand( |
78 'rm /data/tombstones/' + tombstone_file) | 77 'rm /data/tombstones/' + tombstone_file, root=True) |
79 | 78 |
80 | 79 |
81 def _ResolveSymbols(tombstone_data, include_stack): | 80 def _ResolveSymbols(tombstone_data, include_stack): |
82 """Run the stack tool for given tombstone input. | 81 """Run the stack tool for given tombstone input. |
83 | 82 |
84 Args: | 83 Args: |
85 tombstone_data: a list of strings of tombstone data. | 84 tombstone_data: a list of strings of tombstone data. |
86 include_stack: boolean whether to include stack data in output. | 85 include_stack: boolean whether to include stack data in output. |
87 | 86 |
88 Yields: | 87 Yields: |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 | 190 |
192 tombstones = [] | 191 tombstones = [] |
193 for device_serial in devices: | 192 for device_serial in devices: |
194 device = device_utils.DeviceUtils(device_serial) | 193 device = device_utils.DeviceUtils(device_serial) |
195 tombstones += _GetTombstonesForDevice(device, options) | 194 tombstones += _GetTombstonesForDevice(device, options) |
196 | 195 |
197 _ResolveTombstones(options.jobs, tombstones) | 196 _ResolveTombstones(options.jobs, tombstones) |
198 | 197 |
199 if __name__ == '__main__': | 198 if __name__ == '__main__': |
200 sys.exit(main()) | 199 sys.exit(main()) |
OLD | NEW |