Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 978
Yasir Saleem Avatar asked Dec 18 '19 13:12

Yasir Saleem


People also ask

How do I get GDB to work on my Mac?

As with GCC, the easiest way to install GDB is through Homebrew. In a Terminal window, run the command brew install gdb , and wait for it to complete. (As usual, it may ask for your password.) Now, we need to code-sign the GDB executable, so it will be allowed to control other processes, as necessary for a debugger.

Does GDB work on Mac?

I just installed it (gdb 8.0) following this procedure as of today, it works on Mac OS High Sierra 10.13. 2 (17C88). For the latest version "brew install gdb" is fine. However, the steps above will allow you to install older versions which is handy.

How do I debug in eclipse Mac?

1.4. To debug your application, select a Java file with a main method. Right-click on it and select Debug As Java Application. If you started an application once via the context menu, you can use the created launch configuration again via the Debug button in the Eclipse toolbar.

Do you have to install GDB on Mac?

If you don't already have gdb on your system, then you'll need to install it. I'm going to show you how to install gdb by using Homebrew. If you have gdb on your system already, you can skip to the Generate a certificate step. If you received an error, then you'll need to install gdb using Homebrew.


2 Answers

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?

like image 69
Thomas Vitale Avatar answered Oct 21 '22 10:10

Thomas Vitale


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.

like image 29
Juan Pablo Leon Avatar answered Oct 21 '22 10:10

Juan Pablo Leon