Note
Remote analysis on Android* systems is supported in the Intel® VTune™ Amplifier for Systems, part of the Intel® System Studio.
When using the VTune Amplifier to collect data remotely on a target Android device, make sure to:
For hardware event-based sampling or energy analysis, gain a root mode adb access to the Android device.
Optionally, do the following:
To view functions within Android-supplied system libraries, device drivers, or the kernel, get access from the host development system to the exact version of these binaries with symbols not stripped.
To view sources within Android-supplied system libraries, device drivers, or the kernel, get access from the host development system to the sources for these components.
Configuring an Android Device for Analysis
To configure your Android device, do the following:
Allow Debug connections to enable adb access:
Select Settings> About <device>.
Tap Build number seven times to enable the Developer Options tab.
Select the Settings> Developer Options and enable the USB debugging option.
Note
Path to the Developer Options may vary depending on the manufacture of your device and system version.
Enable Unknown Sources to install
Vtune.apk
without Google* Play. To do this, select Settings> Security and enable the Unknown Sources option.
Gaining ADB Access to an Android Device
VTune Amplifier collector for Android requires connectivity to the Android device via adb. If it is difficult or impossible to get adb access to a device over USB, you may get adb over Ethernet or WiFi. After successfully connecting to Ethernet or connecting to a WiFi access point, do the following:
Find the IP Address of the target. The IP address is available in Android for Ethernet via Settings>Wireless&Networks>Ethernet>IP Address or for Wi-Fi via Settings>Wireless&Networks>Wi-Fi><Connected Access Point>>IP Address.
Make sure adb is enabled on the target device. If not enabled, go to Terminal App (of your choice) on the device and type:
$ su $ setprop service.adb.tcp.port 5555 $ stop adbd $ start adbd
Connect adb on the host to the remote device. In the Command Prompt or the Terminal on the host, type:
$ adb connect <IPAddres>:5555
Gaining a Root Mode ADB Access to the Android Device
For performance and Energy analysis on Android platforms, you typically need a root mode adb access to your device to:
Install and load drivers needed for hardware event-based sampling and energy analysis with Intel SoC Watch.
Enable the Android device to support Java* analysis.
Run hardware event-based sampling analysis and energy analysis.
Note
There are several analysis types on Android systems that do NOT require root privileges such as Basic Hotspots and Perf*-based driverless sampling event-based collection.
Depending on the build, you gain root mode adb access differently:
User/Production builds : Gaining root mode adb access to a user build of the Android OS is difficult and different for various devices. Contact your manufacturer for how to do this.
Engineering builds : Root-mode adb access is the default for engineering builds. Engineering builds of the Android OS are by their nature not "optimized". Using the VTune Amplifier against an engineering build is likely to result in VTune Amplifier identifying code to optimize which is already optimized in user and userdebug builds.
Userdebug builds : Userdebug builds of the Android OS offer a compromise between good results and easy-to-run tools. By default, userdebug builds run adb in user mode. VTune Amplifier tools require root mode access to the device, which you can gain via typing
adb root
on the host. These instructions are based on userdebug builds.
Using the Pre-installed Drivers on the Target Android System
For hardware event-based sampling analysis and energy analysis, the VTune Amplifier needs sampling and power drivers to be installed. On some versions of Android systems, including most of the Intel supplied reference builds for SDVs, the following drivers are pre-installed in /lib/modules
or /system/lib/modules
:
Energy analysis collector:
SOCWATCH2_x.ko
applied to the Intel 22 nm ultra-mobile processor and 4th Generation Intel® Core™ processorsHardware event-based analysis collectors:
pax.ko
sep3_x.ko
vtsspp.ko
Typically having pre-installed drivers is more convenient. You can check for pre-installed drivers by typing:
adb shell ls [/lib/modules|/system/lib/modules]
If the drivers are not available or the version does not match requirements, consider:
Enabling Java* Analysis
Enabling Java Analysis on Rooted Devices
By default, the VTune Amplifier installs the remote collector on the target rooted Android devices with the --jitvtuneinfo=src
option. To change the Java profiling option for rooted devices, you need to re-install the remote collector on the target manually using the --jitvtuneinfo=[jit|src|dex|none]
option on amplxe-androidreg.bat
. For example:
<install-dir>/bin32/amplxe-androidreg.bat --package-command=install --jitvtuneinfo=src
VTune Amplifier updates the /data/local.prop
file as follows:
Basic information about the compiled trace:
root@android:/ # cat /data/local.prop dalvik.vm.extra-opts=-Xjitvtuneinfo:jit
Mapping from JIT code to Java source code and basic information about the compiled trace:
root@android:/ # cat /data/local.prop dalvik.vm.extra-opts=-Xjitvtuneinfo:src
Mapping from JIT code to DEX code and basic information about the compiled trace:
root@android:/ # cat /data/local.prop dalvik.vm.extra-opts=-Xjitvtuneinfo:dex
JIT data collection. By default, JIT collection is disabled if you do not supply any options:
root@android:/ # cat /data/local.prop dalvik.vm.extra-opts=-Xjitvtuneinfo:none
Additionally, if your Dalvik JVM supports instruction scheduling, disable it by adding -Xnoscheduling
at the end of dalvik.vm.extra-opts
. For example:
root@android:/ # cat /data/local.prop dalvik.vm.extra-opts=-Xjitvtuneinfo:src -Xnoscheduling
Note
Java analysis currently requires an instrumented Dalvik JVM. Android systems running on the 4th Generation Intel® Core™ processors or Android systems using ART vs. Dalvik for Java are not instrumented to support JIT profiling. You do not need to specify --jitvtuneinfo=N
.
Enabling Java Analysis for Code Generated with ART* Compiler
To enable a source-level analysis, the VTune Amplifier requires debug information for the analyzed binary files. By default, the ART compiler does not generate the debug information for Java code. Depending on your usage scenario, you may choose how to enable generating the debug information with the ART compiler:
Note
Starting with Android 6.0 Marshmallow*, the --include-debug-symbols
option mentioned below is renamed to --generate-debug-info
.
To Do This: | Do This: |
---|---|
Profile an application installed as an |
|
Profile an application executed by the | Add the compiler option rm –f /data/dalvik-cache/*/*TheApp.jar* adb shell dalvikvm –Xcompiler-option --include-debug-symbols –cp TheApp.jar |
Profile system and core classes NoteThis action is required if Java core classes get compiled to the | Set the system property adb shell stop adb shell rm –f /data/dalvik-cache/*/* adb shell setprop dalvik.vm.dex2oat-flags --include-debug-symbols adb shell setprop dalvik.vm.image-dex2oat-flags --include-debug-symbols adb shell start If you run the application before the system classes are compiled, you should add another compiler option adb shell rm –f /data/dalvik-cache/*/* adb shell dalvikvm –Xcompiler-option --include-debug-symbols -Ximage-compiler-option --include-debug-symbols –cp TheApp.jar |
Tip
If you are able to see the --include-debug-symbols
option in the logcat output (adb logcat *:S dex2oat:I
), the compiler uses this option.