GDB is an immensely useful tool to help you debug your C and assembly programs.
printf
).The time you spend getting familiar with GDB will be an excellent investment for this and future courses.
Text User Interface (TUI) mode of GDB can nicely show your code and the value of registers as you debug!
Its use is entirely optional for 351, but we wanted you to be aware of it as it may help some of you.
Most TUI commands will automatically start TUI mode, but you can also explicitly open GDB in TUI mode using:
[attu]$ gdb -tui <filename>
Of particular interest, you can bring up the disassembly and registers view using:
(gdb) layout asm (gdb) layout regs
Note that you want to do them in that order so that the registers window is on top.
Then as you execute instructions (stepi
or si
for assembly instructions), the assembly view will highlight the next instruction (not executed yet) and the registers view will highlight any changed registers.
Unfortunately, there are some annoying formatting issues that sometimes pop up while using TUI mode. If things start to look weird, run the following command to set things straight:
(gdb) refresh