GNU Debugger
GDB is a source-level debugger capable of breaking programs at any specific line, displaying variable values, and determining where errors occurred. It supports multiple languages including C, C++, Fortran, Java, and assembly.
Description
GDB is a powerful tool for debugging programs at the source level. It allows programmers to set breakpoints, inspect variables, and trace execution to identify bugs and errors. Currently supporting languages like C, C++, D, Objective-C, Fortran, Java, OpenCL C, Pascal, assembly, Modula-2, Go, and Ada, it is essential for serious programming and reverse engineering tasks.
The tool comes with related binaries like gcore for generating core dumps from running processes, gdb-multiarch for multi-architecture support, gdbserver for remote debugging, and utilities such as gdb-add-index and gstack. These extend GDB's capabilities for analyzing core files, stack traces, and remote targets.
Installation provides access to the full suite, with dependencies ensuring compatibility across architectures and environments. GDB reads system-wide init files like /etc/gdb/gdbinit on startup.
How It Works
GDB attaches to executables, core dumps, or running processes via options like --exec, --core, or --pid. It reads symbol files for source-level debugging, supports multiple interpreters and UIs, and executes initial commands from files. Remote debugging uses gdbserver over TCP or serial connections, while gcore creates core files by dumping process memory using GDB internals.
Installation
sudo apt install gdbFlags
Examples
gcore -hgdb -hgdb-add-index -hgstack -hgdbserver --helpgcore -o prefix pid1gdb --pid=PIDgstack PID