Debug C or C++ with GDB
It's speccialy usefull to use GDB not only to debug a program but also for traversing a project and to read the code in the order that it usualy runs and not sequencialy. Just put a breakpoint in the main
funciton and next
!
There's a very usefull plugin to make using GDB more comfortable, I been using it for many years. It's called GDB Dashboard and enhances the CLI.
Step 1: Download and Install GDB
First, ensure that GDB is installed on your system. You can typically install it via your package manager. For example:
# On Debian/Ubuntu
sudo apt update
sudo apt install gdb
Step 2: Download and Install the GDB Dashboard Plugin
Follow the instructions on https://github.com/cyrus-and/gdb-dashboard
Alternatively, you can quickly install it by running the following command:
wget -P ~ https://github.com/cyrus-and/gdb-dashboard/raw/master/.gdbinit
put it in .gdbinit
on home or in .config/gdb/gdbinit
Step 3: Disable Unnecessary Features (Optional)
If not going to develop bare metal maybe better to disable some features.
Place this line at the end of the gdbinit
dashboard -layout !assembly breakpoints !expressions !history !memory !registers source stack threads variables
And voilĂ you have gdb configured an redy to use, with a better visualization for the CLI.