Mobile/Fennec/Android/GDB: Difference between revisions

From MozillaWiki
< Mobile‎ | Fennec‎ | Android
Jump to navigation Jump to search
No edit summary
mNo edit summary
Line 99: Line 99:
== FAQ ==
== FAQ ==


=== What is moz-gdb?
=== What is moz-gdb? ===
* moz-gdb was a synonym for JimDB, but it's no longer used, to avoid confusion
* moz-gdb was a synonym for JimDB, but it's no longer used, to avoid confusion



Revision as of 19:21, 20 March 2013

JimDB is a fork of GDB used for simplifying Fennec development. It consists of two parts:

Use #mobile on IRC for support.

Getting started

Using pre-built binaries

Instructions

  1. Download the latest pre-built binaries for your platform from this directory
  2. Extract to a user-writable directory
  3. Run 'git pull' from inside the utils/ directory to get the latest scripts
  4. Launch bin/gdb to start using JimDB!

Example

For Linux,

cd $HOME
wget http://people.mozilla.org/~nchen/jimdb/jimdb-linux-x64.tar.bz2 # step 1
tar -xf jimdb-linux-x64.tar.bz2 # step 2
cd jimdb/utils # step 3
git pull
../bin/gdb # step 4

Custom-building

Step 1. Compiling the binaries

There are two things to build here: gdb and gdbserver

Linux

GDB
  1. Get a zip of the source from the GitHub repo (Get the zip because cloning takes a lot longer)
  2. Extract the zip
  3. You may need to install additional packages in order to build GDB. For example,
    sudo apt-get build-dep gdb
  4. Run configure inside the source directory
    ./configure --target=arm-elf-linux-android --with-python=yes --prefix=/nonexistent \
      --with-gdb-datadir=/nonexistent/utils --with-system-gdbinit=/nonexistent/utils/gdbinit
  5. Run make
    make -j8
  6. The compiled binary will be at gdb/gdb
GDBServer

Consider using the pre-built gdbserver binary from the "Using pre-built binaries" section above; gdbserver is not specific to your platform. Otherwise,

  1. Use the source directory from above
  2. Make sure you have a copy of the Android NDK
  3. Run configure inside the gdb/gdbserver directory (following is for NDK r8d)
    export NDK=/PATH/TO/NDK
    export PATH=$PATH:$NDK/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin
    ./configure --host=arm-linux-androideabi --with-sysroot=$NDK/platforms/android-9/arch-arm
  4. Run make
    make -j8
  5. The compiled binary will be at gdbserver

Mac

GDB
  1. Get a zip of the source from the GitHub repo (Get the zip because cloning takes a lot longer)
  2. Extract the zip
  3. You may need to install additional packages in order to build GDB. For example,
    port install bison flex ncurses texinfo python27
  4. Run configure inside the source directory
    ./configure --target=arm-elf-linux-android --with-python=yes --prefix=/nonexistent \
      --with-gdb-datadir=/nonexistent/utils --with-system-gdbinit=/nonexistent/utils/gdbinit
  5. Run make
    make -j8
  6. The compiled binary will be at gdb/gdb
GDBServer

Consider using the pre-built gdbserver binary from the "Using pre-built binaries" section above; gdbserver is not specific to your platform. Otherwise,

  1. Use the source directory from above
  2. Make sure you have a copy of the Android NDK
  3. Run configure inside the gdb/gdbserver directory (following is for NDK r8d)
    export NDK=/PATH/TO/NDK
    export PATH=$PATH:$NDK/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin
    ./configure --host=arm-linux-androideabi --with-sysroot=$NDK/platforms/android-9/arch-arm
  4. Run make
    make -j8
  5. The compiled binary will be at gdb/gdbserver/gdbserver

Step 2. Creating JimDB directory

To get the most out of JimDB, in addition to the binaries, you need the Python scripts. But first, the scripts assume you have the following JimDB directory structure,

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

Therefore, you'd need to,

  1. Make a JimDB directory
  2. Copy gdb and gdbserver from steps above to bin/
  3. Clone the Python scripts to utils/
  4. Run bin/gdb

For example,

mkdir -p jimdb/bin # step 1
cp /PATH/TO/SOURCE/gdb/gdb jimdb/bin # step 2
cp /PATH/TO/SOURCE/gdb/gdbserver/gdbserver jimdb/bin
git clone git://github.com/darchons/android-gdbutils.git jimdb/utils # step 3
jimdb/bin/gdb # step 4

Using JimDB

FAQ

What is moz-gdb?

  • moz-gdb was a synonym for JimDB, but it's no longer used, to avoid confusion

"configure: error: failure running python-config" when compiling GDB

  • python may point to python3 on your machine. You need to specify where python2 is by using, for example, --with-python=python2 in your configure line

"error while loading shared libraries: libtinfo.so.5" on Linux

  • You may need to create a libtinfo.so.5 symlink to libncurses.so.5. For example,
sudo ln -s libncurses.so.5 /usr/lib/libtinfo.so.5

"cannot locate symbol "__exidx_end"" when starting to debug

  • If you're using pre-built binaries, you need to update to a newer version of JimDB
  • If you're using custom-built binaries, you need to recompile gdbserver using a newer version of the NDK

GDB crashed and Fennec is stuck. Halp!!

  • GDBServer may still be attached to Fennec but is unable to communicate with GDB; try killing GDBServer
adb shell run-as org.mozilla.fennec_$USER kill `adb shell ps | grep gdb | awk '{print $2}'`

JimDB sucks! Halp!!

  • Come on #mobile on IRC
  • Or file a bug under Firefox for Android, JimDB component

JimDB is awesome now!! Can I buy you a $beverage?

  • Yes