Mobile/Fennec/Android: Difference between revisions

Jump to navigation Jump to search
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
  (Host)$ adb forward tcp:1234 tcp:1234
* Find the pid of your process if you don't know it. Every message in adb logcat specifies the PID of the process that produced the message, so gecko's PID can be found there, or you can look at the second column of <tt>adb shell ps|grep fennec</tt>.
* 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
** (Device) <tt>gdbserver localhost:1234 --attach 6036</tt>
  (Host)$ adb shell /data/local/gdbserver localhost:1234 --attach YOURPID
** Use <tt>/data/local/gdbserver</tt> if gdbserver is not in your PATH.
  Attached; pid = YOURPID
Attached; pid = 6036
  Listening on port 1234
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) ~/android-ndk-1.6_r1/build/prebuilt/linux-x86/arm-eabi-4.2.1/bin/arm-eabi-gdb app_process
  (Host)$ /PATH/TO/NDK/build/prebuilt/linux-x86/arm-eabi-4.2.1/bin/arm-eabi-gdb app_process
GNU gdb 6.6
  GNU gdb 6.6
Copyright (C) 2006 Free Software Foundation, Inc.
  Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
  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.
  welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
  Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
  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"...
  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 /home/user/android/sysimg
  (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 /home/user/android/sysimg/system/lib:/home/user/android/moz-build/dist/bin
  (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
  (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 with a single command:
=== Automating gdbserver setup ===
You can use the script below to setup gdbserver:


#!/bin/sh
<pre>
PORT=1234
#!/bin/bash
adb forward tcp:$PORT tcp:$PORT &&
PORT=1234
adb shell am start -a org.mozilla.gecko.DEBUG -n org.mozilla.fennec/org.mozilla.fennec.App &&
PID=""
PID=`adb shell ps|grep org.mozilla.fennec|cut -c11-16` && sleep 3 &&
 
adb shell /data/local/gdbserver localhost:$PORT --attach $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 ==
101

edits

Navigation menu