使用buildroot编译对应的gdb for x86,gdbservice for arm: 确保各自平台和cpu的位数和程序的位数匹配
记得设置 host gdb这边要调试的程序的依赖库,如:
pakydu@SRVECT:~/works/E3_ok/source/utils/OneDay$ /opt/arm64_tool/bin/aarch64-buildroot-linux-gnu-gdb OneDay
GNU gdb (GDB) 8.2.1
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "--host=x86_64-pc-linux-gnu --target=aarch64-buildroot-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from OneDay...done.
(gdb) target remote 10.161.93.10:2001
Remote debugging using 10.161.93.10:2001
Reading /lib/ld-linux-armhf.so.3 from remote target...
warning: File transfers from remote targets can be slow. Use "set sysroot" to access files locally instead.
Reading /lib/ld-linux-armhf.so.3 from remote target...
Reading symbols from target:/lib/ld-linux-armhf.so.3...(no debugging symbols found)...done.
0xf7fbea00 in ?? () from target:/lib/ld-linux-armhf.so.3
(gdb) set solib-absolute-prefix /home/pakydu/works/E3_ok/rootfs_arm64-full/rootfs_partition_unstripped/:/home/pakydu/works/E3_ok/rootfs_arm64-full/rootfs_partition_unstripped/usr/lib/
warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
and track explicitly loaded dynamic code.
(gdb) l
GDB的相关参考:
一文带你看透 GDB 的 实现原理 -- ptrace真香_z_stand的博客-CSDN博客_ptrace修改内存