A great advantage to using gdb in emacs is that it works the same on all platforms (Linux, Windows, etc.), and it displays the source in a separate emacs buffer window. As you single-step the program, a pointer shows you which line of source code will be executed next. Many nice new features have evolved for debugging in Emacs, as illustrated at the video link given near the beginning of this section.
To start gdb within emacs, say M-x gdb <Enter>, edit the gdb execution line, if necessary, and type <Enter> again. A gdb buffer window is created by emacs, and you will see the (gdb) prompt. Set a breakpoint (if not already provided by your .gdbinit file), and type r <Enter> to run the program. When the program stops, a second emacs buffer window will be created containing the source code with a pointer ``=>'' indicating the next line of code to be executed. This is your first breakpoint.
In the source display window within emacs, a breakpoint can be set for the line containing the cursor by typing C-x <space>.