First, we need to install gdb by running the following command:
sudo apt install gdb
The installation should look something like this:
Then, use gdb to debug the hello program, as follows:
gdb ./hello
gdb can be controlled using commands. The commands are fully listed in online documentation, but simply entering help can aid us with the basics.
You can also use gdb to show the disassembly of specified functions, using the disass command. For example, let's see what happens if we use the disass main command:
Then, ...