I made the following tut (based on an another tut) for myself. I have got it working on Ubuntu (didn;t try it on windows)
Source:http://groups.google.com/group/android-ndk/web/debugging-through-the-jni-with-android-2-2 (it is almost the same, but extended with the "Sequoyah solution" )
-The target platform must be Android 2.2 (android-8, aka Froyo)
-The ndk version must be r4b (it contains bugfixes to ndk-gdb that are necessary)
-Eclipse CDT 7.0 or newer must be installed.
-The AndroidManifest.xml must have the property of the application node android:debuggable=“true”
-The build must have been done with the ndk-build
-Sequoyah Android Native Support is installed in Eclipse using the following link: http://download.eclipse.org/sequoyah/updates/1.1/
Transform the project to a C++ project using Sequoyah:
-Choose Android Tools > Add Native Support and follow the wizard
Create a debug configuration for an Android application
Create a debug configuration for a C/C++ application, set the following properties:
-The process launcher must be the Standard Process Launcher. This is selected at the bottom of the Main
- -On the Main tab:
- - -the Field C/C++ Application: $PROJECT_PATH/obj/local/armeabi/app_process
- -on the Debugger:
- - -Field Debugger: gdbserver
- - -Subtab Main:
- - - -GDB debugger: $NDK_PATH/build/prebuilt/$ARCH/arm-eabi-$GCC_VERSION/bin/arm-eabi-gdb
- - - -GDB command file: $PROJECT_PATH/obj/local/armeabi/gdb2.setup
- - - -Subtab Connection:
- - - - -Type: TCP
- - - - -Hostname or IP address: localhost
- - - - -Port number: 5039
-Open the ndk-gdb script that came with the android NDK and comment the last line (we are not calling the usual gdb client, but we will attach an Eclipse gdb session instead)# $GDBCLIENT -x $GDBSETUP -e $APP_PROCESS
-Insert a breakpoint in your Java code , preferably after all System.loadLibrary() calls. (to make sure that the debugger is correctly attached to the Java process)
-Launch the android debug and wait it to reach the breakpoint
-From a Terminal session, in the project folder, run the modified ndk-gdb command. It should not attach to an gdb client, but call the gdbserver on the emulator and open a TCP port for connection.
-In the $PROJECT_PATH/obj/local/armeabi/, modify the gdb.setup file, removing the target remote :5039 statement. (for some reason, the Eclipse GDB session does not like this statement being done in the commands file). Rename this new file to gdb2.setup. This step need to be run just once, on the first debug session. (I am working on further tweaking the ndk-gdb script to generate the gdb.setup file without the target statement, but for the time being, this workaround will work)
-Launch the C/C++ Application debug and wait for the Eclipse GDB session to fully connect to the emulator's gdbserver instance.
After following these steps, one can continue to debug the application as usual, using the “continue” option to let the execution flow until the next breakpoint is hit or by using the usual “step-in” to execute each statement individually. Setting a breakpoint on a Java statement that calls a native function through JNI and stepping into will place the user at the beginning of the native code.