I would like to be able to place breakpoints, and see the call stack, step through code, for when I am building and running the open-source Android OS. I would also potentially like to debug within the Dalvik VM. The OS is built using make, so I figure I need to use gdb. I was only able to find out of date instructions on how to do this. Has anyone managed to debug within the Android OS, or found upto date instructions on this?
Share
If you are running as root (normal case in the emulator, possible on dev phones or via security holes on may consumer ones), you can attach gdb (actually, gdbserver) to almost any already running userspace process. Be aware many things may react poorly to being paused for any useful length of time.
If you aren’t running as root you can only debug processes running as a user that you can convince to run gdbserver – ie, those you launch with adb, or by using the run-as tool application processes of apps that were built with the debug flag set and have Internet permission (for gdb-gdbserver communication).
If you want to debug the kernel you would need to either figure out how to get kgdb working, or more likely just load up with printk’s in interesting places. This of course requires the ability to rebuild and reinstall the kernel.