Reputation: 7448
I am building a native Android application (a game) and would like to know which tools to use in order to debug native apps.
Would be useful to have Xcode debug features, such as breakpoints, guard malloc, zombies etc.
Upvotes: 0
Views: 484
Reputation: 5499
The easiest way I have found to do native debugging is to use Eclipse with the CDT plugin. Once you have added a "C/C++ aspect" to your Android project in Eclipse, it allows you to easily set breakpoints and to step in native code.
To set up the development environment: If you have the standard Eclipse + Android SDK bundle and you have separately downloaded the NDK, you need to add the CDT plugin and the Android NDK plugin for Eclipse. See instructions here: http://tools.android.com/recent/usingthendkplugin. Once you're done, your Eclipse installation will looks something like this:
You'll now want to go into Eclipse Preferences/Settings and set the path to your NDK installation:
To work with Eclipse in C/C++ perspective, first you need to add the C/C++ aspect to any project that hasn't yet got it. Do this by right-clicking the project, and from the "Android tools" submenu, choose item "Add Native support...":
From there, you'll be able to view a Android project which includes native code in the C/++ perspective, including setting breakpoints in native code and launching a native debugging session:
Using Eclipse for native debugging helps avoid a whole world of pain encountered with other command-line methods.
As far as command-line tools go, if you're going to do command-line gdb on a device, I would recommend use of the 'ddd' tool as a front-end for gdb. See http://www.gnu.org/software/ddd/. On OS X, ddd is available as a package in the Fink package manager.
Upvotes: 3