Debugging a crahsed process in Android~~

Many times it has happened to me that the process is crashing and there is not a single clue from the ddms log to go ahead. Then the kernel debugging comes to the resort to thrash out the frustration.

Audio/Surface flingers, media server, service manager are the common place for such a nasty issue. dmesg and strace are really good tools to debug such an issue.

dmesg prints the message buffer of the kernel. It has the list of diagnostic messages about what’s going on in the kernel if the user process does something wrong or something happens to the device drivers. It also contains the exception and faults of the system.

I first run the dmesg and check the last timed message before executing the problematic process. This is just to make it easy to look at the right place after the process is crashed.

strace is an awesome tool to have a detailed information about what a process is doing in the execution. What are the files being accessed, the system calls, forked processes and so on.

I usually run the following command to trace the process from the adb shell
1. strace -ff -F -tt -s 200 -o /tmp/strace process-bin-path(/system/bin/mediaserver)
-ff > follow fork
-F > follow vfork
-tt > print time in micro seconds
-s > buffer size of printing the message
-o > file to generate the strace output
Last is bin process full path, or you can use -p with process id. -p option can be used for Java application. (Use ps command to show running processes)

Analyze the strace and dmesg output to solve an issue in a snap ^^

Advertisement

No comments yet

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.