Mobile/Fennec/Android/GDB: Difference between revisions
No edit summary |
|||
Line 139: | Line 139: | ||
git clone git://github.com/darchons/android-gdbutils.git moz-gdb/utils | git clone git://github.com/darchons/android-gdbutils.git moz-gdb/utils | ||
Now edit this file: | |||
moz-gdb/utils/gdbinit | |||
and uncomment (remove the #'s) and set the following variables: | |||
python feninit.default.objdir # set it to your fennec object directory | |||
python feninit.default.srcroot # set it to your source directory | |||
==== Linux ==== | ==== Linux ==== | ||
Make sure your paths are absolute! The gdbinit file, even though it specifies relative paths by default, will not correctly load debug symbols unless you specify absolute paths. | Make sure your paths are absolute! The gdbinit file, even though it specifies relative paths by default, will not correctly load debug symbols unless you specify absolute paths. | ||
Line 164: | Line 170: | ||
</table> | </table> | ||
Running | === Running JimDB === | ||
Once JimDB is properly set up, with a moz-gdb directory as described above, running Fennec in GDB is very easy: | |||
./moz-gdb/bin/gdb | |||
This will automatically start gdbserver and fennec on the device, and start gdb on your computer. |
Revision as of 18:50, 30 March 2012
Note: the names JimDB and moz-gdb seem to be used interchangeably, meaning the same thing.
Using JimDB (Or, Android GDB with Niceness)
Prebuilt binaries
Linux
Download page
Run 'git pull' inside the utils directory to get the latest GDB utilities.
GDB utilities
A set of tools to make Fennec development on Android easier.
Source and documentation.
Building moz-gdb
There are two things to build here: the gdb you'll run on your computer, and the gdbserver you'll install on the device. JimDB's gdb takes care of automatically running /data/local/gdbserver on the device, once it's correctly installed.
Building gdb
Linux
Get required packages:
sudo apt-get install bison flex libncurses5-dev texinfo python2.7-dev
Get source:
git clone git://github.com/darchons/android-gdb.git cd android-gdb git checkout android-gdb_7_3
Run configure and make:
mkdir android-gdb-objdir cd android-gdb-objdir export prefix=/nonexistent /path/to/android-gdb/configure --target=arm-elf-linux --with-python=yes --prefix=$prefix \ --with-gdb-datadir=$prefix/utils --with-system-gdbinit=$prefix/utils/gdbinit make -j4
Reminder: Don't use ~ in the paths you pass here, as Bash wouldn't evaluate it!
The gdb binary will be located at android-gdb-objdir/gdb/gdb
Mac OS X
NOTE (BenWa): It failed to built with clang on 2012/01/09
Get required packages:
port install bison flex ncurses texinfo python27
Get source:
git clone git://github.com/darchons/android-gdb.git cd android-gdb git checkout android-gdb_7_3
Run configure and make:
mkdir android-gdb-objdir cd android-gdb-objdir export prefix=/nonexistent /path/to/android-gdb/configure --target=arm-elf-linux --enable-targets=all --with-python=yes --prefix=$prefix \ --with-gdb-datadir=$prefix/utils --with-system-gdbinit=$prefix/utils/gdbinit make -j4
Reminder: Don't use ~ in the paths you pass here, as Bash wouldn't evaluate it!
The gdb binary will be located at android-gdb-objdir/gdb/gdb
Building gdbserver
Linux
Create an NDK toolchain:
cd /PATH/TO/NDK ./build/tools/make-standalone-toolchain.sh
This will tell you that the toolchain was packaged somewhere like /tmp/ndk-username/arm-linux-androideabi-4.4.3.tar.bz2
Extract that toolchain somewhere:
mkdir ~/android-toolchain cd ~/android-toolchain tar -xvf /tmp/ndk-username/arm-linux-androideabi-4.4.3.tar.bz2
Make sure NDK toolchain is in PATH:
export PATH=~/android-toolchain/arm-linux-androideabi-4.4.3/bin:$PATH
Run configure and make for gdbserver:
mkdir android-gdbserver-objdir cd android-gdbserver-objdir /path/to/android-gdb/gdb/gdbserver/configure --host=arm-linux-androideabi \ --with-sysroot=/PATH/TO/NDK/platforms/android-9/arch-arm make -j4
The gdbserver binary will be located at android-gdbserver-objdir/gdbserver.
Reminder: Don't use ~ in the paths you pass here, as Bash wouldn't evaluate it!
Install it on your device:
adb push gdbserver /data/local
Mac OS X
Setup a toolchain environment for your build:
/PATH/TO/NDK/build/tools/make-standalone-toolchain.sh --install-dir=android-9-toolchain --platform=android-9
Run configure and make for gdbserver:
mkdir android-gdbserver-objdir cd android-gdbserver-objdir export PATH=android-9-toolchain/bin:$PATH ../android-gdb/gdb/gdbserver/configure --host=arm-linux-androideabi make -j4
The gdbserver binary will be located at android-gdbserver-objdir/gdbserver.
Install it on your device:
adb push gdbserver /data/local
Set up the moz-gdb directory
Once you've built JimDB, you need to create and populate a moz-gdb directory as explained below.
Indeed, GDB utilities assume the following moz-gdb directory structure:
./bin/ gdb gdbserver ./utils/ gdbinit python/
Execute the following commands to create and set up the moz-gdb directory:
mkdir -p moz-gdb/bin cp android-gdb-objdir/gdb/gdb moz-gdb/bin cp android-gdbserver-objdir/gdbserver moz-gdb/bin git clone git://github.com/darchons/android-gdbutils.git moz-gdb/utils
Now edit this file:
moz-gdb/utils/gdbinit
and uncomment (remove the #'s) and set the following variables:
python feninit.default.objdir # set it to your fennec object directory python feninit.default.srcroot # set it to your source directory
Linux
Make sure your paths are absolute! The gdbinit file, even though it specifies relative paths by default, will not correctly load debug symbols unless you specify absolute paths.
INCORRECT | CORRECT |
---|---|
|
|
Running JimDB
Once JimDB is properly set up, with a moz-gdb directory as described above, running Fennec in GDB is very easy:
./moz-gdb/bin/gdb
This will automatically start gdbserver and fennec on the device, and start gdb on your computer.