I'm having trouble to make a debugging for C ++ osx Yosemite (I tried different IDE and each of them gives a problem), I read on google install gdb with brew ... but nothing. with NetBeans, launch debugging, and in the console output I get the shell gdb:
GNU gdb (GDB) 7.8.1
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3 +: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
--- Type <return> to continue, or q <return> to quit ---
This GDB was configured as "x86_64-apple-darwin14.0.0".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
--- Type <return> to continue, or q <return> to quit ---
For help, type "help".
Type "apropos word" to search for commands related to "word".
(gdb)
I want to debug driven by using netbeans gui, step into, step over etc .... This is a configuration of netbeans:
And I also follwed this steps to install gdb:
http://ntraft.com/installing-gdb-on-os-x-mavericks/
Thanks
EDIT
debugging configuration on netbeans:
I had the same problem. That's what I did to fix it (under Yosemite):
Install brew
: http://brew.sh
Update brew
. If you already have installed brew
, 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
$ brew install gdb
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
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
field Debugger Command field
. Have you tired Codesigning the gdb executable?
The Darwin Kernel requires the debugger to have special permissions before it is allowed to control other processes. These permissions are granted by codesigning the GDB executable. Without these permissions, the debugger will report error messages such as:
Starting program: /x/y/foo Unable to find Mach task port for process-id 28885: (os/kern) failure (0x5). (please check gdb is codesigned - see taskgated(8))
Codesigning requires a certificate. The following procedure explains how to create one:
- Start the Keychain Access application (in /Applications/Utilities/Keychain Access.app)
- Select the Keychain Access -> Certificate Assistant -> Create a Certificate... menu
- Then:
- Choose a name for the new certificate (this procedure will use "gdb-cert" as an example)
- Set "Identity Type" to "Self Signed Root"
- Set "Certificate Type" to "Code Signing"
- Activate the "Let me override defaults" option
- Click several times on "Continue" until the "Specify a Location For The Certificate" screen appears, then set "Keychain" to "System"
- Click on "Continue" until the certificate is created
- Finally, in the view, double-click on the new certificate, and set "When using this certificate" to "Always Trust"
- Exit the Keychain Access application and restart the computer (this is unfortunately required)
Once a certificate has been created, the debugger can be codesigned as follow. In a Terminal, run the following command...
codesign -f -s "gdb-cert" <gnat_install_prefix>/bin/gdb
... where "gdb-cert" should be replaced by the actual certificate name chosen above, and should be replaced by the location where you installed GNAT.
Source: https://gcc.gnu.org/onlinedocs/gcc-4.8.1/gnat_ugn_unw/Codesigning-the-Debugger.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.