问题
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.
When I debug the project, I am getting error: Configuring GDB Aborting configuring GDB
(its screenshot is also provided below).
回答1:
Which versions of gdb and Eclipse are you using?
I'll try to mention some aspects with which I had problems in the past.
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
.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.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?
回答2:
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:
- 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.
- 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.
来源:https://stackoverflow.com/questions/59393100/macos-10-15-catalina-gdb-problem-for-c-debugging-in-eclipse