--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
|   blog   |   blog_archive   |   about   |   contact   |   tutoring   |
--------------------------------------------------------------------------------

uelen's GDB cheatsheet

Getting Started

If you've never run GDB before, you can start it up with the following command:
gdb <program>

If you've been compiling to a.out then you'd start GDB up with
gdb ./a.out

Make sure to add the -g flag when compiling your program! This would look something like
g++ -g my_program.cpp

And here's some conventions I'm using:

Some Tips

There's a few tricks I've learned that make GDB easier to use. First of all, you don't actually need to type out the full command name to run a command. You can type the first few characters of a command, or potentially even a single character. This means instead of typing layout you can type lay, and instead of typing break you can type b.

Sometimes you want to run the same command a bunch of times in a row. Typing next a bunch of times is a pain. However, if you enter an empty command and just hit Enter then GDB will repeat the last command. Instead of typing next a bunch of times, you can type it a single time and then repeatedly hit the Enter key.

The Commands

Debugging Assembly

This work is licensed under the Creative Commons Attribution-ShareAlike 4.0 International License. If you're interested in modifying this document you can obtain the original markdown at https://finzdani.net/gdb.md