Breakpoint
Learn about breakpoints and how they are useful for debugging by executing a code line by line.
We'll cover the following...
The print command in GDB prints out the value of a variable that’s defined in the current stack.
We’ll continue to use the go.c file from the previous lesson, as a reference for this lesson. We’ll try to print the s variable (which is supposed to be a character buffer).
Let’s first, however, define a breakpoint.
Inserting a breakpoint
A breakpoint is a flag that will stop the program at a specific line of code. Let’s insert a breakpoint on line 9 of our code. This means the program will stop before executing that line of code and leave us in GDB. We use the GDB command break to insert a breakpoint and then the run command to run the program:
Now (gdb) prompt is waiting for input and we are stopped just short ...