- The problem with just running the code is that it keeps on running until the program exits, which is usually too late. For this, breakpoints are introduced.
- A break point is a command for the debugger to stop the execution of the program before executing a specific source line.
- We can set break points using two methods:
- Specifying a specific line of code to stop in:
(gdb) break debugme.c:9
Will insert a break point right before checking the command line arguments in our program.
- Specifying a function name, to break every time it is being called:
(gdb)break main
this will set a break point right when starting the program (as the function "main" gets executed automatically on the beginning of any C or C++ program).
Cem Ozdogan
2011-02-14