Commit effbb9ae authored by jbudorick's avatar jbudorick Committed by Commit bot

[Android] Log exceptions thrown by newly converted DeviceUtils calls in telemetry.

BUG=489317

Review URL: https://codereview.chromium.org/1165463010

Cr-Commit-Position: refs/heads/master@{#333078}
parent 79f37760
...@@ -84,8 +84,12 @@ class AndroidPlatformBackend( ...@@ -84,8 +84,12 @@ class AndroidPlatformBackend(
self._perf_tests_setup = perf_control.PerfControl(self._device) self._perf_tests_setup = perf_control.PerfControl(self._device)
self._thermal_throttle = thermal_throttle.ThermalThrottle(self._device) self._thermal_throttle = thermal_throttle.ThermalThrottle(self._device)
self._raw_display_frame_rate_measurements = [] self._raw_display_frame_rate_measurements = []
self._can_access_protected_file_contents = ( try:
self._device.HasRoot() or self._device.NeedsSU()) self._can_access_protected_file_contents = (
self._device.HasRoot() or self._device.NeedsSU())
except:
logging.exception('New exception caused by DeviceUtils conversion')
raise
self._device_copy_script = None self._device_copy_script = None
power_controller = power_monitor_controller.PowerMonitorController([ power_controller = power_monitor_controller.PowerMonitorController([
monsoon_power_monitor.MonsoonPowerMonitor(self._device, self), monsoon_power_monitor.MonsoonPowerMonitor(self._device, self),
...@@ -210,8 +214,12 @@ class AndroidPlatformBackend( ...@@ -210,8 +214,12 @@ class AndroidPlatformBackend(
if not android_prebuilt_profiler_helper.InstallOnDevice( if not android_prebuilt_profiler_helper.InstallOnDevice(
self._device, 'purge_ashmem'): self._device, 'purge_ashmem'):
raise Exception('Error installing purge_ashmem.') raise Exception('Error installing purge_ashmem.')
output = self._device.RunShellCommand( try:
android_prebuilt_profiler_helper.GetDevicePath('purge_ashmem')) 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: for l in output:
logging.info(l) logging.info(l)
...@@ -542,8 +550,12 @@ class AndroidPlatformBackend( ...@@ -542,8 +550,12 @@ class AndroidPlatformBackend(
self._device.PushChangedFiles([(new_profile_dir, saved_profile_location)]) self._device.PushChangedFiles([(new_profile_dir, saved_profile_location)])
profile_dir = self._GetProfileDir(package) profile_dir = self._GetProfileDir(package)
self._EfficientDeviceDirectoryCopy( try:
saved_profile_location, profile_dir) self._EfficientDeviceDirectoryCopy(
saved_profile_location, profile_dir)
except:
logging.exception('New exception caused by DeviceUtils conversion')
raise
dumpsys = self._device.RunShellCommand('dumpsys package %s' % package) dumpsys = self._device.RunShellCommand('dumpsys package %s' % package)
id_line = next(line for line in dumpsys if 'userId=' in line) id_line = next(line for line in dumpsys if 'userId=' in line)
uid = re.search(r'\d+', id_line).group() uid = re.search(r'\d+', id_line).group()
...@@ -595,7 +607,11 @@ class AndroidPlatformBackend( ...@@ -595,7 +607,11 @@ class AndroidPlatformBackend(
# pulled down is really needed e.g. .pak files. # pulled down is really needed e.g. .pak files.
if not os.path.exists(output_profile_path): if not os.path.exists(output_profile_path):
os.makedirs(output_profile_path) os.makedirs(output_profile_path)
files = self._device.RunShellCommand(['ls', profile_dir]) try:
files = self._device.RunShellCommand(['ls', profile_dir])
except:
logging.exception('New exception caused by DeviceUtils conversion')
raise
for f in files: for f in files:
# Don't pull lib, since it is created by the installer. # Don't pull lib, since it is created by the installer.
if f != 'lib': if f != 'lib':
......
...@@ -43,9 +43,13 @@ class DS2784PowerMonitor(sysfs_power_monitor.SysfsPowerMonitor): ...@@ -43,9 +43,13 @@ class DS2784PowerMonitor(sysfs_power_monitor.SysfsPowerMonitor):
def CanMonitorPower(self): def CanMonitorPower(self):
if not self._HasFuelGauge(): if not self._HasFuelGauge():
return False return False
if self._device_battery.GetCharging(): try:
logging.warning("Can't monitor power usage since device is charging.") if self._device_battery.GetCharging():
return False logging.warning("Can't monitor power usage since device is charging.")
return False
except:
logging.exception('New exception caused by DeviceUtils conversion')
raise
return True return True
def StartMonitoringPower(self, browser): def StartMonitoringPower(self, browser):
......
...@@ -208,7 +208,11 @@ def CreateSymFs(device, symfs_dir, libraries, use_symlinks=True): ...@@ -208,7 +208,11 @@ def CreateSymFs(device, symfs_dir, libraries, use_symlinks=True):
pull = True pull = True
else: else:
host_md5sums = md5sum.CalculateHostMd5Sums([output_lib]) host_md5sums = md5sum.CalculateHostMd5Sums([output_lib])
device_md5sums = md5sum.CalculateDeviceMd5Sums([lib], device) try:
device_md5sums = md5sum.CalculateDeviceMd5Sums([lib], device)
except:
logging.exception('New exception caused by DeviceUtils conversion')
raise
pull = (not host_md5sums or not device_md5sums pull = (not host_md5sums or not device_md5sums
or host_md5sums[0] != device_md5sums[0]) or host_md5sums[0] != device_md5sums[0])
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
import logging
import os import os
from telemetry.core.backends.chrome import android_browser_finder from telemetry.core.backends.chrome import android_browser_finder
...@@ -58,8 +59,12 @@ class AndroidTraceviewProfiler(profiler.Profiler): ...@@ -58,8 +59,12 @@ class AndroidTraceviewProfiler(profiler.Profiler):
# pylint: disable=cell-var-from-loop # pylint: disable=cell-var-from-loop
util.WaitFor(lambda: self._FileSize(trace_file) > 0, timeout=10) util.WaitFor(lambda: self._FileSize(trace_file) > 0, timeout=10)
output_files.append(trace_file) output_files.append(trace_file)
self._browser_backend.adb.device().PullFile( try:
self._DEFAULT_DEVICE_DIR, self._output_path) self._browser_backend.adb.device().PullFile(
self._DEFAULT_DEVICE_DIR, self._output_path)
except:
logging.exception('New exception caused by DeviceUtils conversion')
raise
self._browser_backend.adb.RunShellCommand( self._browser_backend.adb.RunShellCommand(
'rm ' + os.path.join(self._DEFAULT_DEVICE_DIR, '*')) 'rm ' + os.path.join(self._DEFAULT_DEVICE_DIR, '*'))
print 'Traceview profiles available in ', self._output_path print 'Traceview profiles available in ', self._output_path
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
import logging
import os import os
import subprocess import subprocess
import threading import threading
...@@ -48,8 +49,12 @@ class JavaHeapProfiler(profiler.Profiler): ...@@ -48,8 +49,12 @@ class JavaHeapProfiler(profiler.Profiler):
def CollectProfile(self): def CollectProfile(self):
self._timer.cancel() self._timer.cancel()
self._DumpJavaHeap(True) self._DumpJavaHeap(True)
self._browser_backend.adb.device().PullFile( try:
self._DEFAULT_DEVICE_DIR, self._output_path) self._browser_backend.adb.device().PullFile(
self._DEFAULT_DEVICE_DIR, self._output_path)
except:
logging.exception('New exception caused by DeviceUtils conversion')
raise
self._browser_backend.adb.RunShellCommand( self._browser_backend.adb.RunShellCommand(
'rm ' + os.path.join(self._DEFAULT_DEVICE_DIR, '*')) 'rm ' + os.path.join(self._DEFAULT_DEVICE_DIR, '*'))
output_files = [] output_files = []
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
import logging
import tempfile import tempfile
from telemetry.core.platform import profiler from telemetry.core.platform import profiler
...@@ -36,7 +37,12 @@ class NetLogProfiler(profiler.Profiler): ...@@ -36,7 +37,12 @@ class NetLogProfiler(profiler.Profiler):
# On Android pull the output file to the host. # On Android pull the output file to the host.
if self._platform_backend.GetOSName() == 'android': if self._platform_backend.GetOSName() == 'android':
host_output_file = '%s.json' % self._output_path host_output_file = '%s.json' % self._output_path
self._browser_backend.adb.device().PullFile(output_file, host_output_file) try:
self._browser_backend.adb.device().PullFile(
output_file, host_output_file)
except:
logging.exception('New exception caused by DeviceUtils conversion')
raise
# Clean the device # Clean the device
self._browser_backend.adb.device().RunShellCommand('rm %s' % output_file) self._browser_backend.adb.device().RunShellCommand('rm %s' % output_file)
output_file = host_output_file output_file = host_output_file
......
...@@ -128,7 +128,11 @@ Try rerunning this script under sudo or setting ...@@ -128,7 +128,11 @@ Try rerunning this script under sudo or setting
self._output_file) self._output_file)
if self._is_android: if self._is_android:
device = self._browser_backend.adb.device() device = self._browser_backend.adb.device()
device.PullFile(self._device_output_file, self._output_file) try:
device.PullFile(self._device_output_file, self._output_file)
except:
logging.exception('New exception caused by DeviceUtils conversion')
raise
required_libs = \ required_libs = \
android_profiling_helper.GetRequiredLibrariesForPerfProfile( android_profiling_helper.GetRequiredLibrariesForPerfProfile(
self._output_file) self._output_file)
......
...@@ -34,7 +34,11 @@ class _TCMallocHeapProfilerAndroid(object): ...@@ -34,7 +34,11 @@ class _TCMallocHeapProfilerAndroid(object):
def _SetDeviceProperties(self, properties): def _SetDeviceProperties(self, properties):
device_configured = False device_configured = False
# This profiler requires adb root to set properties. # This profiler requires adb root to set properties.
self._browser_backend.adb.device().EnableRoot() try:
self._browser_backend.adb.device().EnableRoot()
except:
logging.exception('New exception caused by DeviceUtils conversion')
raise
for values in properties.itervalues(): for values in properties.itervalues():
device_property = self._browser_backend.adb.device().GetProp(values[0]) device_property = self._browser_backend.adb.device().GetProp(values[0])
if not device_property or not device_property.strip(): if not device_property or not device_property.strip():
...@@ -51,8 +55,12 @@ class _TCMallocHeapProfilerAndroid(object): ...@@ -51,8 +55,12 @@ class _TCMallocHeapProfilerAndroid(object):
raise Exception('Device required special config, run again.') raise Exception('Device required special config, run again.')
def CollectProfile(self): def CollectProfile(self):
self._browser_backend.adb.device().PullFile( try:
self._DEFAULT_DEVICE_DIR, self._output_path) self._browser_backend.adb.device().PullFile(
self._DEFAULT_DEVICE_DIR, self._output_path)
except:
logging.exception('New exception caused by DeviceUtils conversion')
raise
self._browser_backend.adb.RunShellCommand( self._browser_backend.adb.RunShellCommand(
'rm ' + os.path.join(self._DEFAULT_DEVICE_DIR, '*')) 'rm ' + os.path.join(self._DEFAULT_DEVICE_DIR, '*'))
if os.path.exists(self._output_path): if os.path.exists(self._output_path):
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
import logging
import os import os
import signal import signal
import subprocess import subprocess
...@@ -44,7 +45,11 @@ class _TCPDumpProfilerAndroid(object): ...@@ -44,7 +45,11 @@ class _TCPDumpProfilerAndroid(object):
self._proc.terminate() self._proc.terminate()
host_dump = os.path.join(self._output_path, host_dump = os.path.join(self._output_path,
os.path.basename(self._DEVICE_DUMP_FILE)) os.path.basename(self._DEVICE_DUMP_FILE))
self._adb.device().PullFile(self._DEVICE_DUMP_FILE, host_dump) try:
self._adb.device().PullFile(self._DEVICE_DUMP_FILE, host_dump)
except:
logging.exception('New exception caused by DeviceUtils conversion')
raise
print 'TCP dump available at: %s ' % host_dump print 'TCP dump available at: %s ' % host_dump
print 'Use Wireshark to open it.' print 'Use Wireshark to open it.'
return host_dump return host_dump
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
import logging
import re import re
import tempfile import tempfile
...@@ -38,7 +39,12 @@ class V8Profiler(profiler.Profiler): ...@@ -38,7 +39,12 @@ class V8Profiler(profiler.Profiler):
# On Android pull the output file to the host. # On Android pull the output file to the host.
if self._platform_backend.GetOSName() == 'android': if self._platform_backend.GetOSName() == 'android':
host_output_file = '%s.log' % self._output_path host_output_file = '%s.log' % self._output_path
self._browser_backend.adb.device().PullFile(output_file, host_output_file) try:
self._browser_backend.adb.device().PullFile(
output_file, host_output_file)
except:
logging.exception('New exception caused by DeviceUtils conversion')
raise
# Clean the device # Clean the device
self._browser_backend.adb.device().RunShellCommand('rm %s' % output_file) self._browser_backend.adb.device().RunShellCommand('rm %s' % output_file)
output_file = host_output_file output_file = host_output_file
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment