android gdb 远程调试工具,Android下用gdb远程调试办法
Host: ubuntu
Target: Android ICS
1. 將gdbserver和gdbclient分別放入target和host。兩者都可在android源代碼的prebuilt目錄下找到。
2. 在Target上啟動gdbserver,在adb shell中執行
$ /path/to/gdbserver :1111--attach PID
其中PID為想要debug程序的進程號,可以通過ps得到。1111為端口號,可以自定義。
3. 在Host上啟動gdbclient,首先將target上的庫pull到host上(如/home/jzj/debug/gdb)
$cd /home/jzj/debug/gdb
$adb pull /system/lib
$adb pull /system/bin/app_process
然后寫啟動腳本init.gdb(這里假設程序要用到的庫放在/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
最后執行
$ gdb -x init.gdb
就可以啟動gdb了。一切正常的話這時候就可以用gdb的基本功能,如設斷點或者查看內存了。這時有些so庫的符號表可能還沒載入,可以執行
(gdb) shared
載入這些符號表。
最后附個關于gdb設置腳本中兩個變量的官方解釋,一般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上啟動gdbserver,...
總結
以上是生活随笔為你收集整理的android gdb 远程调试工具,Android下用gdb远程调试办法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 农民有福了?2020年农民养老金新政出炉
- 下一篇: 2020年养老保险缴费基数