I found that there was no GDB pre-installed inside the macOS (was called OSX) since very long time ago. So this article is talking about how to install GDB in macOS Sierra.
First, you need to install homebrew
Then, install gdb by typing
brew install gdb
or
sudo brew install gdb
But if you are using gdb right now to debug your code, you will find that the terminal will tell you:
Error message from debugger back end: Unable to find Mach task port for process–id 46234: (os/kern) failure (0x5). (please check gdb is codesigned – see taskgated(8)
That is because you haven’t code-sign your own installed gdb yet, so here are two ways to do it.
- Code-sign your own gdb.
- Let superuser do the job, so it will jump through this certification.
For the solution two, just type:
sudo gdb
and it will solve your problem.
Also, you can edit your bash profile or zsh profile to add the alias
alias gdb=”sudo gdb”
then there is no need to type sudo every time, but if you want it to be safe, you can do type sudo every time.
I was pretty pleased to uncover this web site. I wanted to thank
you for your time for this particularly wonderful read!!
I definitely loved every bit of it and i also have you book-marked
to check out new stuff in your website.
Excellent!
thank you
thanks a lot..
gdb vs llvm usage – bbkim_lab
[…] I followed steps to install and set keychain for using gdb in mac os. After setting process, It still has additional problem to solve. I give up to solve this problem […]
Maybe you can just type sudo gdb to test if this works.