GDB调试示例
以调试可执行程序gdbDebug为例,gdbDebug.cpp内容如下:

使用gdb 启动gdbDebug程序


左侧为gdb调试,右侧为gdbDebug.cpp内容


GDB与GDBServer调试示例
以调试可执行程序gdbDebug为例,gdbDebug.cpp内容如下:

使用gdbserver 启动debug程序,如下:
./gdbserver 0.0.0.0:3000 ./gdbDebug
其中0.0.0.0是本机ip,3000端口(端口可变),图片显示加载成功。

PC端
1 使用 aarch64-none-linux-gnu-gdb 启动gdbDebug程序,并远程连接gdbserver
1) 给予gdbDebug程序执行权限,并启动

2) 连接已启动gdbserver的板子
命令target remote 192.168.1.102:3000,其中192.168.1.102为板子ip,3000为gdbserver绑定的端口。

上图是连接成功,下图服务端显示客户端的ip和端口

使用b命令对main、test1、test2、test3断点设置

此时gdb run运行命令无法使用,需要使用c跳转到断点处运行



此时所有的程序输出都在域控端


