Android: Difference between revisions

288 bytes added ,  16 December 2009
Make setting up gdb debugging easier
(Add Debugging with gdb)
(Make setting up gdb debugging easier)
Line 175: Line 175:
== Debugging with gdb ==
== Debugging with gdb ==


Make sure you have the system image of your device unpacked somewhere. (eg. signed-dream_devphone_userdebug-ota-14721.zip) This is only necessary for various libraries and the linker.
The images included with the SDK for emulation are [http://www.yaffs.net/ yaffs2] images and require some work to mount and extract files from. An alternative is to just copy the necessary files from your device via adb pull. /system/bin/linker is referred to by absolute path so setting solib-absolute-prefix in gdb will be necessary for it to be found. Other files can be placed anywhere as long as they can be found in solib-search-path.


The images included with the SDK for emulation are [http://www.yaffs.net/ yaffs2] images and require some work to extract files from. An alternative here is to just copy the necessary files via adb pull. /system/bin/linker is referred to by absolute path so setting solib-absolute-prefix in gdb will be necessary for it to be found. Any other files can be placed anywhere as long as they can be found in the solib-search-path.
In short, find a directory to put some libraries, make sure adb is in your path, and paste this into your terminal:
adb pull /system/bin/linker . &&
mkdir -p system/bin &&
mv linker system/bin &&
for LIB in libc.so libm.so libstdc++.so liblog.so libz.so libGLESv1_CM.so
do
adb pull /system/lib/$LIB .
done
 
Alternately, unpack the system image of your device somewhere. (eg. signed-dream_devphone_userdebug-ota-14721.zip)


* 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.
Line 198: Line 207:
  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 placed system/bin/linker)
* 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 /home/user/android/sysimg
* Configure solib-search-path. This needs to point to the directories you need debugging symbols from, like /system/lib.
* 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 /home/user/android/sysimg/system/lib:/home/user/android/moz-build/dist/bin
* Connect to gdbserver
* Connect to gdbserver
134

edits