How I can install GDB in NetBeans in Mavericks for debugging?
I have an error when I debug a C program in NetBeans.
GDB has unexpectedly stopped with return 127
Here is a screenshot of the build tools:
Solution 1:
That's what I did to install GDB (under Yosemite):
Install
brew
: http://brew.shUpdate
brew
. If you already have installedbrew
, check for updates. In the terminal:
$ brew update
This step turned out to be decisive for me as, before updating, brew
did not find any gdb
package:
$ brew install gdb # Error: No available formula for gdb
And after that:
$ brew update
$ brew search | grep gdb # cgdb gdb gdbm pgdbf
- Install gdb:
$ brew install gdb
- Codesign the binary following these instructions: http://sourceware.org/gdb/wiki/BuildingOnDarwin I copy them here for the sake of completeness and to add some comments:
Creating a certificate
Start Keychain Access application (
/Applications/Utilities/Keychain Access.app
)Open menu
/Keychain Access/Certificate Assistant/Create a Certificate...
Choose a name (
gdb-cert
in the example), setIdentity Type
toSelf Signed Root
, setCertificate Type
toCode Signing
and select theLet me override defaults
. Click several times onContinue
until you get to theSpecify a Location For The Certificate
screen, then setKeychain
toSystem
.If you can't store the certificate in the
System
keychain, create it in thelogin
keychain, then exported it. You can then imported it into theSystem
keychain.Finally, using the contextual menu for the certificate, select
Get Info
, open theTrust
item, and setCode Signing
toAlways Trust
.You must quit Keychain Access application in order to use the certificate and restart
taskgated
service by killing the current running taskgated process (comment: for example withsudo pkill taskgated
or restarting).
And then
Giving gdb permission to control other processes
If the certificate is known as
gdb-cert
, just use:$ codesign -s gdb-cert gdb
Comment: if
gdb
is not found, then add the path where it was installed. In my case:$ codesign -s gdb-cert /usr/local/Cellar/gdb/7.10/bin/gdb
- Use either
gdb
or the path where gdb was installed (for example,/usr/local/Cellar/gdb/7.10/bin/gdb
) in the menu/Netbeans/Preferences/C/C++/Build Tools
fieldDebugger Command field
.