Search⌘ K

Entering and Exiting gdb Mode

Explore the essential steps for debugging C programs using gdb. Learn to compile with the -g flag, run programs inside gdb mode, inspect source code with the list command, and properly exit gdb. This lesson guides you through starting and stopping gdb effectively to facilitate troubleshooting.

Compile the program

To be able to debug a program using gdb, we must, first, compile it using the -g flag.

gcc main.c -g

The output of this program will be available in a.out (or a.exe).

Run a.out/a.exe under

...