Port oprofile to Android

Source: Internet
Author: User
Tags image filter
Port oprofile to Android
Port oprofileandroid simulator oprofile

Tool compilation reference
Http://blog.csdn.net/louieuser/article/details/6152175

Tool usage:
1. Create an AVD. when starting the simulator, use the compiled kernel to replace the built-in kernel of the SDK.
C: \ Users \ maricoliu> emulator @ android2.3-partition-size 300-kernel ~ \ Kernel-qemu

Note: To push our program to the system, allocate enough size. Otherwise, the no space left on device error will occur. Use-partition-size to specify the size.

2. Install busybox and oprofile
Load the compiled busybox and oprofile into the simulator.
Go to the ADB shell and create two folders.
# Mkdir/data/busybox
# Mkdir/data/oprofile
Run the following command on the console:
C: \ Users \ maricoliu> ADB push ~ \ Busybox/data/busybox/
The oprofile tool can load files starting with OP to the simulator:
C: \ Users \ maricoliu> ADB push ~ \ Oprofile \ opcontrol/data/oprofile/
C: \ Users \ maricoliu> ADB push ~ \ Oprofile \ opannotate/data/oprofile/
...... (The rest will not be listed)
Go back to shell, install busybox, and add the oprofile File Execution permission.
# Cd/data/busybox
# Chmod 777 busybox
#./Busybox-install busybox
# Cd/data/oprofile
# Chmod 777 op *

3. Run oprofile
# Export Path = $ path:/data/busybox
# Export Path = $ path:/data/oprofile
# Mount-O remount RW/
# Mount-o rw, remount-T yaffs2/dev/mtdblock3/System
# Ln-S/proc/mounts/etc/mtab (create a soft connection, which will be explained later)
# Opcontrol -- init // initialization, only once
# Opcontrol -- setup -- callgraph = 2 -- session-Dir =/result/-- no-vmlinux
# Opcontrol -- start
Opcontrol -- start
Using 2.6 + oprofile kernel interface.
Using Log File/result/samples/oprofiled. Log
Daemon started.
Profiler running.
# Opcontrol -- Status
Opcontrol -- Status
Daemon Running: PID 773.
Separate options: None
Vmlinux file: None
Image Filter: None
Call-graph depth: 2

Run your program

# Opcontrol -- dump // collect sample data
# Opcontrol -- stop // stop profiler
Stopping profiling.
# Opreport -- session-Dir =/result // view the report

Problems:
1. Error:

Test: not found
ID: not found
Test: not found
Grep: not found
Test: not found
Grep: not found
Test: not found
............

This is because the commands provided by Android are too simple, so we need to port busybox to run opcontrol. After installing busybox according to the above steps, this error may occur. After Google learns that the opcontrol file to be modified is as follows:

Bindir = "/data/busybox"
Add/data/busybox to path
After viewing the opcontrol source code,/data/busybox is not added.
2. An error occurs.
./Opcontrol -- init
Grep:/etc/mtab: no such file or directory
Grep:/etc/mtab: no such file or directory
Kernel support not available, missing opcontrol -- init as root

# Touch/etc/mtab
#./Opcontrol -- init
Kernel support not available, missing opcontrol -- init as root?

Through the analysis of opcontrol, it is found that the return value of executing "grep oprofile/proc/modules>/dev/null" is the judgment condition and the operation is still performed, because there is no oprofile information in the mtab file, therefore, you need to execute "Mount-T oprofilefs nodev/dev/oprofile>/dev/null". After the Linux standard file system executes this command, it will write the relevant mount information/ ETC/mtab, after umount is executed, the relevant information will be deleted from the/etc/mtab file.
The mtab file has not changed. After Google, we know that the new busybox uses/proc/mounts to replace/etc/mtab, therefore, you can bypass this problem by creating a link named/proc/mounts mtab under/etc.

# Ln-S/proc/mounts/etc/mtab
The link failed file exists error may occur. Make sure that the mtab file does not exist in the/etc/directory. If yes, the delete tool is in your own csdn upload resource.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.