简体   繁体   中英

How can I debug native Android platform code?

I'm interested in learning about the Android runtime (ART) and I'd like to be able to put a debugger on it so I can step through the code. I have an AOSP build that I've been running on an emulator.

What's the best way to attach and run source? Should I just use gdbserver on the emulator? Are there any IDEs that people use for native debugging?

If you want to debug native code, you're going to need the source, which of course means getting the AOSP. After you've setup the AOSP, do the following:

  1. In your AOSP directory, run "choosecombo". Select "debug" and pick an "eng" build of your choice.
  2. Build the AOSP
  3. Start the emulator (ie: on Linux, "emulator &")
  4. adb shell into the emulator and run "setprop debug.db.uid 32767". This prevents debuggerd from attaching to a process that it thinks has halted and causing problems. See system/core/debuggerd/debuggerd.cpp in the AOSP for more info.
  5. In the same shell that you built the AOSP, run "gdbclient [process name]". This will attach and load the debugging information for the process you are interested in. You can also attach to a pid, but you will end up having to load the symbol information yourself.
  6. Enjoy debugging native Android platform code

看起来您已经明白了,但仅出于完整性考虑,以下是一些官方文档的链接,这些文档基本上涵盖了您所说的内容: http : //source.android.com/devices/tech/debug/index.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM