[First written by Steve Guo, please keep the mark if forwarding.]
Assume your target board's IP address is 192.168.1.101. Your host
dev machine's IP address is 192.168.1.100. Your Android source code is
in ~/mydroid. In the target board, you should do the following things. 1. Make sure you have replaced libc.so with the version containing
symbol information. (You should copy
~/mydroid/out/target/XXX/symbols/system/lib/libc.so), otherwise you
will met issue when debugging multi-thread app. Because libthread_db.so
depends on a _thread_created_hook symbol in libc.so. 2. Copy ~/mydroid/prebuilt/android-arm/gdbserver/gdbserver into board rootfs. 3. You can launch gdbserver by the following two commands: #gdbserver 192.168.1.101:5544 --attach $(PID) #gdbserver 192.168.1.101:5544 $(YOUR_APP) The first command is to debug an already run process, the second
command is to debug a new process. 5544 is a random port you can use
any. In the host develop machine, you should do the following things. 1. Add ~/mydroid/prebuilt/linux-x86/toolchain/arm-eabi-4.2.1/bin into $PATH so that you can directly use arm-eabi-gdb. $export PATH=$PATH:~/mydroid/prebuilt/linux-x86/toolchain/arm-eabi-4.2.1/bin 2. launch arm-eabi-gdb and in the gdb shell environment, type the following commands: (gdb) set solib-search-path
~/mydroid/out/target/product/avlite/symbols/system/lib:~/mydroid/out/target/product/avlite/symbols/system/bin (gdb) target remote 192.168.1.101:5544 3. The remaining things is how you use gdb, it's not covered in this topic. Note: There are the following know issues now: 1. n and s does not work now for multi-thread app. 2. p does not work correctly for C++ symbol.
Using gdbserver and arm-eabi-gdb to debug native code in Android
最新推荐文章于 2024-04-20 12:17:55 发布