There are two ways you can install GDB on your linux machine.
Codesign gdb using your certificate: codesign -fs gdbc /usr/local/bin/gdb; Shut down your mac and restart in recovery mode (hold down command-R until apple logo appears) Open terminal window; Modify System Integrity Protection to allow debugging: csrutil enable -without debug; Reboot your Mac. Debugging with gdb should now work as expected.
1. Install pre-built gdb binaries from verified distribution resources
You can install gdb on Debian-based linux distro (e.g. Ubuntu, Mint, etc) by following command.
$ sudo apt-get update
$ sudo apt-get install gdb
2. Download source code of GDB, compile it and install.
Step-1: Download source code.
You can download source code of all release from http://ftp.gnu.org/gnu/gdb/
$ wget 'http://ftp.gnu.org/gnu/gdb/gdb-7.11.tar.gz'
Step-2: Extract it
$ tar -xvzf gdb-7.11.tar.gz
Step-3: Configure and Compile it.
$ cd gdb-7.11This step will take a bit of time. So you can sit back and have cup of coffee for a while.
Once it is completed, you can locate gdb binary located at gdb-7.11/gdb/gdb
Step-4: Install GDB.
$ make install By default this will install gdb binaries in /usr/local/bin and libs in /usr/local/lib
Congratulation, you have successfully compiled and installed GDB.
Once you installed GDB, you can print GDB version to test whether it is installed correctly.
$ gdb --version
Question or issue on macOS:
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:)
How to solve this problem?
Solution no. 1:
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.1in 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
makeand wait again (which can take some time)
sudo make install
Gdb Download Mac Yosemite
Now gdb is installed at /usr/local/bin/
Solution no. 2:
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.
Solution no. 3:
You can also use homebrew to get gdb in mac os: