use gdb on Android to debug mediaserver

steps:

1: get mediaserver's PID

   adb shell ps | grep mediaserver or pid mediaserver (need to source build/env.sh first)


2 Login to Android target and start gdb server

 a: adb shell

 b: gdbserver :5039 --attach 1797

or on the host, run:

 adb shell gdbserver :5039 --attach `pid mediaserver`


3: forward host's port 5039 to target's port 5039

    adb forward tcp:5039 tcp:5039


4: run gdbclient 

   gdbclient ./mediaserver


Or here is a very sample way, on the host, just run on command as below:

gdbclient ./mediaserver :5039 mediaserver

Then gdbclient will help us start the gdbserver, forward the port and connect to the target, very sample.


Note: if your shared libraries are loaded dynamically, you need to set solib-search-path again after they are loaded.

Indeed, under your $OUT fold, you already have a gdbclient.cmds, which has set the path for you.

Just remove the last "remote target :5039" line and run "source gdbclient.cmds" is enough.


Then gdb client should connect to gdbserver, debugging is started!

Enjoy!



Note: if cannot break into, just put long sleep there and use gdbclient ./your_app:5039 your_app, the same as mediaserver.

你可能感兴趣的:(use gdb on Android to debug mediaserver)