Mobile/Fennec/Android/GDB: Difference between revisions
Jump to navigation
Jump to search
(Delete the instructions to 'gdb push gdbserver', since the section "Create the moz-gdb directory" is required, and the python scripts will take care of the copying of gdbserver from the moz-gdb dir) |
No edit summary |
||
Line 1: | Line 1: | ||
JimDB is a fork of GDB used for simplifying Fennec development. It consists of two parts: | |||
* Binaries - the GDB/GDBServer binaries that include Android-specific patches (https://github.com/darchons/android-gdb) | |||
* Scripts - the Python scripts that run under GDB to simplify common tasks (https://github.com/darchons/android-gdbutils) | |||
Use #mobile on IRC for support. | |||
= | = Getting started = | ||
== | == Using pre-built binaries == | ||
=== Instructions === | |||
Run 'git pull' inside the utils directory to get the latest | # Download the latest pre-built binaries for your platform from [http://people.mozilla.org/~nchen/jimdb this directory] | ||
# Extract to a user-writable directory | |||
# Run 'git pull' from inside the utils/ directory to get the latest scripts | |||
# 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 | |||
There are two things to build here: | |||
==== Linux ==== | ==== Linux ==== | ||
===== GDB ===== | |||
# Get a zip of the source from [https://github.com/darchons/android-gdb the GitHub repo] (Get the zip because cloning takes a lot longer) | |||
# Extract the zip | |||
# You may need to install additional packages in order to build GDB. For example,<pre>sudo apt-get build-dep gdb</pre> | |||
# Run configure inside the source directory<pre>./configure --target=arm-elf-linux-android --with-python=yes --prefix=/nonexistent \ --with-gdb-datadir=/nonexistent/utils --with-system-gdbinit=/nonexistent/utils/gdbinit</pre> | |||
# Run make <pre>make -j8</pre> | |||
# 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, | |||
# Use the source directory from above | |||
# Make sure you have a copy of the Android NDK | |||
# Run configure inside the ''gdb/gdbserver directory'' (following is for NDK r8d)<pre>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</pre> | |||
# Run make <pre>make -j8</pre> | |||
# The compiled binary will be at gdbserver | |||
==== Mac ==== | |||
==== | ===== GDB ===== | ||
# Get a zip of the source from [https://github.com/darchons/android-gdb the GitHub repo] (Get the zip because cloning takes a lot longer) | |||
# Extract the zip | |||
# You may need to install additional packages in order to build GDB. For example,<pre>port install bison flex ncurses texinfo python27</pre> | |||
# Run configure inside the source directory<pre>./configure --target=arm-elf-linux-android --with-python=yes --prefix=/nonexistent \ --with-gdb-datadir=/nonexistent/utils --with-system-gdbinit=/nonexistent/utils/gdbinit</pre> | |||
# Run make <pre>make -j8</pre> | |||
# 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, | |||
# Use the source directory from above | |||
# Make sure you have a copy of the Android NDK | |||
# Run configure inside the ''gdb/gdbserver directory'' (following is for NDK r8d)<pre>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</pre> | |||
# Run make <pre>make -j8</pre> | |||
# 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/ | ./bin/ | ||
Line 137: | Line 82: | ||
python/ | python/ | ||
Therefore, you'd need to, | |||
# Make a JimDB directory | |||
# Copy gdb and gdbserver from steps above to bin/ | |||
# Clone the Python scripts to utils/ | |||
# Run bin/gdb | |||
Make | |||
Run | |||
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 |
Revision as of 19:04, 20 March 2013
JimDB is a fork of GDB used for simplifying Fennec development. It consists of two parts:
- Binaries - the GDB/GDBServer binaries that include Android-specific patches (https://github.com/darchons/android-gdb)
- Scripts - the Python scripts that run under GDB to simplify common tasks (https://github.com/darchons/android-gdbutils)
Use #mobile on IRC for support.
Getting started
Using pre-built binaries
Instructions
- Download the latest pre-built binaries for your platform from this directory
- Extract to a user-writable directory
- Run 'git pull' from inside the utils/ directory to get the latest scripts
- 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
- Get a zip of the source from the GitHub repo (Get the zip because cloning takes a lot longer)
- Extract the zip
- You may need to install additional packages in order to build GDB. For example,
sudo apt-get build-dep gdb
- 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
- Run make
make -j8
- 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,
- Use the source directory from above
- Make sure you have a copy of the Android NDK
- 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
- Run make
make -j8
- The compiled binary will be at gdbserver
Mac
GDB
- Get a zip of the source from the GitHub repo (Get the zip because cloning takes a lot longer)
- Extract the zip
- You may need to install additional packages in order to build GDB. For example,
port install bison flex ncurses texinfo python27
- 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
- Run make
make -j8
- 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,
- Use the source directory from above
- Make sure you have a copy of the Android NDK
- 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
- Run make
make -j8
- 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,
- Make a JimDB directory
- Copy gdb and gdbserver from steps above to bin/
- Clone the Python scripts to utils/
- 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
- 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