gdb ./build/my_program
break main                 # breakpoint at a function
break file.cpp:123         # breakpoint at a source line
run arg1 arg2              # run with command-line arguments
next                       # execute next line, stepping over calls
step                       # execute next line, stepping into calls
continue                   # resume until a breakpoint
finish                     # run until current function returns
print variable             # inspect a variable
print *it                  # inspect the element referred to by an iterator
display variable           # print after every step
backtrace                   # show the call stack
frame 2                    # switch to stack frame 2
list                       # display nearby source
quit

Attach to a running process:

gdb -p <PID>