CSE 2312 - Brief Guide for Using the GDB Debugger
Topics:
Starting a Debugging Session
Suppose that your source code is saved in a file called test1.s, which you have compiled into an executable called test1.bin.
To start the debugger, you perform these steps:
- On the terminal window, execute this command (make sure you enter it as a single line, and you copy and paste exactly, including spaces):
qemu-system-arm -s -M versatilepb -daemonize -m 128M -S -d in_asm,cpu,exec -kernel test1.bin ; gdb-multiarch
- The GDB debugger has now started. Enter the following three lines:
set architecture arm
target remote :1234
symbol-file test1.elf
Debugging Commands
-
b label
Sets a breakpoint at a specific label in your source code file. In practice, for some weird reason, the code actually breaks not at the label that you specify, but after executing the next line.
-
b line_number
Sets a breakpoint at a specific line in your source code file. In practice, for some weird reason, the code actually breaks not at the line that you specify, but at the line right after that.
-
c
Continues program execution until it hits the next breakpoint.
-
i r
Shows the contents of all registers, in both hexadecimal and decimal representations.
-
list
Shows a list of instructions around the line of code that is being executed.
-
quit
This command quits the debugger, and exits GDB.
-
stepi
This command executes the next instruction.
Back to the resources page.
Back to the CSE 2312 home page.