I searched online about how to install gdb on macOS Sierra 10.12.2 but failed on the methods I could find. Then I figure out the following way which is easy and works fine on my machine. hope it may help you too:)
24 Answers
download the most recent GDB from
expand the gdb-7.12.1.tar.xz file:
tar xopf gdb-7.12.1.tar.xzcd gdb-7.12.1in terminal to open the gdb folderthen follow the instructions in the README file in the gdb folder, or simply follow the following steps:
./configure, wait for the terminalmakeand wait again (which can take some time)sudo make install
Now gdb is installed at /usr/local/bin/
8Note that you might want to try/use LLDB (lldb) instead. This is now the default (don't know about 10.12, but on 10.13 it is installed, when you install the Xcode utilities). It even comes with a nice curses GUI, but otherwise a shell very similar to GDB.
You can also use homebrew to get gdb in mac os:install-gdb-macos-sierra
3Surprised no one mentioned:
brew install gdb 1