因為不是在 local 端上除錯,所以會需要一些額外的設定。
# 首先要在 target device 上把 GDB Server 叫起來,指令如下。
gdbserver :port /the_path_of_an_executable_file
e.g.
$sudo adb shell
#gdbserver :5039 /system/bin/bootanimation
* 指定 GDB Server 監聽的埠號為5039# 然後是 local 端上的設定。
adb forward <local> <remote>
e.g.
$sudo adb forward tcp:5039 tcp:5039
# 接著在 local 端執行 GDB,並且設定相關項目。可使用 gdb、gdbtui 或 gdb --tui。
$ln -s prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/arm-eabi-gdb ./gdb
$ln -s prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/arm-eabi-gdbtui ./gdbtui
$./gdb ${PWD}/out/target/product/product_name/symbols/system/bin/bootanimation
(gdb)directory ${PWD}/frameworks/base/cmd/bootanimation
(gdb)set solib-absolute-prefix ${PWD}/out/target/product/product_name/symbols
(gdb)set solib-search-path ${PWD}/out/target/product/product_name/symbols/system/lib
(gdb)target remote :5039
# GDB 的設定也可以另外寫成一個檔案。
$vi gdb.setup
directory /absolute-source-path/frameworks/base/cmd/bootanimation
set solib-absolute-prefix /absolute-source-path/out/target/product/product_name/symbols
set solib-search-path /absolute-source-path/out/target/product/product_name/symbols/system/lib
target remote :5039
$./gdb -x gdb.setup ${PWD}/out/target/product/product_name/symbols/system/bin/bootanimation
# 使用 DDD
$sudo apt-get install ddd
$ddd --debugger "${PWD}/gdb -x gdb.setup" ${PWD}/out/target/product/product_name/symbols/system/bin/bootanimation
沒有留言:
張貼留言