While I can debug my application with the Eclipse JDT debugger for Java code and GDB for C code, I would prefer to use a single tool for all my debugging. I found several projects that enable "mixed-mode" debugging in Eclipse and include support for single stepping between Java and native code.
Unfortunately, one claims to be pre-release quality and the other is currently unmaintained. Are there any plug-ins that bring mixed mode debugging functionality to Eclipse in a reliable way or should I continue to use two separate debuggers?
Put some breakpoints in your code: Put a breakpoint in the Java code before your C code starts (for example imeadiately after the System. loadLibrary call (you must ensure that this Run Configuration has its source tab including the C code you wish to debug) Put a breakpoint in the C code wherever you like.
JNI comes in handy. it converts all your platform specific implementations to platform independent. Performance- and platform-sensitive API implementations in the standard library allows all Java applications to access this functionality. the library files .
A Java program can be debugged simply by right clicking on the Java editor class file from Package explorer. Select Debug As → Java Application or use the shortcut Alt + Shift + D, J instead. Either actions mentioned above creates a new Debug Launch Configuration and uses it to start the Java application.
For those looking to debug NDK/JNI code in the Eclipse Juno release, it is essentially built into the software after installing the Android plugins and CDT plugins. You may have issues though since there is a problem that was introduced with the C/C++ Development tools (CDT 8.1) that as of 7/24/12 has not been fixed. For details on the issue see the following link. If you just want to debug, keep reading.
http://code.google.com/p/android/issues/detail?id=33788
If it is working correctly, you simply set your breakpoints in the C and Debug As -> Android Native Application. Unfortunately, you can not debug the java and C at the same time. If the problem is in the Java and you want to debug you do so by clicking Debug As -> Android Application.
If it is not working correctly, and you want to figure out how to get it correctly, the following packages worked for me.
Android DDMS 20.0.1.v201207132230-403220 Android Development Tools 20.0.1.v201207132230-403220 Android Hierarchy Viewer 20.0.1.v201207132230-403220 Android Native Development Tools 20.0.1.v201207132230-403220 Android Traceview 20.0.1.v201207132230-403220 Autotools support for CDT (Incubation) 3.0.1.201202152032 C/C++ Development Tools 8.0.2.201202111925 C/C++ Development Tools SDK 8.0.2.201202111925 C/C++ Library API Documentation Hover Help (Incubation) Eclipse SDK 4.2.0.I20120608-1400 Tracer for OpenGL ES 20.0.1.v201207132230-403220
The android packages came from setting Work With: option on the Eclipse Help->Install New Software... dialog to
dl-ssl.google.com/android/eclipse/
The older 8.02... CDT packages came from setting the Work With: option to the Indigo release packages.
download.eclipse.org/releases/indigo
If installed, you will need to remove the Android tools, and the new version of the CDT prior to installing the old version of the CDT. Once the 8.02... version of CDT is installed, you can install the Android tools and commence debugging.
Ensure you use the Build command "ndk-build NDK_DEBUG=1"
Autotools may not be required but since it is installed I have it listed.
Note that stepping through the code can be quirky sometimes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With