Breakpoint
In debugging, sometimes we need to execute or halt a code line by line. That's where breakpoints come in handy.
We'll cover the following
The print
command will print out the value of a variable that is defined in the current stack.
Open the go.c file from the previous lesson. We’ll use this as a reference for this lesson. Let’s try to print the s
variable (which is supposed to be a character buffer). Let’s first however define 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 the gdb debugger. We use the gdb
command break
to insert a breakpoint, and then the run
command to run the program:
Create a free account to access the full course.
By signing up, you agree to Educative's Terms of Service and Privacy Policy