(Note: there's now an ndk-debug.sh script in stellarium/android/util
which handles most of this; I'll have to remember to rewrite this section)
If you need to debug as soon as the native code starts, import the project into Eclipse as described below, and set a breakpoint right before the necessitas code starts up the native side of the app. This line in QtActivity.java
should do the trick:
QtApplication.setQtActivityDelegate(qtLoader);
With the device attached to adb (test with adb devices
):
Find the process ID for Stellarium:
adb shell ps | grep stellarium
Then attach gdbserver to it:
adb shell gdbserver :5039 --attach pid
Have ADB forward that port from the device:
adb forward tcp:5039 tcp:5039
Pull the app process off the device; this process starts and runs Android apps, so it's the process you're going to be debugging. gdb needs this.
Windows Note: MinGW will interpret the paths in the pull
commands below as Windows paths and passes them to adb accordingly (/system/bin/app_process
becomes C:\system\bin\app_process
). They're supposed to be paths on the Android device though, not your system. Either use cmd
, or type the paths as//system/bin/app_process
adb pull /system/bin/app_process
Pull libc.so as well, and maybe any Qt libs you want:
adb pull /system/lib/libc.so adb pull /data/data/org.kde.necessitas.ministro/files/qt/lib/libQtCore.so ...
Open gdb, which should reside somewhere in the android ndk directory (in Windows, it's under necessitas/android-ndk-r6b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/windows/bin
)
Tell gdb where your source is:
directory path/to/source
Give gdb the executable that it's going to be debugging, the app_process binary you downloaded from the device:
file path/to/app_process
And give it the locations of libstellarium.so, libc.so, and any other libraries so it can find them (you can run the command multiple times, it will add each directory to the search path):
set solib-search-path /path/to/lib/directory
Instructions on using gdb are beyond the scope of this document. You're on your own.
Now you should be able to resume in Eclipse and in gdb, and debug as usual.
It should be possible to hook gdb into Eclipse or QtCreator to allow GUI debugging. May want to investigate that at some point. It'll probably be handy to have a script do most of the setup for this use.
http://www.stellarium.org/wiki/index.php/Building_for_Android