Besides things that have already been posted i also use:

  • a .gdbinit file for STL containers
  • signal SIGNAL noprint nostop for some custom signals that are of no real interest when debugging
  • C-Casts to dereference pointers
  • catchpoints (catch throw, catch catch)
  • condition for conditional break- and watchpoints
  • rarely gdbserver for remote debugging
  • gdb program coredump, for those embarassing segfaults ;)

PS: One reason i personally love gdb btw. is that it supports tab-completion for nearly everything (gdb commands, symbols in the symbol table, functions, memberfunctions etc.). This is a fairly good productivity boost in my opinion.

🌐
GeeksforGeeks
geeksforgeeks.org › c language › gdb-step-by-step-introduction
GDB (Step by Step Introduction) - GeeksforGeeks
January 10, 2025 - Here are a few useful commands to get started with GDB. Now, type "l" at gdb prompt to display the code. ... Let's introduce a break point, say line 5.
🌐
Stanford University
web.stanford.edu › class › cs107 › resources › gdb
CS107 GDB and Debugging
See the bottom of the page for more resources to help you master gdb. Compiling for gdb: gcc does not automatically put debugging information into the executable program, but our Makefiles all include the -g -Og flags that give gdb information about our programs so we can use the debugger efficiently.
Discussions

c++ - How do you use gdb? - Stack Overflow
Bring the best of human thought and AI automation together at your work. Explore Stack Internal ... I decided to find out how our C/C+ *nix practitioners use the gdb debugger. More on stackoverflow.com
🌐 stackoverflow.com
C programming: How to use gdb with Makefile and command line arguments? - Stack Overflow
Find centralized, trusted content ... you use most. Learn more about Collectives ... Connect and share knowledge within a single location that is structured and easy to search. Learn more about Teams ... My program incorporates a command line argument, thus the "name.ged". Whenever I run gdb after getting ... More on stackoverflow.com
🌐 stackoverflow.com
Properly Learning GDB
A course would be overkill. Look for a cheat sheet, then use it to do some actual debugging. You'll find yourself looking up specific things and soon enough you will have explored everything. I will say, if you're on windows, I'd strongly suggest using the rad debugger (shameless self plug) by epic games / rad tools. It's on GitHub. More on reddit.com
🌐 r/C_Programming
21
46
December 10, 2024
A quick intro to gdb.
This Red Hat Tutorial learns you the finer points. More on reddit.com
🌐 r/C_Programming
4
40
May 28, 2023
People also ask

Why do I need to compile my code with the -g flag to use GDB?
In GDB, the -g flag tells your compiler to include extra debugging information in your program’s executable file. This information, such as variable names, function names and source code line numbers, is what GDB uses to provide a detailed, source-level debugging experience. Without it, GDB can’t show you what’s happening inside your program in a human-readable way.
🌐
builtin.com
builtin.com › software-engineering-perspectives › how-to-use-gdb
How to Use the GNU Debugger (GDB) | Built In
What is the difference between step and next in GDB?
Both commands execute the next line of code in GDB, but they handle function calls differently. The step command will “step into” a function call, pausing execution at the very first line of the function. The next command will “step over” a function, executing the entire function at once and pausing at the next line in the current function.
🌐
builtin.com
builtin.com › software-engineering-perspectives › how-to-use-gdb
How to Use the GNU Debugger (GDB) | Built In
My program crashed, can GDB help me figure out why?
Yes, GDB is an effective tool for this. When a program crashes, you can use the backtrace (or bt) command to see the sequence of function calls that led to the crash. This shows you the call stack at the moment of the failure, helping you find the exact line of code where the error occurred.
🌐
builtin.com
builtin.com › software-engineering-perspectives › how-to-use-gdb
How to Use the GNU Debugger (GDB) | Built In
🌐
Reddit
reddit.com › r/c_programming › a quick intro to gdb.
r/C_Programming on Reddit: A quick intro to gdb.
May 28, 2023 -

GDB Quick Guide

I found out I didn't need cgdb by the way, it was better to just gdb -tui on Debian. Less modem noise in the form of uninterpreted escape sequences too.

So it paid up to do gdb -help.

The guide doesn't mention watch or watch -l but it points to Debugging with GDB where you can find everything.

It is a good quick start, with a couple of examples.

