- I just encountered a crash of Androids debuggerd on my pandaboard and wondered how to find the root cause of this issue. For the native parts of an app there is the ndk-gdb but what do we do in case of a non-app system component? Here is what I came up with.
- This howto assumes you have an Android build environment including the toolchain, Android sources and adb set up already.
Create a debugable version of the ELF binary
- Edit the makefile of the compoent to be debugged and add -g (and -O0 if you like):
vim system/core/debuggerd/Android.mk # insert something like this: LOCAL_CFLAGS += -g -O0Rebuild the binary
rm -r out/target/product/pandaboard/obj/EXECUTABLES/debuggerd_intermediates make TARGET_PRODUCT=pandaboard TARGET_TOOLS_PREFIX=/path/to/crosstoolchain/bin/arm-eabi- debuggerd showcommandsInstall the new binary on the device
adb remount adb shell mv /system/bin/debuggerd /system/bin/debuggerd_orig adb push out/target/product/pandaboard/symbols/system/bin/debuggerd /system/bin/debuggerdNow restart the process (or reboot the device) to get your binary executed
- Find the PID of the remote process you want to debug:
adb shell ps | grep debuggerdStart the gdbserver on the android device and attach to the process to be debugged:
adb shell /system/bin/gdbserver +debug-socket --attach <PID>Switch to another console on your development host and setup the ADB port forwarding:
adb forward tcp:5039 localfilesystem:debug-socketStart the GDB (client)
gdb-multiarch out/target/product/pandaboard/symbols/system/bin/debuggerdand connect to the gdbserver:
(gdb) target remote :5039Now you may set breakpoints, dump backtraces, inspect variables, and the like.
That's all - happy debugging!
Platform/Android/DebugAndroidSystemComponents (last modified 2013-08-29 07:29:44)