101
edits
| Line 200: | Line 200: | ||
* launch in debug mode: | * launch in debug mode: | ||
adb shell am start -a org.mozilla.gecko.DEBUG -n org.mozilla.fennec/org.mozilla.fennec.App | (Host)$ adb shell am start -a org.mozilla.gecko.DEBUG \ | ||
-n org.mozilla.fennec/org.mozilla.fennec.App | |||
* Forward a port for gdb between your device and computer using adb. Any port you can open should work. 1234 is used here. | * Forward a port for gdb between your device and computer using adb. Any port you can open should work. 1234 is used here. | ||
(Host)$ adb forward tcp:1234 tcp:1234 | |||
* Find the pid of your process if you don't know it. | * Find the pid of your process if you don't know it. You can look at the second column of <tt>adb shell ps|grep fennec</tt>. | ||
* Attach gdbserver to the process | * Attach gdbserver to the process | ||
(Host)$ adb shell /data/local/gdbserver localhost:1234 --attach YOURPID | |||
Attached; pid = YOURPID | |||
Listening on port 1234 | |||
* Run arm-eabi-gdb on your binary. (android-ndk-1.6_r1/build/prebuilt/linux-x86/arm-eabi-4.2.1/bin) For debugging gecko, a copy of app_process from your device should be used. | * Run arm-eabi-gdb on your binary. (android-ndk-1.6_r1/build/prebuilt/linux-x86/arm-eabi-4.2.1/bin) For debugging gecko, a copy of app_process from your device should be used. | ||
(Host)$ /PATH/TO/NDK/build/prebuilt/linux-x86/arm-eabi-4.2.1/bin/arm-eabi-gdb app_process | |||
GNU gdb 6.6 | |||
Copyright (C) 2006 Free Software Foundation, Inc. | |||
GDB is free software, covered by the GNU General Public License, and you are | |||
welcome to change it and/or distribute copies of it under certain conditions. | |||
Type "show copying" to see the conditions. | |||
There is absolutely no warranty for GDB. Type "show warranty" for details. | |||
This GDB was configured as "--host=x86_64-unknown-linux-gnu --target=arm-elf-linux"... | |||
* Configure solib-absolute-prefix. This will point to the directory where you unpacked your system image or where you copied the libraries. | * Configure solib-absolute-prefix. This will point to the directory where you unpacked your system image or where you copied the libraries. | ||
(Host gdb) set solib-absolute-prefix ANDROIDLIBS | |||
* Configure solib-search-path. This needs to point to the directories you need debugging symbols from - /system/lib or where ever you copied the libraries. | * Configure solib-search-path. This needs to point to the directories you need debugging symbols from - /system/lib or where ever you copied the libraries. | ||
(Host gdb) set solib-search-path ANDROIDLIBS:ANDROIDLIBS/system/lib:OBJDIR/dist/bin | |||
* Connect to gdbserver | * Connect to gdbserver | ||
(Host gdb) target remote localhost:1234 | |||
* These three Host gdb commands can be placed in a .gdbinit file to automate future gdb runs. .gdbinit should be located where you normally run gdb. | * These three Host gdb commands can be placed in a .gdbinit file to automate future gdb runs. .gdbinit should be located where you normally run gdb. | ||
You can use the script below to setup gdbserver | === Automating gdbserver setup === | ||
You can use the script below to setup gdbserver: | |||
<pre> | |||
#!/bin/bash | |||
PORT=1234 | |||
PID="" | |||
# By default, this will attach to the parent process. | |||
# Use "plugin-container" as argument to attach to child. | |||
if [ -z $1 ]; then | |||
GREP=org.mozilla.fennec | |||
else | |||
GREP=$1 | |||
fi | |||
adb forward tcp:$PORT tcp:$PORT && | |||
adb shell am start -a org.mozilla.fennec.DEBUG -n org.mozilla.fennec/org.mozilla.fennec.App && | |||
while [ -z $PID ]; do | |||
PID=`adb shell ps | grep $GREP | head -n 1 | cut -c11-16` | |||
done && | |||
adb shell run-as org.mozilla.fennec /data/local/gdbserver localhost:$PORT --attach $PID | |||
</pre> | |||
== Profiling == | == Profiling == | ||
edits