Mobile/Fennec/Android/GDB: Difference between revisions

From MozillaWiki
< Mobile‎ | Fennec‎ | Android
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
= Using JimDB (Or, Android GDB with Niceness) =
== Prebuilt binaries ==
== Prebuilt binaries ==


Line 108: Line 109:
  cp android-gdbserver-objdir/gdbserver moz-gdb/bin
  cp android-gdbserver-objdir/gdbserver moz-gdb/bin
  git clone git://github.com/darchons/android-gdbutils.git moz-gdb/utils
  git clone git://github.com/darchons/android-gdbutils.git moz-gdb/utils
== Running ==
=== Setup gdbinit file ===
==== 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.
<table style="border: 1px solid black;">
<tr>
<th style="background: rgb(250,35,35); color: black; font-weight: bold;">INCORRECT</th>
<th style="background: rgb(35,250,35); color: black; font-weight: bold;">CORRECT</th>
</tr>
<tr>
<td>
<code>
python feninit.default.objdir = '~/Source/mozilla-android/obj-android'
python feninit.default.srcroot = '~/Source/mozilla-central/mozilla'
</code>
</td>
<td>
<code>
python feninit.default.objdir = '/home/USERNAME/Source/mozilla-android/obj-android'
python feninit.default.srcroot = '/home/USERNAME/Source/mozilla-central/mozilla'
</code>
</td>
</tr>
</table>
Running GDB with this requires that you enter into the bin directory, and run ./gdb, once your gdbinit file is setup.

Revision as of 17:42, 14 December 2011

Using JimDB (Or, Android GDB with Niceness)

Prebuilt binaries

Linux

moz-gdb.tar.bz2

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

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

Run configure and make:

mkdir android-gdb-objdir
cd android-gdb-objdir
export prefix=/nonexistent
../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

The gdb binary will be located at android-gdb-objdir/gdb/gdb

Mac OS X

Get required packages:

port install bison flex ncurses texinfo python27

Get source:

git clone git://github.com/darchons/android-gdb.git

Run configure and make:

mkdir android-gdb-objdir
cd android-gdb-objdir
export prefix=/nonexistent
../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

The gdb binary will be located at android-gdb-objdir/gdb/gdb

Building gdbserver

Linux

Make sure NDK toolchain is in PATH:

export PATH=$PATH:/PATH/TO/NDK/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin

Run configure and make for gdbserver:

mkdir android-gdbserver-objdir
cd android-gdbserver-objdir
../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.

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 --arch=arm --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 moz-gdb directory

GDB utilities assume the following moz-gdb directory structure:

./bin/
    gdb
    gdbserver
./utils/
    gdbinit
    python/

The following commands will set up the directories and pull in GDB utilities:

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

Running

Setup gdbinit file

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

python feninit.default.objdir = '~/Source/mozilla-android/obj-android' python feninit.default.srcroot = '~/Source/mozilla-central/mozilla'

python feninit.default.objdir = '/home/USERNAME/Source/mozilla-android/obj-android' python feninit.default.srcroot = '/home/USERNAME/Source/mozilla-central/mozilla'

Running GDB with this requires that you enter into the bin directory, and run ./gdb, once your gdbinit file is setup.