参考:https://www.dandelioncloud.cn/article/details/1527473447139819521
gdb下载路径:http://ftp.gnu.org/gnu/gdb/
configure参数:./configure LDFLAGS=-static --host=aarch64-linux-gnu CC=/usr/bin/aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++
,注意要加static参数,否则使用全路径执行gdbserver会报找不到文件错误。
错误排查
-
对于gdb7.8编译,可能会出现错误
https://www.cnblogs.com/eastgeneral/p/11615368.html, 将相关的c文件的重复函数注释掉就行。 -
连接android平台报错:warning: while parsing target description (at line 10): Target description specified unknown architecture "arm"
https://blog.csdn.net/qq_40351988/article/details/121631918
使用gdb-multiarch,一般clion默认的也是这个。 -
使用clion无法catch到断点,但是使用gdb命令可以。
可执行文件在编译的时候没有加-g参数 -
file exe fialure
1)不要使用strip处理执行文件,否则无法debug.对于clion则提示‘file exe fialure’
2)将要debug的程序正在运行 -
warning: Selected architecture aarch64 is not compatible with reported target architecture arm
Reply contains invalid hex digit 59
场景:ndk编译的可执行文件
mkdir -p build
cd build
rm -rf *
export CMAKE_BUILD_TYPE=Debug
cmake .. \
-DCMAKE_TOOLCHAIN_FILE=/etc/opt/pkg/android-ndk-r25c/build/cmake/android.toolchain.cmake \
-DANDROID_ABI="arm64-v8a" \
-DANDROID_NATIVE_API_LEVEL=android-24
make -j4
通过gdb-multiarch命令进入gdb命令行,执行set architecture arm
,上面错误消除。但是读不到debug相关的符号表
(gdb) set architecture arm
The target architecture is assumed to be arm
(gdb) target remote 10.0.3.16:1234
Remote debugging using 10.0.3.16:1234
Reading /system/bin/linker64 from remote target...
warning: File transfers from remote targets can be slow. Use "set sysroot" to access files locally instead.
warning: `target:/system/bin/linker64': Shared library architecture aarch64 is not compatible with target architecture arm.
Reading /system/bin/linker64 from remote target...
warning: `target:/system/bin/linker64': Shared library architecture aarch64 is not compatible with target architecture arm.
Reading symbols from target:/system/bin/linker64...
Reading /system/bin/.debug/linker64 from remote target...
Reading /usr/lib/debug//system/bin/linker64 from remote target...
Reading /usr/lib/debug/system/bin//linker64 from remote target...
Reading target:/usr/lib/debug/system/bin//linker64 from remote target...
(No debugging symbols found in target:/system/bin/linker64)
- gdb-multiarch 读取可执行文件调试信息失败
Dwarf Error: DW_FORM_strx1 found in non-DWO CU [in module /home/xinyi/code/cplus/lxc_socket/build/lxc_socket_server] (No debugging symbols found in build/lxc_socket_server)
当编译静态链接可执行文件SET(CMAKE_EXE_LINKER_FLAGS "-static -ffunction-sections -fdata-sections -Wl,--gc-sections")
时就会报上面的错误
- gdb-server 读取可执行文件调试信息失败
客户端:
(gdb) set architecture arm
The target architecture is assumed to be arm
(gdb) target remote 10.0.3.16:1234
Remote debugging using 10.0.3.16:1234
Reading /system/bin/linker64 from remote target...
warning: File transfers from remote targets can be slow. Use "set sysroot" to access files locally instead.
warning: `target:/system/bin/linker64': Shared library architecture aarch64 is not compatible with target architecture arm.
Reading /system/bin/linker64 from remote target...
warning: `target:/system/bin/linker64': Shared library architecture aarch64 is not compatible with target architecture arm.
Reading symbols from target:/system/bin/linker64...
Reading /system/bin/.debug/linker64 from remote target...
Reading /usr/lib/debug//system/bin/linker64 from remote target...
Reading /usr/lib/debug/system/bin//linker64 from remote target...
Reading target:/usr/lib/debug/system/bin//linker64 from remote target...
(No debugging symbols found in target:/system/bin/linker64)
0xb7f51c64 in ?? ()
(gdb)
(No debugging symbols found in target:/system/bin/linker)
可能的情况是调试的程序是tripped了,通过file查看一下。可以debug的是not stripped
但是奇怪的是调试文件已经是not stripped
了,gdb仍然无法读取到调试符号信息。
服务端:
Remote debugging from host 10.0.2.54
gdbserver: unexpected r_debug version 0
直接使用ndk里自带的gdbserver
android-ndk-r9\prebuilt\android-arm\gdbserver
直接使用Android系统自带的gdbserver
/system/bin/gdbserver
0 条评论