Tuesday, July 20, 2010

Android Build & Debugging with Emulator

This reference is based on Android 2.2 Froyo source tree.  with Emulator

Reference
http://source.android.com/porting/debugging_gdb.html
Document : ./build/core/build-system.html


  • Source Modification


The following settings are needed in Android.mk.
------------------------------------------------------------------------------------------------------------------
1)
LOCAL_CFLAGS := -O0 -g
LOCAL_CPPFLAGS := -O0 -g

2)
LOCAL_STRIP_MODULE := false
------------------------------------------------------------------------------------------------------------------

LOCAL_STRIP_MODULE inheritate  its value from TARGET_STRIP_MODULE. The variable TARGET_STRIP_MODULE is set as “TARGET_STRIP_MODULE := true” in the file “./build/core/combo/TARGET_linux-arm.mk”. So This setup makes LOCAL_STRIP_MODULE  true. If LOCAL_STRIP_MODULE := true, “strip” remove all symbols from binaries. This means the binaries lost also debug symbols.

  • Setup Emulator

The reference of official homepage (http://source.android.com/porting/debugging_gdb.html) is enough.

Additionally we can set emulator port setup by using  a different way from homepage’s way: “adb forward tcp: tcp:.
When your emulator launches, you can set
------------------------------------------------------------------------------------------------------------------
emulator -avd -qemu -redir [tcp|udp]::[guest_host]:
------------------------------------------------------------------------------------------------------------------

If you want to use your own-generated system.img
------------------------------------------------------------------------------------------------------------------
emulator -avd OpenGLTest -system system.img
------------------------------------------------------------------------------------------------------------------

Just type “emulator -help” for more detailed information.


  • Build partially

If you use ./build/envsetup.sh, you can use shell command “mm”. Command “mm” means “make current directory”.


  • Make clean partially(?)

No comments: