CGDB is a terminal-based lightweight interface to the
GNU debugger gdb
. It provides a split screen view, which displays the source code along with the debug information. This recipe discusses how to debug Android application with cgdb
.
The following instructions install cgdb
on different operating systems:
cgdb
:$ sudo apt-get install cgdb
Alternatively, you can download the source code from http://cgdb.github.com/, and perform the following instructions to install cgdb
:
$ ./configure --prefix=/usr/local $ make $ sudo make install
Note that cgdb
requires libreadline
and ncurses
development libraries.
$ sudo port install cgdb
Please read the Debugging Android NDK Application with NDK GDB recipe before going through this one.
The following steps enable cgdb
for Android NDK application debugging:
ndk-gdb
script under the Android NDK root
directory. This can be done with the following command:$ cp $ANDROID_NDK/ndk-gdb $ANDROID_NDK/ndk-cgdb
Here, $ANDROID_NDK
refers to the Android NDK root
directory.
ndk-cgdb
script from:GDBCLIENT=${TOOLCHAIN_PREFIX}gdb
To the following:
GDBCLIENT="cgdb -d ${TOOLCHAIN_PREFIX}gdb --"
HelloNDKGDB
project. Click on Finish to import the project:ndk-cgdb
The following is a screenshot of the cgdb
interface:
gdb
commands. Note that the upper-half of the window will mark the current execution line with an arrow and all the breakpoints with red.As shown in the preceding screenshot, cgdb
provides a more intuitive interface for debugging the native code in Android. We can view the source
code as we enter gdb
commands. This recipe demonstrates the basic setup of cgdb
for debugging the native code. The details of how to use cgdb
can be found at its documentation available at http://cgdb.github.com/docs/cgdb.html.