User Guide

Intel® VTune™ Profiler User Guide

ID 766319
Date 11/07/2023
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

Enable Java* Analysis on Android* System

Explore configuration settings required to enable Java analysis with Intel® VTune™ Profiler on an Android system:

Enabling Java Analysis on Rooted Devices

By default, the VTune Profiler 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 (Windows) or amplxe-androidreg.sh (Linux). For example:

On Windows*:

<install-dir >\bin32\amplxe-androidreg.bat --package-command=install --jitvtuneinfo=src

On Linux*:

<install-dir >/bin{32,64}/amplxe-androidreg.sh --package-command=install --jitvtuneinfo=src

VTune Profiler 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.

TIP:

If you are able to see the --generate-debug-info option in the logcat output (adb logcat *:S dex2oat:I), the compiler uses this option.

Enabling Java Analysis for Code Generated with ART* Compiler

To enable a source-level analysis, the VTune Profiler 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:

For releases prior to Android 6.0 Marshmallow*, the --generate-debug-info in the examples below should be replaced with --include-debug-symbols.

To Do This:

Do This:

Profile a 3rd party application or system application installed as an .apk file

  1. Set the system property dalvik.vm.dex2oat-flags to --generate-debug-info:

    adb shell setprop dalvik.vm.dex2oat-flags --generate-debug-info

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

    adb shell setprop
    dalvik.vm.dex2oat-filter speed

  3. (Re-)install the application.

    adb shell install -r
    TheApp.apk

Profile all applications installed as .apk or .jar files by re-building the Android image when pre-optimization for private applications is enabled (LOCAL_DEX_PREOPT:=true property set in device.mk)

  1. On your host system, open the /build/core/dex_preopt_libart.mk file, located in your Android OS directory structure.

  2. Modify the --no-generate-debug-info line to --generate-debug-info and save and close the file.

  3. Rebuild the Android image and flash it to your device.

  4. If you are using an Android image that is not PIC configured (WITH_DEXPREOPT_PIC:=false property set in device.mk), generate classes.dex from odex using the patchoat command. classes.dex should appear in /data/dalvik-cache/x86/system@app@appname@appname.apk@classes.dex

Profile all applications installed as .apk or .jar files by re-building the Android image when pre-optimization for private applications is disabled (LOCAL_DEX_PREOPT:=false property set in device.mk)

  1. Set the system property dalvik.vm.dex2oat-flags to --generate-debug-info:

    adb shell rm -rf /data/dalvik-cache/x86/system@app@webview@webview.apk@classes.dex
    adb shell setprop dalvik.vm.dex2oat-flags --generate-debug-info
  2. Stop and start the adb shell:

    adb shell stop
    adb shell start
  3. Generate the dex file:

    adb shell ls /data/dalvik-cache/x86/system@app@webview@webview.apk@classes.dex
    adb pull /data/dalvik-cache/x86/system@app@webview@webview.apk@classes.dex

Profile an application executed by the dalvikvm executable

Add the compiler option --generate-debug-info 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 --generate-debug-info and force recompilation:

adb shell stop
adb shell rm –f /data/dalvik-cache/*/*
adb shell setprop dalvik.vm.dex2oat-flags --generate-debug-info
adb shell setprop dalvik.vm.image-dex2oat-flags --generate-debug-info
adb shell start

If you run the application before the system classes are compiled, you should add another compiler option -Ximage-compiler-option --generate-debug-info:

adb shell rm –f /data/dalvik-cache/*/*
adb shell dalvikvm –Xcompiler-option --generate-debug-info -Ximage-compiler-option --generate-debug-info –cp TheApp.jar