Troubleshoot gdb prompt signature error on Mac

Source: Internet
Author: User
Tags install brew install homebrew

Troubleshoot gdb prompt signature error on Mac


Please keep this link for the original power reprint.


Installing GDB


The new Mac has GCC, g++, but no gdb


Some say that installing Xcode is there. But I really don't.


Install via homebrew, no run Install brew command


Ruby-e "$ (curl-fsslk https://raw.github.com/Homebrew/homebrew/go/install)"


Then install GDB


Brew Install HTTPS://RAW.GITHUB.COM/HOMEBREW/HOMEBREW-DUPES/MASTER/GDB.RB


Or


Brew Install Homebrew/dupes/gdb


I used the latter.




Signature issues


Install GDB. Write a Hello gdb!


Hello.cpp


#include <iostream>




using namespace Std;




int main (int argc, char **argv)


{


cout << "Hello gdb!" << Endl;


return 0;


}


Compiling links


>g++-g-o Hello Hello.cpp


Start debugging


>gdb Hello




>run


Starting program:/users/username/ws/hello


Unable to find Mach task port for Process-id 358: (Os/kern) Failure (0x5).


(Please check that GDB is Codesigned-see taskgated (8))


Hint above GDB signature error.




Reason


Darwin Kernel For security reasons, in the absence of special authorization to disagree with GDB debugging whatever program, because the ability to debug control of the process. Just assume that the root user does not have this problem, but who would like to use root to debug the program.


Solve


A frequently used workaround is to give GDB a code signing right that the system fully trusts. to other processes.




First, you need to create a system code signing trust certificate:


Launch the Keychain Access app (/applications/utilities/keychain Access.app)
Open Menu: Keychain Access-"certificate assistant-" Create a certificate ...
Enter the name of the certificate, such as: Gdb-cert;
Select identity type: Self-signed root certificate (identity type to signed root)
Select certificate Type: Code signature (Certificate type to code Signing)
TICK: Let me override these default signatures (select the Let me override defaults)
Continue until you choose to store the certificate address. Select: System
The certificate is created, and the certificate is set to define its own trust
Right-click the Gdb-cert certificate you just created, select "Show Simple Introduction" (Get Info)
Click "Trust". Displays the trust options that you can define yourself
"Code Signing" select "Always Trust" (Code Signing
Second, grant the certificate to GDB and run the command


>codesign-s Gdb-cert/path to GdB


Note that you need to exit the Keychain Access application, or restart the system


View/path to GDB. Run command


>which GDB


Well, the above gives GDB the system Trust code signing certificate, can use GDB normally


Please keep this link for the original power reprint.

Troubleshoot gdb prompt signature error on Mac

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.