134
edits
(→Running: LD_LIBRARY_PATH should be set to something) |
(Add Debugging with gdb) |
||
Line 172: | Line 172: | ||
js> 1+1 | js> 1+1 | ||
2 | 2 | ||
== 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 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. | |||
* 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 | |||
** (Device) ps js | |||
USER PID PPID VSIZE RSS WCHAN PC NAME | |||
root 6036 6034 6084 1856 ffffffff afe0c27c T ./js | |||
* Attach gdbserver to the process | |||
** (Device) gdbserver localhost:1234 --attach 6036 | |||
Attached; pid = 6036 | |||
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) | |||
** (Host) ~/android-ndk-1.6_r1/build/prebuilt/linux-x86/arm-eabi-4.2.1/bin/arm-eabi-gdb js | |||
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 placed system/bin/linker) | |||
** (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. | |||
** (Host gdb) set solib-search-path /home/user/android/sysimg/system/lib:/home/user/android/moz-build/dist/bin | |||
* Connect to gdbserver | |||
** (Host gdb) target remote localhost:1234 | |||
= Other Resources = | = Other Resources = |
edits