- Make sure your kernel is compiled with OProfile support (CONFIG_OPROFILE=y, CONFIG_HAVE_OPROFILE=y)
- If you want to profile the kernel, have the vmlinux binary ready
- If you want to profile a native application, compile it with debug symbols (-g)
- After system has loaded, execute once: “opcontrol –setup –event=CPU_CYCLES:50000″
If you also want to profile the kernel, add the params “–vmlinux=full-path-to-your-vmlinux-file-on-target –kernel-range=start-of-kernel-text-section,end-of-kernel-text-section” (use your toolchain’s objdump to find the relevant addresses) - Before beginning the profiling, execute on the target: “opcontrol –reset”
- To begin profiling, execute: “opcontrol –start”
- During profiling, you might want to make sure that samples are being collected: “opcontrol –status”
- Stop profiling by executing: “opcontrol –stop”
- On your host: cd mydroid/external/oprofile
- On your host, execute: “./opimport_pull result_folder” (imports the samples collected from the target, saves them in a newly created folder and prints a basic report)
- On your host, execute: “cd mydroid/prebuilt/linux-x86/oprofile/bin”
- To get an annotated report, execute: “./opannotate -p <path-to-folder-with-your-native-app-w-symbols-and-any-other-binary-you-want-detailed-report-of-like-libc-so-for-example>
-s -d <path-to-source-files-e.g.-mydroid> –session-dir=path-to-your-samples-dir”
- To get a simple report, execute: “./opreport -g -l -p <same-path-like-before> –session-dir=path-to-your-samples-dir”
Ohad Ben-Cohen – Linux Kernel Development
Free and Open Source Software