gdb — Development Environment and Programming
A GNU standard debugger for inspecting breakpoints, stack, and variables of a running program.
Basic Information
| Program name | gdb (GDB) |
|---|---|
| One-line description | A GNU standard debugger for inspecting breakpoints, stack, and variables of a running program. |
| Developed / maintained by | GNU Project |
| Official homepage | https://www.gnu.org/software/gdb/ |
| Official documentation | https://sourceware.org/gdb/documentation/ |
| Official download | https://www.gnu.org/software/gdb/download/ |
| Supported operating systems | Linux, macOS, Windows (MinGW), major Unix |
| License | GPL-3.0-or-later |
| Stable version | 18.1 (released 2026-09-25) — checked 2026-10-18 |
| GitHub repository | https://sourceware.org/git/gdb.git |
| Category | Development environment and programming (tags: debugging, crash analysis, stack trace) |
What is this program?
gdb (GNU Debugger) is the standard debugger for setting breakpoints in running programs, stepping through line by line, and examining variables and the stack. It is also used to open core dumps left when services die on a server and reconstruct the point of failure.
When tracing abnormal behavior of native services written in C/C++ (web servers, databases, kernel modules, etc.) down to the root cause, it is effectively the default tool; a workflow of pulling only core files from a remote server and analyzing them is also widely used.
What problems does it solve?
- When you need to check from a core dump where a service died after being killed by a signal.
- When you need to inspect variable states step by step for a reproducible abnormal behavior.
- When you need to trace memory-level issues such as stack overflows or null pointers.
- When you need to analyze a production server using only core files, without deploying a debug build.
Key features
Breakpoints and stepping
Set breakpoints on lines, functions, and addresses, and execute one instruction at a time.
- Use case: stop just before an abnormal behavior and inspect variables.
- Result: obtain the exact reproduction point and the state at that time.
- Limitations: for threaded/asynchronous logic, choosing breakpoint locations can be tricky.
Stack trace
Prints the call stack at the time of a crash as a hierarchy.
- Use case: view the crashed function and call path in a core dump.
- Result: identify the cause function and upper callers within seconds.
- Limitations: builds with debug symbols stripped lack line information.
Variable and memory inspection
Check variable values and memory dumps with the print and x commands.
- Use case: trace input values under error conditions.
- Result: directly inspect corrupted pointers and unexpected values.
- Limitations: in optimized builds (-O2), variables may be optimized away and displayed values may differ from the original.
Remote debugging
Attach to processes or simulators on another machine with target remote.
- Use case: debug embedded devices or cross-build environments.
- Result: debug remote processes from the development machine.
- Limitations: requires network and permission configuration, so initial setup overhead exists.
Installation and execution
Ubuntu / Debian
Install the distribution repository version. For the latest features, use a source build from the GNU download page.
sudo apt update
sudo apt install gdb
RHEL / CentOS / Fedora
Install from the default repositories.
sudo dnf install gdb
Source build (latest version)
Download the source from the official download page and build it.
# https://www.gnu.org/software/gdb/download/
Real-world usage examples
Opening a core dump
Open a core file with gdb to see where it died.
gdb /usr/sbin/app-server core.12345
Setting a breakpoint and running (example)
Set a breakpoint on a function and run. The output is an example.
gdb ./app-server
gdb) break handle_request
gdb) run --config /etc/app.conf
Viewing the stack
Print the call stack at the time of a crash or breakpoint.
gdb) backtrace full
Advantages and limitations
Advantages
- A standard tool for debugging C/C++ native code with abundant documentation and resources.
- Powerful post-mortem analysis based on core dumps, suitable for tracking production server failures.
- Free under the GNU license and included by default on most Linux systems.
- Python scripting can automate repetitive analysis.
Considerations before use
- No GUI, so there is a learning curve for command syntax.
- Optimized builds may display distorted variables and stack.
- Support for GC languages such as Go and Rust is limited.
- Symbol-stripped builds make line-level analysis difficult.
Comparison with similar programs
| Program | Characteristics | Suitable for these cases |
|---|---|---|
| lldb | A debugger from the LLVM project that fits well with Clang/macOS environments. | macOS/LLVM toolchain development environments. |
| valgrind | Detects memory errors while slowing down execution. | When looking for hard-to-reproduce memory leaks. |
| AddressSanitizer | Catches memory errors quickly through compile-time instrumentation. | When detecting errors early in the testing phase. |
Official resources and further learning
- Official homepage — https://www.gnu.org/software/gdb/
- Official documentation / knowledge base — https://sourceware.org/gdb/documentation/
- Official download — https://www.gnu.org/software/gdb/download/
- Release notes — https://sourceware.org/gdb/news/
- Source / development resources — https://sourceware.org/git/gdb.git
Version and supported environment information is confirmed from the official site as of 2026-10-18. Installation commands may vary depending on the distribution and version you use, so please also check the official installation documentation.
Actual execution screen
This is a composite example reconstructed in a server-like style showing the screen where you open a core dump with gdb and check the crash point and stack. The screen is a synthetic example and not an actual execution result.
!gdb core dump analysis screen: terminal showing SIGSEGV location (request.c:184) and backtrace
Actual production server
Source (HTML): https://games.aidebatehub.com/programs/apps/dev/gdb.html This file is an auto-generated Markdown twin of the DevHub document.
AI Knowledge Hub
Visitor Comments