GDB Debugging Cheatsheet
Essential GDB debugging commands and techniques for effective C/C++ debugging
Anonymous
Updated 5 months ago
general
beginner
general
debugging
gdb
c
cpp
linux
tools
GDB Debugging Cheatsheet
Essential GDB commands and techniques for effective C/C++ debugging
Quick Start: Compile with debug symbols using
gcc -g program.c, then run gdb ./a.out to start debugging.Basic Commands
Essential
gdb programStart GDB with a program
Example:
gdb ./myappgdb program coreDebug with core dump
Example:
gdb ./myapp coregdb -p PIDAttach to running process
Example:
gdb -p 12345run [args]Start program execution
Example:
run arg1 arg2continue (c)Continue execution after breakpoint
quit (q)Exit GDB
help [command]Get help for commands
Example:
help breakpointset args [args]Set program arguments
Example:
set args -v file.txtshow argsDisplay current arguments
file programLoad executable file
Example:
file ./debug_version💡 Pro Tip: Use Tab for auto-completion and ↑/↓ for command history
📖 For more details: man gdb or info gdb