Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(321)

Side by Side Diff: build/android/tombstones.py

Issue 2237553003: (Reland) Added tombstones in instrumentation tests results. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « build/android/test_runner.pydeps ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 152
153 def _ResolveTombstones(jobs, tombstones): 153 def _ResolveTombstones(jobs, tombstones):
154 """Resolve a list of tombstones. 154 """Resolve a list of tombstones.
155 155
156 Args: 156 Args:
157 jobs: the number of jobs to use with multiprocess. 157 jobs: the number of jobs to use with multiprocess.
158 tombstones: a list of tombstones. 158 tombstones: a list of tombstones.
159 """ 159 """
160 if not tombstones: 160 if not tombstones:
161 logging.warning('No tombstones to resolve.') 161 logging.warning('No tombstones to resolve.')
162 return 162 return []
163 if len(tombstones) == 1: 163 if len(tombstones) == 1:
164 data = [_ResolveTombstone(tombstones[0])] 164 data = [_ResolveTombstone(tombstones[0])]
165 else: 165 else:
166 pool = multiprocessing.Pool(processes=jobs) 166 pool = multiprocessing.Pool(processes=jobs)
167 data = pool.map(_ResolveTombstone, tombstones) 167 data = pool.map(_ResolveTombstone, tombstones)
168 resolved_tombstones = []
168 for tombstone in data: 169 for tombstone in data:
169 for line in tombstone: 170 resolved_tombstones.extend(tombstone)
170 logging.info(line) 171 return resolved_tombstones
171 172
172 173 def _GetTombstonesForDevice(device, resolve_all_tombstones,
173 def _GetTombstonesForDevice(device, args): 174 include_stack_symbols,
175 wipe_tombstones):
174 """Returns a list of tombstones on a given device. 176 """Returns a list of tombstones on a given device.
175 177
176 Args: 178 Args:
177 device: An instance of DeviceUtils. 179 device: An instance of DeviceUtils.
178 args: command line arguments 180 resolve_all_tombstone: Whether to resolve every tombstone.
181 include_stack_symbols: Whether to include symbols for stack data.
182 wipe_tombstones: Whether to wipe tombstones.
179 """ 183 """
180 ret = [] 184 ret = []
181 all_tombstones = list(_ListTombstones(device)) 185 all_tombstones = list(_ListTombstones(device))
182 if not all_tombstones: 186 if not all_tombstones:
183 logging.warning('No tombstones.') 187 logging.warning('No tombstones.')
184 return ret 188 return ret
185 189
186 # Sort the tombstones in date order, descending 190 # Sort the tombstones in date order, descending
187 all_tombstones.sort(cmp=lambda a, b: cmp(b[1], a[1])) 191 all_tombstones.sort(cmp=lambda a, b: cmp(b[1], a[1]))
188 192
189 # Only resolve the most recent unless --all-tombstones given. 193 # Only resolve the most recent unless --all-tombstones given.
190 tombstones = all_tombstones if args.all_tombstones else [all_tombstones[0]] 194 tombstones = all_tombstones if resolve_all_tombstones else [all_tombstones[0]]
191 195
192 device_now = _GetDeviceDateTime(device) 196 device_now = _GetDeviceDateTime(device)
193 try: 197 try:
194 for tombstone_file, tombstone_time in tombstones: 198 for tombstone_file, tombstone_time in tombstones:
195 ret += [{'serial': str(device), 199 ret += [{'serial': str(device),
196 'device_abi': device.product_cpu_abi, 200 'device_abi': device.product_cpu_abi,
197 'device_now': device_now, 201 'device_now': device_now,
198 'time': tombstone_time, 202 'time': tombstone_time,
199 'file': tombstone_file, 203 'file': tombstone_file,
200 'stack': args.stack, 204 'stack': include_stack_symbols,
201 'data': _GetTombstoneData(device, tombstone_file)}] 205 'data': _GetTombstoneData(device, tombstone_file)}]
202 except device_errors.CommandFailedError: 206 except device_errors.CommandFailedError:
203 for entry in device.StatDirectory( 207 for entry in device.StatDirectory(
204 '/data/tombstones', as_root=True, timeout=60): 208 '/data/tombstones', as_root=True, timeout=60):
205 logging.info('%s: %s', str(device), entry) 209 logging.info('%s: %s', str(device), entry)
206 raise 210 raise
207 211
208 # Erase all the tombstones if desired. 212 # Erase all the tombstones if desired.
209 if args.wipe_tombstones: 213 if wipe_tombstones:
210 for tombstone_file, _ in all_tombstones: 214 for tombstone_file, _ in all_tombstones:
211 _EraseTombstone(device, tombstone_file) 215 _EraseTombstone(device, tombstone_file)
212 216
213 return ret 217 return ret
214 218
219 def ClearAllTombstones(device):
220 """Clear all tombstones in the device.
221
222 Args:
223 device: An instance of DeviceUtils.
224 """
225 all_tombstones = list(_ListTombstones(device))
226 if not all_tombstones:
227 logging.warning('No tombstones to clear.')
228
229 for tombstone_file, _ in all_tombstones:
230 _EraseTombstone(device, tombstone_file)
231
232 def ResolveTombstones(device, resolve_all_tombstones, include_stack_symbols,
233 wipe_tombstones, jobs=4):
234 """Resolve tombstones in the device.
235
236 Args:
237 device: An instance of DeviceUtils.
238 resolve_all_tombstone: Whether to resolve every tombstone.
239 include_stack_symbols: Whether to include symbols for stack data.
240 wipe_tombstones: Whether to wipe tombstones.
241 jobs: Number of jobs to use when processing multiple crash stacks.
242 """
243 return _ResolveTombstones(jobs,
244 _GetTombstonesForDevice(device,
245 resolve_all_tombstones,
246 include_stack_symbols,
247 wipe_tombstones))
215 248
216 def main(): 249 def main():
217 custom_handler = logging.StreamHandler(sys.stdout) 250 custom_handler = logging.StreamHandler(sys.stdout)
218 custom_handler.setFormatter(run_tests_helper.CustomFormatter()) 251 custom_handler.setFormatter(run_tests_helper.CustomFormatter())
219 logging.getLogger().addHandler(custom_handler) 252 logging.getLogger().addHandler(custom_handler)
220 logging.getLogger().setLevel(logging.INFO) 253 logging.getLogger().setLevel(logging.INFO)
221 254
222 parser = argparse.ArgumentParser() 255 parser = argparse.ArgumentParser()
223 parser.add_argument('--device', 256 parser.add_argument('--device',
224 help='The serial number of the device. If not specified ' 257 help='The serial number of the device. If not specified '
(...skipping 28 matching lines...) Expand all
253 constants.CheckOutputDirectory() 286 constants.CheckOutputDirectory()
254 287
255 if args.device: 288 if args.device:
256 devices = [device_utils.DeviceUtils(args.device)] 289 devices = [device_utils.DeviceUtils(args.device)]
257 else: 290 else:
258 devices = device_utils.DeviceUtils.HealthyDevices(blacklist) 291 devices = device_utils.DeviceUtils.HealthyDevices(blacklist)
259 292
260 # This must be done serially because strptime can hit a race condition if 293 # This must be done serially because strptime can hit a race condition if
261 # used for the first time in a multithreaded environment. 294 # used for the first time in a multithreaded environment.
262 # http://bugs.python.org/issue7980 295 # http://bugs.python.org/issue7980
263 tombstones = []
264 for device in devices: 296 for device in devices:
265 tombstones += _GetTombstonesForDevice(device, args) 297 resolved_tombstones = ResolveTombstones(
266 298 device, args.all_tombstones,
267 _ResolveTombstones(args.jobs, tombstones) 299 args.stack, args.wipe_tombstones, args.jobs)
268 300 for line in resolved_tombstones:
301 logging.info(line)
269 302
270 if __name__ == '__main__': 303 if __name__ == '__main__':
271 sys.exit(main()) 304 sys.exit(main())
OLDNEW
« no previous file with comments | « build/android/test_runner.pydeps ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698