If you don't have it installed, open your Terminal prompt and write this command: /usr/bin/ruby -e '$(curl -fsSL )' The easiest way to install gdb is by using Homebrew: 'the missing package manager for macOS'.
Starting from Mavericks (macOS 10.9), there are several steps to follow to make it work.
Using gdb debugger on macOS is no longer straightforward since Xcode stopped using it and replaced it with lldb.