Esempio n. 1
0
 def __init__(self, browser_backend, platform_backend, output_path, state):
   super(TCPDumpProfiler, self).__init__(
       browser_backend, platform_backend, output_path, state)
   if platform_backend.GetOSName() == 'android':
     android_prebuilt_profiler_helper.InstallOnDevice(
         browser_backend.device, 'tcpdump')
     self._platform_profiler = _TCPDumpProfilerAndroid(
         browser_backend.device, output_path)
   else:
     self._platform_profiler = _TCPDumpProfilerLinux(output_path)
Esempio n. 2
0
  def SetGraphicsMemoryTrackingEnabled(self, enabled):
    if not enabled:
      self.KillApplication('memtrack_helper')
      return

    if not android_prebuilt_profiler_helper.InstallOnDevice(
        self._device, 'memtrack_helper'):
      raise Exception('Error installing memtrack_helper.')
    self._device.RunShellCommand([
      android_prebuilt_profiler_helper.GetDevicePath('memtrack_helper'),
      '-d'], as_root=True, check_return=True)
def PrepareDeviceForPerf(device):
    """Set up a device for running perf.

  Args:
    device: DeviceUtils instance identifying the target device.

  Returns:
    The path to the installed perf binary on the device.
  """
    android_prebuilt_profiler_helper.InstallOnDevice(device, 'perf')
    # Make sure kernel pointers are not hidden.
    device.WriteFile('/proc/sys/kernel/kptr_restrict', '0', as_root=True)
    return android_prebuilt_profiler_helper.GetDevicePath('perf')
Esempio n. 4
0
  def SetGraphicsMemoryTrackingEnabled(self, enabled):
    if not enabled:
      self.KillApplication('memtrack_helper')
      return

    if not android_prebuilt_profiler_helper.InstallOnDevice(
        self._device, 'memtrack_helper'):
      raise Exception('Error installing memtrack_helper.')
    try:
      cmd = android_prebuilt_profiler_helper.GetDevicePath('memtrack_helper')
      cmd += ' -d'
      self._device.RunShellCommand(cmd, as_root=True, check_return=True)
    except Exception:
      logging.exception('New exception caused by DeviceUtils conversion')
      raise
Esempio n. 5
0
  def PurgeUnpinnedMemory(self):
    """Purges the unpinned ashmem memory for the whole system.

    This can be used to make memory measurements more stable. Requires root.
    """
    if not self._can_elevate_privilege:
      logging.warning('Cannot run purge_ashmem. Requires a rooted device.')
      return

    if not android_prebuilt_profiler_helper.InstallOnDevice(
        self._device, 'purge_ashmem'):
      raise Exception('Error installing purge_ashmem.')
    output = self._device.RunShellCommand([
      android_prebuilt_profiler_helper.GetDevicePath('purge_ashmem')])
    for l in output:
      logging.info(l)
  def PurgeUnpinnedMemory(self):
    """Purges the unpinned ashmem memory for the whole system.

    This can be used to make memory measurements more stable. Requires root.
    """
    if not self._can_access_protected_file_contents:
      logging.warning('Cannot run purge_ashmem. Requires a rooted device.')
      return

    if not android_prebuilt_profiler_helper.InstallOnDevice(
        self._device, 'purge_ashmem'):
      raise Exception('Error installing purge_ashmem.')
    try:
      output = self._device.RunShellCommand(
          android_prebuilt_profiler_helper.GetDevicePath('purge_ashmem'))
    except:
      logging.exception('New exception caused by DeviceUtils conversion')
      raise
    for l in output:
      logging.info(l)
Esempio n. 7
0
  output_kallsyms = os.path.join(symfs_dir, 'kallsyms')
  if not os.path.exists(output_kallsyms):
    presentation.device.PullFile('/proc/kallsyms', output_kallsyms)
  return output_kallsyms


def PrepareDeviceForPerf(presentation.device):
  """Set up a presentation.device for running perf.

  Args:
    presentation.device: DeviceUtils instance identifying the target presentation.device.

  Returns:
    The path to the installed perf binary on the presentation.device.
  """
  android_prebuilt_profiler_helper.InstallOnDevice(presentation.device, 'perf')
  # Make sure kernel pointers are not hidden.
  presentation.device.WriteFile('/proc/sys/kernel/kptr_restrict', '0', as_root=True)
  return android_prebuilt_profiler_helper.GetDevicePath('perf')


def GetToolchainBinaryPath(library_file, binary_name):
  """Return the path to an Android toolchain binary on the host.

  Args:
    library_file: ELF library which is used to identify the used ABI,
        architecture and toolchain.
    binary_name: Binary to search for, e.g., 'objdump'
  Returns:
    Full path to binary or None if the binary was not found.
  """