示例#1
0
    def CollectDebugData(self, log_level):
        """Collects various information that may be useful for debugging.

    Specifically:
      1. Captures a screenshot.
      2. Collects stdout and system logs.
      3. Attempts to symbolize all currently unsymbolized minidumps.

    All collected information is stored as artifacts, and everything but the
    screenshot is also included in the return value.

    Platforms may override this to provide other debug information in addition
    to the above set of information.

    Args:
      log_level: The logging level to use from the logging module, e.g.
          logging.ERROR.

    Returns:
      A debug_data.DebugData object containing the collected data.
    """
        suffix = artifact_logger.GetTimestampSuffix()
        data = debug_data.DebugData()
        self._CollectScreenshot(log_level, suffix + '.png')
        self._CollectSystemLog(log_level, suffix + '.txt', data)
        self._CollectStdout(log_level, suffix + '.txt', data)
        self._SymbolizeAndLogMinidumps(log_level, data)
        return data
示例#2
0
    def CollectDebugData(self, log_level):
        """Collects various information that may be useful for debugging.

    In addition to any data collected by parents' implementation, this also
    collects the following and stores it as artifacts:
      1. UI state of the device
      2. Logcat
      3. Symbolized logcat
      4. Tombstones

    Args:
      log_level: The logging level to use from the logging module, e.g.
          logging.ERROR.

    Returns:
      A debug_data.DebugData object containing the collected data.
    """
        # Store additional debug information as artifacts.
        # We do these in a mixed order so that higher priority ones are done first.
        # This is so that if an error occurs during debug data collection (e.g.
        # adb issues), we're more likely to end up with useful debug information.
        suffix = artifact_logger.GetTimestampSuffix()
        self._StoreLogcatAsArtifact(suffix)
        retval = super(AndroidBrowserBackend, self).CollectDebugData(log_level)
        self._StoreUiDumpAsArtifact(suffix)
        self._StoreTombstonesAsArtifact(suffix)
        return retval
示例#3
0
  def _CollectBrowserLogs(self, log_level):
    """Helper function to handle the browser log part of CollectDebugData.

    Attempts to retrieve the current and previous browser logs, merge them, and
    save the result as an artifact.

    Args:
      log_level: The logging level to use from the logging module, e.g.
          logging.ERROR.
    """
    # /var/log/chrome/chrome is the log for the current browser, but in case
    # there's something useful in the previous browser's logs, merge chrome
    # and chrome.PREVIOUS.
    try:
      current_log = self._cri.GetFileContents('/var/log/chrome/chrome')
    except OSError:
      logging.log(log_level, 'Unexpectedly did not find browser log')
      return
    current_log = '#### Current Chrome Log ####\n\n%s' % current_log
    try:
      previous_log = self._cri.GetFileContents(
          '/var/log/chrome/chrome.PREVIOUS')
    except OSError:
      # This is expected if this is the first browser launch on this device.
      previous_log = 'Did not find a previous Chrome log.'
    merged_log = '%s\n\n#### Previous Chrome Log ####\n\n%s' % (current_log,
                                                                previous_log)
    artifact_name = posixpath.join(
        'browser_logs', 'browser_log-%s' % artifact_logger.GetTimestampSuffix())
    logging.log(log_level, 'Saving browser log as artifact %s', artifact_name)
    artifact_logger.CreateArtifact(artifact_name, merged_log)
示例#4
0
  def _CollectUiLogs(self, log_level):
    """Helper function to handle the UI log part of CollectDebugData.

    Attempts to retrieve the current UI log and save it as an artifact.

    Args:
      log_level: The logging level to use from the logging module, e.g.
          logging.ERROR.
    """
    # Unlike the browser logs, there is no .PREVIOUS version, so we can only
    # easily get the most recent UI log.
    try:
      ui_log = self._cri.GetFileContents('/var/log/ui/ui.LATEST')
    except OSError:
      logging.log(log_level, 'Unexpectedly did not find UI log')
      return
    artifact_name = posixpath.join(
        'ui_logs', 'ui_log-%s' % artifact_logger.GetTimestampSuffix())
    logging.log(log_level, 'Saving UI log as artifact %s', artifact_name)
    artifact_logger.CreateArtifact(artifact_name, ui_log)
示例#5
0
    def CollectDebugData(self, log_level):
        """Collects various information that may be useful for debugging.

    In addition to any data collected by parents' implementation, this also
    collects the following and stores it as artifacts:
      1. UI state of the device
      2. Logcat
      3. Symbolized logcat
      4. Tombstones

    Args:
      log_level: The logging level to use from the logging module, e.g.
          logging.ERROR.

    Returns:
      A debug_data.DebugData object containing the collected data.
    """
        # Store additional debug information as artifacts.
        suffix = artifact_logger.GetTimestampSuffix()
        self._StoreUiDumpAsArtifact(suffix)
        self._StoreLogcatAsArtifact(suffix)
        self._StoreTombstonesAsArtifact(suffix)
        return super(AndroidBrowserBackend, self).CollectDebugData(log_level)