androidprofilingltrace

Profiling Android applications using ltrace


I need to profile dynamic library calls of android application and have decided to profile using "ltrace" tool for this purpose. I combined "ltrace" tool into android package, then compiled together successfully. It works fine with shell program just like usual linux console application.

However, I cannot properly profile android applications, which are forked from "Zygote" process. I tried attaching ltrace to "Zygote" process to follow child processes of it, but I only got SIGCHLD and SIGSTOP signals and terminated abnormally, showing the following errors.

unexpected instruction 0xffffffff at 0xffff0508

I'm just wondering if anyone has ever tried this kind of profiling on android system. Any short comments can be very helpful for me.

Thank you in advance.


Solution

  • Try attaching ltrace to your android application's process after it is it forked off zygote. You will need an ltrace built for android's bionic libc, and one that has reasonable handling of threads.

    There is a way to set a debuggable android app to wait for connection of the java debugger, you could use that, connect ltrace, and then connect and disconnect the java debugger to start it going again. This should capture most of your own logic, though not the entirety of the startup.

    IIRC you are under a time limit to connect and get it going again, otherwise it may resume on its own to avoid triggering an application not responding situation.

    It may be that you will learn more by using the java debugger to see what is going on, and then reading the source to see how that is implemented on the native side.