Compile your application

Before you can profile your executable with Streamline, you must compile your executable. This topic describes the compiler options to use when you compile your application.

Profiling native code

When compiling with GCC or Clang, use the following options:

-g

Turns on the debug symbols necessary for quality analysis reports.

-fno-inline

Disables inlining and substantially improves the call path quality.

-fno-omit-frame-pointer

Compiles your EABI images and libraries with frame pointers. This option enables Streamline to record the call stack with each sample taken.

-mno-omit-leaf-frame-pointer

Keeps the frame pointer in leaf functions.

-marm

When building for AArch32, if GCC was compiled with the --with-mode=thumb option enabled, this -marm is required. Using --with-mode=thumb without -marm breaks call stack unwinding in Streamline.

Optional compiler options for call stack unwinding

To enable call stack unwinding in Streamline, you need to compile your executable with some additional compiler options:

  • For AArch64 applications:

    • Compiling with GCC, use: -fno-omit-frame-pointer and -mno-omit-leaf-frame-pointer

      Note

      Arm recommends using -mno-omit-leaf-frame-pointer to prevent samples in leaf functions incorrectly listing their grand-parent function as their parent.

    • Compiling with Clang, use: -fno-omit-frame-pointer

      Note

      -mno-omit-leaf-frame-pointer is not supported on Clang.

  • For AArch32 applications, compiling with either GCC or Clang, use: -fno-omit-frame-pointer, -marm, and -mapcs-frame.

    Note

    Streamline supports call stack unwinding for code that has been generated by Arm® Compiler 6.

    Streamline does not support call stack unwinding for T32 (Thumb®) code.

Profiling Java or Kotlin code

In addition to profiling native code, Streamline can profile OAT files that Android runtime (ART) generates. The Streamline report for the application shows function names and disassembly in the Code view, but not source code.

To enable OAT files to be built with debug symbols, you must run dex2oat with the --no-strip-symbols option. To run dex2oat with the --no-strip-symbols option:

  1. Run the following command on the device:

    setprop dalvik.vm.dex2oat-flags --no-strip-symbols
    
  2. Re-install the APK file

  3. To verify the options for dex2oat are set correctly, run the command:

    getprop dalvik.vm.dex2oat-flags
    
  4. To check whether DEX files contain .debug_* sections, you can use the GNU tools readelf command, for example:

    readelf -S .../images/*.dex
    

Source code annotations

To enable Streamline to provide extra context when profiling your executable, you can add annotations to your source code. Streamline supports two types of annotations:

  • User space annotations, for annotating your application

  • Kernel annotations, to profile system calls

You can read more information about annotating your code in the Annotate your code chapter of the Arm Streamline User Guide.