def _ProcessUploadAndEmailCrashes(self): """Upload the crashes found and email the team about this.""" logging.info('#########INSIDE _ProcessUploadAndEmailCrashes#########') try: build_version = self.chrome_version self._SaveSymbols(self.symbols_dir) self._ProcessOnlyFirstCrash() file_to_attach = self._GetFirstCrashFile() # removing the crash_txt for now, # since we are getting UnicodeDecodeError # crash_txt = open(file_to_attach).read() except ValueError: test_utils.SendMail(self.stress_pref['mailing_address'], self.stress_pref['mailing_address'], "We don't have build version", "BROWSER CRASHED, PLEASE CHECK", self.stress_pref['smtp']) # Move crash reports and dumps to server os_name = self._GetOSName() dest_dir = build_version + '_' + os_name if (test_utils.Shell2(self.stress_pref['script'] % (CRASHES, dest_dir))): logging.info('Copy Complete') upload_dir = self.stress_pref['upload_dir'] + dest_dir num_crashes = '\n \n Number of Crashes :' + \ str(len(glob.glob1(self.breakpad_dir, '*.dmp'))) mail_content = '\n\n Crash Report URL :' + upload_dir + '\n' + \ num_crashes + '\n\n' # + crash_txt mail_subject = 'Stress Results :' + os_name + '_' + build_version # Sending mail with first crash report, # of crashes, location of upload test_utils.SendMail(self.stress_pref['mailing_address'], self.stress_pref['mailing_address'], mail_subject, mail_content, self.stress_pref['smtp'], file_to_attach)
def _SymbolicateCrashDmp(self, dmp_file, symbols_dir, output_file): """Generate symbolicated crash report. Args: dmp_file: the dmp file to symbolicate. symbols_dir: the directory containing the symbols. output_file: the output file. Returns: Crash report text. """ report = '' if self.IsWin(): windbg_cmd = [ os.path.join('C:', 'Program Files', 'Debugging Tools for Windows', 'windbg.exe'), '-Q', '-y', '\"', symbols_dir, '\"', '-c', '\".ecxr;k50;.logclose;q\"', '-logo', output_file, '-z', '\"', dmp_file, '\"'] subprocess.call(windbg_cmd) # Since we are directly writing the info into output_file, # we just need to copy that in to report report = open(output_file, 'r').read() elif self.IsMac(): crash_report = os.path.join(self.DataDir(), 'pyauto_private', 'stress', 'mac', 'crash_report') for i in range(5): # crash_report doesn't work sometimes. So we retry report = test_utils.Shell2( '%s -S "%s" "%s"' % (crash_report, symbols_dir, dmp_file))[0] if len(report) < 200: try_again = 'Try %d. crash_report didn\'t work out. Trying again', i logging.info(try_again) else: break open(output_file, 'w').write(report) return report