Qemu simulates gdb debugging of ARM
System: Ubuntu16.04.4 32bit
Cross Compiler: arm-linux-gnueabihf-gcc
VMware: VMware Workstation 14 Pro
u-boot: u-boot-2018.03
linux: linux-4.16.2
1. Debug uboot
qemu-system-arm -M vexpress-a9 -m 256M -nographic -kernel u-boot -gdb tcp::2233 -S
Stuck here waiting to connect
Host gdb connection
arm-linux-gnueabihf-gdb u-boot
Enter the command to connect to remote debugging
(gdb) target remote : 2233
2. Debug linux
The operation is the same as debugging uboot
qemu-system-arm -M vexpress-a9 -m 256M -nographic -kernel vmlinux -gdb tcp::2233 -S
arm-linux-gnueabihf-gdb vmlinux
(gdb) target remote : 2233
3. gdb simple debugging command
next(n): the next part
step(s): step into
bt List function stack frames
print to view the value of a variable or memory
break line number or function name: next breakpoint
info breakpoints View current breakpoint information
delete clears all breakpoints
continue (c) run to the next breakpoint
print /x var hexadecimal display (var) value
print can specify the display format, where '/x' is used to represent the hexadecimal format.
The supported variable display formats are:
x Displays the variable in hexadecimal format.
d Displays variables in decimal format.
u Displays unsigned integers in hexadecimal format.
o Display variables in octal format.
t Display variables in binary format.
a Displays the variable in hexadecimal format.
c Displays variables in character format.
f Displays variables in floating-point format.
print x=4 Modify the variable value at runtime