Table of Contents
1- Key Functionalities of The GDB Debugger
- Source code debugging
- GDB can debug programs at the source code level, allowing developers to step through their code line by line and examine variables and memory.
- GDB allows developers to set breakpoints in their code to stop the execution of the program at a specific point and examine the state of the program.
- GDB allows developer to watch memory locations for changes during program execution.
- Call Stack
- With GDB debugger, developers can examine the call stack to understand how the program reached a certain point in execution.
- Debugging multi-threaded and multi-process programs
- Dynamic tracing
- GDB can trace the execution of a program and generate a log of events that occurred during the execution.
- Remote debugging
- GDB can be used to debug programs running on remote systems.
- Core dump analysis
- GDB can analyze core dumps generated by crashing programs to help developers identify the cause of the crash.
- The GDB Agent Expression Mechanism
1.1- Breakpoint Management
There are 3 different types of breakpoints in GDB debugger.
A breakpoint makes your program stop whenever a certain point in the program is reached. 
A watchpoint is a special breakpoint that stops your program when the value of an expression changes. 
A catchpoint is another special breakpoint that stops your program when a certain kind of event occurs, such as the throwing of a C++ exception or the loading of a library. 
A tracepoint is a type of breakpoint that doesn’t stop the program’s execution when hit, but instead logs a message indicating that it has been hit. Tracepoints are useful for collecting information about the program’s execution without disrupting its flow.
- [Official GDB Document] Tracepoints
- [Official GDB Document] Tracepoint Restrictions
- [Official GDB Document] Tracepoints support in
We can use a number of operations with breakpoints.
- The specific commands used for breakpoints, watchpoints, or catchpoints may change.
1- Set Breakpoints
You can set a breakpoint at a specific line number in the source code, or when a certain function is called. Once the program hits the breakpoint, it is temporarily suspended and you can inspect data/variables in the program.
- [Official GDB Document] Setting Breakpoints
- [Official GDB Document] Setting Watchpoints
- [Official GDB Document] Setting Catchpoints
- [Official GDB Document] Create Tracepoints
2- Specify a condition
You can also specify a condition for a breakpoint. A conditional breakpoint allows you to specify a condition that must be met for the breakpoint to be triggered.
A special case of a breakpoint condition is to stop only when the breakpoint has been reached a certain number of times. If the ignore count value of the breakpoint is n, the breakpoint does not stop the next n times your program reaches it.
3- Enable-Disable Breakpoints
In GDB, you can enable or disable breakpoints. When a breakpoint is enabled, it means that GDB will suspend the execution of your program when it reaches that breakpoint. When a breakpoint is disabled, it has no effect on your program until you enable it again.
- [Official GDB Document] Enable and Disable Breakpoints
- [Official GDB Document] Enable and Disable Tracepoints
4- Delete Breakpoints
In GDB, you can delete breakpoints once they have done their job and you no longer want your program to stop there.
5- Save Breakpoints
In GDB, you can save all current breakpoint definitions to a file suitable for use in a later debugging session. This includes all types of breakpoints (breakpoints, watchpoints, catchpoints, tracepoints)
6- Listing breakpoints
- [Official GDB Document] Set Breakpoints
- Also includes information on listing breakpoints.
- [Official GDB Document] Listing Tracepoints
1.2- The GDB Agent Expression Mechanism
In some applications, it is not feasible for the debugger to interrupt the program’s execution long enough for the developer to learn anything helpful about its behavior. If the program’s correctness depends on its real-time behavior, delays introduced by a debugger might cause the program to fail, even when the code itself is correct.
- Exploring The GNU GDB Agent Expressions: A Complete Overview – Ktpql
- [Official GDB Document] The GDB Agent Expression Mechanism
2- Key Features of The GDB Debugger
- GDB can be used on various platforms, including Linux, Windows, macOS, and more.
- Supports multiple programming languages
- GDB supports a wide range of programming languages such as C, C++, Ada, Fortran, and more.
- Command-line interface
- GDB has a command-line interface that allows developers to interact with the debugger using various commands.
- GDB is highly extensible, and developers can add their own commands and features to the debugger using the GDB Python API.
Further Exploring The GNU GDB Debugger
You can use the following resources for further research and understanding the GNU GDB in detail.
GDB Debugger Wikis
GDB Debugger Books:
GDB Debugger Documentation:
GDB Source Code:
- Official source code of the GNU GDB: sourceware.org Git
- Unofficial github mirror of sourceware binutils-gdb repository: bminor/binutils-gdb: . Updated daily. (github.com)
 Breakpoints (Debugging with GDB). Sourceware. https://sourceware.org/gdb/onlinedocs/gdb/Breakpoints.html