🌐
The Ohio State University
u.osu.edu › cstutorials › 2018 › 09 › 28 › how-to-debug-c-program-using-gdb-in-6-simple-steps
How to Debug C Program using gdb in 6 Simple Steps
September 28, 2018 - Note: The above command creates a.out file which will be used for debugging as shown below. Launch the C debugger (gdb) as shown below. ... Places break point in the C program, where you suspect errors. While executing the program, the debugger will stop at the break point, and gives you the prompt to debug.
🌐
Built In
builtin.com › software-engineering-perspectives › how-to-use-gdb
How to Use the GNU Debugger (GDB) | Built In
Create a company profile. ... GDB, short for GNU Debugger, is a debugger tool used to inspect a program’s internal state while it is running, allowing users to find and fix bugs in languages such as C, C++, Ada, Go and Fortran.
Published   September 18, 2025
Find elsewhere
🌐
Caltech
users.cms.caltech.edu › ~mvanier › CS11_C › misc › gdb.html
CS 11 C track: Using gdb for debugging
It’s a good habit to always use these options.) The -g option puts debugging information into the executable. Most importantly, it puts the text of the source code file into the executable so you can examine it as the program executes (we’ll see how below). Type gdb myprog (for the example ...
🌐
Baylor
cs.baylor.edu › ~donahoo › tools › gdb › tutorial.html
How to Debug Using GDB
We quit GDB with the quit command. Next we need to change the following line: int fact = 1; Recompile the code and run it, you will get the expected output. This program causes a core dump due to a segmentation fault. We will try to trace the reason for this core dump. Download the program, from here. 1. Compile the program using the following command. ... 3. The core dump generates a file called corewhich can be used for debugging.
🌐
TutorialsPoint
tutorialspoint.com › gnu_debugger › gdb_quick_guide.htm
GDB - Quick Guide
An ANSI-compliant C compiler (gcc is recommended - note that gdb can debug codes generated by other compilers) 115 MB of free disk space is required on the partition on which you're going to build gdb. 20 MB of free disk space is required on the partition on which you're going to install gdb. ... The make utility - the GNU version is known to work without a problem, others probably do as well. step 2: Download the gdb source distribution from ftp.gnu.org/gnu/gdb. (We used gdb-6.6.tar.gz for these instructions.)
🌐
UTK
web.eecs.utk.edu › ~bvanderz › teaching › cs140Sp18 › gdb › gdb.html
How to Use gdb
Start by copying the files in ~bvz/cs140/gdb to your directory and then typing make. make should compile the sample files in your directory into executables. ... ./names_list names_list prompts the user for five names and prepends the names to a list. The list starts with a sentinel node.
🌐
Visual Studio Code
code.visualstudio.com › docs › cpp › cpp-debug
Debug C++ in Visual Studio Code
November 3, 2021 - When attached to a process with GDB, break-all will end the process. ... Configure C/C++ debugging - Learn about additional debugger configuration options. Basic Editing - Learn about the powerful Visual Studio Code editor. Code Navigation - Move quickly through your source code. Tasks - use tasks to build your project and more.
🌐
University of Michigan
web.eecs.umich.edu › ~sugih › pointers › summary.html
GDB Tutorial
This is a brief description of some of the most commonly used features of gdb. To prepare your program for debugging with gdb, you must compile it with the -g flag. So, if your program is in a source file called memsim.c and you want to put the executable in the file memsim, then you would ...
🌐
Cprogramming
cboard.cprogramming.com › c-programming › 181159-how-debug-every-instruction-code.html
How to debug every instruction of the code ?
August 7, 2022 - Is it a complete IDE, SDK or plugin ? ... GDM is Gnome Display Manager, but I am pretty sure you meant 'GDB' both times and that 'GDM' was just a typo. Gnu Debugger (GDB) is the standard debugger for Binutils and GCC, and is included with most Linux distros by default, as well as being included with MinGW.
🌐
UCSD
cseweb.ucsd.edu › classes › fa09 › cse141 › tutorial_gcc_gdb.html
Tutorial of gcc and gdb
For example, if we want to break at the beginning of main function in garbage.c, we can also try below: (gdb) break *0x1f7b Breakpoint 1 at 0x1f7b: file garbage.c, line 8. To show the current breakpoints we have, we may use the "info breakpoint" command as:
🌐
University of Toronto
cs.toronto.edu › ~krueger › csc209h › tut › gdb_tutorial.html
gdb tutorial
In order to run crash.c with gdb, we must compile it with the -g option which tells the compiler to embed debugging information for the debugger to use.
🌐
GNU Project
sourceware.org › gdb › current › onlinedocs › gdb
Debugging with GDB
GDB can do four main kinds of things (plus other things in support of these) to help you catch bugs in the act: Start your program, specifying anything that might affect its behavior. Make your program stop on specified conditions. Examine what has happened, when your program has stopped.
🌐
Suchprogramming
suchprogramming.com › debugging-with-gdb-part-1
Such Programming - Debugging C Programs with GDB – Part 1
February 21, 2018 - To provide more information to the debugger about this program I’ll use the -g flag when building it. # Makefile CC=gcc -g -o $@ -Wall $< all: test test: test.c $(CC) debug: test gdb -q ./test
🌐
HowtoForge
howtoforge.com › home › how to debug c programs in linux using gdb
How to Debug C Programs in Linux using gdb
For example, in case of the gcc compiler, which we'll be using to compile the example C program later in this tutorial, you need to use the -g command line option while compiling your code. To know what the gcc compiler's manual page says about this command line option, head here. Next step is to make sure that you have GDB installed on your system.