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:)
As with GCC, the easiest way to install GDB is through Homebrew. In a Terminal window, run the command brew install gdb , and wait for it to complete. (As usual, it may ask for your password.) Now, we need to code-sign the GDB executable, so it will be allowed to control other processes, as necessary for a debugger.
I just installed it (gdb 8.0) following this procedure as of today, it works on Mac OS High Sierra 10.13. 2 (17C88). For the latest version "brew install gdb" is fine. However, the steps above will allow you to install older versions which is handy.
If you have installed gdb as explained before (using Homebrew), the path should be: /usr/local/Cellar/gdb/version/bin/gdb (replace version with the actual version of your gdb installation, e.g. /usr/local/Cellar/gdb/8.3/bin/gdb).
download the most recent GDB from https://www.sourceware.org/gdb/download/
expand the gdb-7.12.1.tar.xz file: tar xopf gdb-7.12.1.tar.xz
cd gdb-7.12.1
in terminal to open the gdb folder
then follow the instructions in the README file in the gdb folder, or simply follow the following steps:
./configure
, wait for the terminal
make
and wait again (which can take some time)
sudo make install
Now gdb is installed at /usr/local/bin/
Note 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With