3.2.5. Using GDB breakpoints to stop execution at defined code locations
During a debugging session, you often need to investigate only specific sections of code. Breakpoints are markers that instruct GDB to stop execution at a defined location. Because each breakpoint maps to a source line, you must specify the correct source file and line number when placing them.
Procedure
To place a breakpoint.
Specify the name of the source code file and the line in that file:
(gdb) br file:lineWhen file is not present, name of the source file at the current point of execution is used:
(gdb) br lineAlternatively, use a function name to put the breakpoint on its start:
(gdb) br function_nameA program might encounter an error after a certain number of iterations of a task. To specify an additional condition to halt execution:
(gdb) br file:line if conditionReplace condition with a condition in the C or C++ language. The placeholders file and line match the syntax shown in the first breakpoint step in this procedure.
To inspect the status of all breakpoints and watchpoints:
(gdb) info brTo remove a breakpoint by using its number as displayed in the output of
info br:(gdb) delete numberTo remove a breakpoint at a given location:
(gdb) clear file:line