How GDB is Game Chnager when write code ?
When your code is running but not working at that time we mostly check line by line code it cant find any clue.
The best way to check your code line by line and what code acutally do internally, when you run the code.
so anyway let’s start by installing GDB debugger in computer .
To install on Ubuntu
sudo apt install gdb
To install on arch
sudo pacman -S gdb
To download on Your Machine https://sourceware.org/gdb/download/
You can also use it online https://www.onlinegdb.com/
How to run GDB
- Run Your complier
$ g++ -g program
- Run Your gdb
$ gdb a.out
you will get output something like
Start Your gdb with start command
start
Now Press ctrl + x + a
Now for go to next linenext
it go two second line
next
if your ui is not lagging than press ctrl + l
to refresh the ui
To check store data in variable
print var_name
or
info locals
To Go Function defination when debgger reach to that line
step
To exit
exit
Hope you get basic idea who to use this software
I know that i did not teach everything ,so To know more You can refere any Documenation or cheatsheet
If i get sometime than i may continue this blog to the end and I will teach everything
Thank You For Your Time :)