android gdb 远程调试工具,Android下用gdb远程调试办法
Host: ubuntu
Target: Android ICS
1. 將gdbserver和gdbclient分別放入target和host。兩者都可在android源代碼的prebuilt目錄下找到。
2. 在Target上啟動(dòng)gdbserver,在adb shell中執(zhí)行
$ /path/to/gdbserver :1111--attach PID
其中PID為想要debug程序的進(jìn)程號(hào),可以通過(guò)ps得到。1111為端口號(hào),可以自定義。
3. 在Host上啟動(dòng)gdbclient,首先將target上的庫(kù)pull到host上(如/home/jzj/debug/gdb)
$cd /home/jzj/debug/gdb
$adb pull /system/lib
$adb pull /system/bin/app_process
然后寫(xiě)啟動(dòng)腳本init.gdb(這里假設(shè)程序要用到的庫(kù)放在/home/jzj/debug/gdb/下,android的symbol放在/home/jzj/debug/ics/symbols/system/lib/下,android的源碼放在/home/jzj/workspace/ics下)
file /home/jzj/debug/gdb/app_process
set solib-absolute-prefix /home/jzj/debug/ics/symbols/
set solib-search-path /home/jzj/debug/ics/symbols/system/lib/:/home/jzj/debug/gdb
dir /home/jzj/workspace/ics
shell adb forward tcp:1111 tcp:1111
target remote :1111
最后執(zhí)行
$ gdb -x init.gdb
就可以啟動(dòng)gdb了。一切正常的話這時(shí)候就可以用gdb的基本功能,如設(shè)斷點(diǎn)或者查看內(nèi)存了。這時(shí)有些so庫(kù)的符號(hào)表可能還沒(méi)載入,可以執(zhí)行
(gdb) shared
載入這些符號(hào)表。
最后附個(gè)關(guān)于gdb設(shè)置腳本中兩個(gè)變量的官方解釋,一般solib-absolute-prefix先于solib-search-path查找。
solib-absolute-prefix :
If this variable is set, path will be used as a prefix for any absolute shared library paths; many runtime loaders store the absolute paths to the shared library in the target program's memory. If you use `solib-absolute-prefix' to find shared libraries, they need to be laid out in the same way that they are on the target, with e.g. a `/usr/lib' hierarchy under path. You can set the default value of `solib-absolute-prefix' by using the configure-time `--with-sysroot' option.
solib-search-path :
If this variable is set, path is a colon-separated list of directories to search for shared libraries. `solib-search-path' is used after `solib-absolute-prefix' fails to locate the library, or if the path to the library is relative instead of absolute. If you want to use `solib-search-path' instead of `solib-absolute-prefix', be sure to set `solib-absolute-prefix' to a nonexistant directory to prevent GDB from finding your host's libraries.
http://www.dengb.com/Androidjc/433578.htmlwww.dengb.comtruehttp://www.dengb.com/Androidjc/433578.htmlTechArticleHost: ubuntu Target: Android ICS 1. 將gdbserver和gdbclient分別放入target和host。兩者都可在android源代碼的prebuilt目錄下找到。 2. 在Target上啟動(dòng)gdbserver,...
總結(jié)
以上是生活随笔為你收集整理的android gdb 远程调试工具,Android下用gdb远程调试办法的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 农民有福了?2020年农民养老金新政出炉
- 下一篇: android蓝牙设计与实现,一个And