A.在一个终端输入 作为gdb服务端
../../qemu5p1/qemu-5.1.0/aarch64-softmmu/qemu-system-aarch64 -M virt,secure=off, -cpu cortex-a57 \
-smp 1 -m 1024M -kernel u-boot -nographic -D log.txt -d in_asm -s -S
-s 选项告诉 qemu-system-aarch64 启动内置的 gdb-server, 监听在 TCP 端口 1234 上
-S 选项告诉 qemu-system-aarch64 不要启动程序执行,等待 gdb 的指令
目前程序 u-boot 处于停止状态
qemu-system-aarch64 等待 gdb 客户端连接它,发送进一步的指令。
B.另外再启动一个终端 作为客户端
现在客户端用 gdb 连接 qemu-system-aarch64
1.启动gdb调试
gdb-multiarch u-boot
2.连接gdb服务器调试端口
target remote 192.168.10.101:1234
3.运行控制
step :单步执行程序,进入函数内部。
next :单步执行程序,不进入函数内部。
continue :继续执行程序。
finish :运行到函数结束。
si
4.退出全速
ctrl+c
5.设置程序断点
b *0x7c00
6.反汇编:
起始地址,指令数目
disas 0x7ff6e654,+10
7.查看寄存器的内容
i r
p /x $cpsr
p /x $x1
p /x $x0
8.查看内存
命令格式:x /nfu addr
n表示数量
f表示格式:x(hex), d(decimal), c(char)
u表示显示单位:b(byte), h(halfword), w(word), g(giant, 8 bytes)
x /4xw 0