Quantcast
Channel: C#
Viewing all articles
Browse latest Browse all 1853

Preparing a Target Android* System for Remote Analysis

$
0
0

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:

Optionally, do the following:

  • Enable Java* analysis.

  • 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:

  1. Allow Debug connections to enable adb access:

    1. Select Settings> About <device>.

    2. Tap Build number seven times to enable the Developer Options tab.

    3. 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.

  2. 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:

  1. 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.

  2. 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
  3. 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™ processors

  • Hardware 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:

  1. Basic information about the compiled trace: root@android:/ # cat /data/local.prop dalvik.vm.extra-opts=-Xjitvtuneinfo:jit

  2. 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

  3. 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

  4. 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 .apk file

  1. Set the system property dalvik.vm.dex2oat-flags to --include-debug-symbols:

    adb shell setprop dalvik.vm.dex2oat-flags --include-debug-symbols

  2. If you use --compiler-filter=interpret-only, set the optimization level to O2:

    adb shell setprop
    dalvik.vm.dex2oat-filter O2

  3. (Re-)install the application.

    adb shell install -r
    TheApp.apk

Profile an application executed by the dalvikvm executable

Add the compiler option --include-debug-symbols followed by -Xcompiler-option. Make sure the application has not been compiled yet.

rm –f /data/dalvik-cache/*/*TheApp.jar*
adb shell dalvikvm –Xcompiler-option --include-debug-symbols –cp TheApp.jar

Profile system and core classes

Note

This action is required if Java core classes get compiled to the /data/dalvik-cache/ subdirectory. Manufacturers may place them in different directories. If manufactures supply the precompiled boot.oat file in /system/framework/x86, Java core classes will not be resolved because they cannot be re-compiled with debug information.

Set the system property dalvik.vm.image-dex2oat-flags to --include-debug-symbols and force recompilation:

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 -Ximage-compiler-option --include-debug-symbols:

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.


Viewing all articles
Browse latest Browse all 1853

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>