GDB

From FEAP Wiki
Revision as of 00:18, 26 November 2020 by S g (talk | contribs) (→‎GDB Installation on MAC.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

GDB Installation on MAC.

If you use BREW to manage packages on the Mac, then here are the instruction for getting gdb to work (these are for Catalina and above, but may work for other OS versions).

  1. First install gdb brew install gdb ; if you are not using brew, you can still use the instructions below to codesign your version of gdb, no matter how you got it.
  2. Go to https://sourceware.org/gdb/wiki/PermissionsDarwin and carefully follow the instructions: 1.1, 1.2, 1.3.1, 1.3.2 (here create the file and use the first codesign command given, then skip to 1.4), 1.4. Note in step 1.1 when it says click Continue you should look at the screens and when you see the one for how many days the certificate will be good for change to something like 3000.

Your gdb should now function.

Short archive of the linked site's instructions
  • Start Keychain Access application (/Applications/Utilities/Keychain Access.app)

Open the menu item /Keychain Access/Certificate Assistant/Create a Certificate...

Choose a name (gdb-cert in the example), set Identity Type to Self Signed Root, set Certificate Type to Code Signing and select the Let me override defaults. Click several times on Continue until you get to the Specify a Location For The Certificate screen, then set Keychain to System.

  • Start Keychain Access again. Using the contextual menu for the certificate, select Get Info, open the Trust item, and set Code Signing to Always Trust.

Finally, quit the Keychain Access application once more to refresh the certificate store.

  • Create a gdb-entitlement.xml file containing the following:
<?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>
  • If the certificate you generated in the previous section is known as gdb-cert, use:

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

  • Run sudo killall taskgated