Yasir Saleem
Yasir Saleem

Reputation: 155

macOS 10.15 Catalina gdb problem for C++ Debugging in Eclipse

I am using macOS 10.15.2 Catalina and am trying to debug a Hello World C++ program in Eclipse. I have set up gdb debugger by installing it from Homebrew and signing the certificate by following the procedure in the below link.

https://www.thomasvitale.com/how-to-setup-gdb-and-eclipse-to-debug-c-files-on-macos-sierra/

The debugger does not get starts.

I have set gdb settings in the Eclipse as mentioned in the below screenshot. GDB setting in Eclipse

When I debug the project, I am getting error: Configuring GDB Aborting configuring GDB (its screenshot is also provided below).

enter image description here

Upvotes: 6

Views: 2399

Answers (2)

Juan Pablo Leon
Juan Pablo Leon

Reputation: 41

I faced a similar problem, and I had to do two steps to fix it. I'm not sure if they are both needed or not:

  1. Make sure your debug configuration has an absolute path to .gdbinit. You need to have a .gdbinit file in your user folder with the following content:
set startup-with-shell off

My debug configuration in eclipse pointed to this file, but it wasn't reading it until I changed the path to be absolute.

  1. Set up the permissions with extra entitlements like the ones from this guide: https://www.thomasvitale.com/how-to-setup-gdb-and-eclipse-to-debug-c-files-on-macos-sierra/

Create a gdb-entitlement.xml file with the following content:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
    "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
        <key>com.apple.security.cs.allow-jit</key>
        <true/>
        <key>com.apple.security.cs.allow-unsigned-executable-memory</key>
        <true/>
        <key>com.apple.security.cs.allow-dyld-environment-variables</key>
        <true/>
        <key>com.apple.security.cs.disable-library-validation</key>
        <true/>
        <key>com.apple.security.cs.disable-executable-page-protection</key>
        <true/>
        <key>com.apple.security.cs.debugger</key>
        <true/>
        <key>com.apple.security.get-task-allow</key>
        <true/>
    </dict>
    </plist>

Then, open your Terminal prompt, go to the directory where you saved the xml file and run:

codesign --entitlements gdb-entitlement.xml -fs gdb-cert $(which gdb)

Where "gdb-cert" is the certificated you created before for code signing. After those steps and setting the GDB path correctly on Eclipse, debugging worked again.

Upvotes: 4

Thomas Vitale
Thomas Vitale

Reputation: 1808

Which versions of gdb and Eclipse are you using?

I'll try to mention some aspects with which I had problems in the past.

  1. In case you installed gdb with Homebrew, try setting the "GDB debugger" field to the actual path, something like /usr/local/Cellar/gdb/8.3/bin/gdb instead of the link /usr/local/bin/gdb.

  2. Where is your .gdbinit file located? In the tutorial, it is located in the user home folder, so in the Eclipse debug configuration the GDB command file is set to ~/.gdbinit. The value in your screenshot doesn't specify an absolute path, it might be looking for it in the wrong place.

  3. Is your gdb certificate part of the System Keychain (rather than the login Keychain)? During the signing have you passed the entitlements file as argument?

Upvotes: 4

Related Questions