Edit the questio开发者_高级运维n to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this questionI 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?
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.
Don't use emulator, it's a waste of your precious time. Get an android phone and the debugging will be as fast and easy as you love to.
It depends on your desktop situation, but the emulator can be improved by increasing the emulator RAM. It isn't great, but it will be improved.
To debug on your device, connect it to your computer with its USB cable. When you run the project through Eclipse, it will prompt for which device/emulator to run on, in which case you select your phone. You would then switch to the Debug perspective.
Sure.
It's easy as long as you have Eclipse IDE. You just have to run your program in debug and go to DDMS tab.
Some links that will help you:
http://www.droidnova.com/debugging-in-android-using-eclipse,541.html
http://developer.android.com/guide/developing/debugging/index.html
EDIT: I guess you will have to download and compile the Android sources for your purposes. This link will probably help you: http://source.android.com/source/initializing.html
精彩评论