Difference between revisions of "GDB on OS X Mavericks or newer and Xcode 5 or newer"
From Free Pascal wiki
Jump to navigationJump to searchJwdietrich (talk | contribs) (Categorization) |
Jwdietrich (talk | contribs) (Categorization) |
||
Line 137: | Line 137: | ||
[[Category:Mac OS X]] | [[Category:Mac OS X]] | ||
[[Category:Install]] | [[Category:Install]] | ||
+ | [[category:Debugging]] |
Revision as of 09:30, 13 November 2013
Overview
This page explains how to build and install gdb on OS X using the simple homebrew distribution.
Since OS X Mavericks 10.9, Xcode 5 no longer installs gdb by default and not globally.
For general notes about installing FPC and Lazarus on OS X see Installing Lazarus on MacOS X.
About using gdb see GDB Debugger Tips.
homebrew installieren
Open a Terminal and install homebrew:
ruby <(curl -fsSkL raw.github.com/mxcl/homebrew/go)
Here is an example output:
mattias@mac:~$ ruby <(curl -fsSkL raw.github.com/mxcl/homebrew/go) ==> This script will install: /usr/local/bin/brew /usr/local/Library/... /usr/local/share/man/man1/brew.1 ==> The following directories will be made group writable: /usr/local/. /usr/local/bin /usr/local/lib /usr/local/share /usr/local/share/doc ==> The following directories will have their group set to admin: /usr/local/. /usr/local/bin /usr/local/lib /usr/local/share /usr/local/share/doc Press ENTER to continue or any other key to abort ==> /usr/bin/sudo /bin/chmod g+rwx /usr/local/. /usr/local/bin /usr/local/lib /usr/local/share /usr/local/share/doc WARNING: Improper use of the sudo command could lead to data loss or the deletion of important system files. Please double-check your typing when using sudo. Type "man sudo" for more information. To proceed, enter your password, or type Ctrl-C to abort. Password: ==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/. /usr/local/bin /usr/local/lib /usr/local/share /usr/local/share/doc ==> Installing the Command Line Tools (expect a GUI popup): ==> /usr/bin/sudo /usr/bin/xcode-select --install xcode-select: note: install requested for command line developer tools Press any key when the installation has completed. ==> Downloading and installing Homebrew... remote: Finding bitmap roots... remote: Counting objects: 136798, done. remote: Compressing objects: 100% (45940/45940), done. remote: Total 136798 (delta 94648), reused 131779 (delta 89816) Receiving objects: 100% (136798/136798), 25.15 MiB | 738.00 KiB/s, done. Resolving deltas: 100% (94648/94648), done. From https://github.com/mxcl/homebrew * [new branch] master -> origin/master HEAD is now at 55d2970 play/sox conflict ==> Installation successful! You should run `brew doctor' *before* you install anything. Now type: brew help
Install gdb
brew install https://raw.github.com/Homebrew/homebrew-dupes/master/gdb.rb
Here is an example output:
mattias@mac:~$ brew install https://raw.github.com/Homebrew/homebrew-dupes/master/gdb.rb ######################################################################## 100,0% ==> Installing gdb dependency: readline ==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/readline-6.2.4.maveri ######################################################################## 100,0% ==> Pouring readline-6.2.4.mavericks.bottle.1.tar.gz ==> Caveats This formula is keg-only: so it was not symlinked into /usr/local. OS X provides the BSD libedit library, which shadows libreadline. In order to prevent conflicts when programs look for libreadline we are defaulting this GNU Readline installation to keg-only. Generally there are no consequences of this for you. If you build your own software and it requires this formula, you'll need to add to your build variables: LDFLAGS: -L/usr/local/opt/readline/lib CPPFLAGS: -I/usr/local/opt/readline/include ==> Summary /usr/local/Cellar/readline/6.2.4: 31 files, 1,6M ==> Installing gdb ==> Downloading http://ftpmirror.gnu.org/gdb/gdb-7.6.1.tar.bz2 ######################################################################## 100,0% ==> ./configure --prefix=/usr/local/Cellar/gdb/7.6.1 --with-system-readline --with-python= ==> make ==> make install ==> Caveats gdb requires special privileges to access Mach ports. You will need to codesign the binary. For instructions, see: http://sourceware.org/gdb/wiki/BuildingOnDarwin ==> Summary 🍺 /usr/local/Cellar/gdb/7.6.1: 27 files, 5,0M, built in 105 seconds
The new gdb does not run yet. You will get the error:
The GDB command: „-exec-run“ returned the error: „,msg=„Unable to find Mach task port for process-id 62593: (os/kern) failure (0x5). (please check gdb is codesigned - see taskgated(8))““
Codesigning gdb
You need to create a certificate and sign gdb:
- Open application “Keychain Access” (/Applications/Utilities/Keychain Access.app)
- Open menu /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 “Continue”.
- You might want to extend the predefined 365 days period to 3650 days.
- Click several times on “Continue” until you get to the “Specify a Location For The Certificate” screen, then set “Keychain to System”.
- If you can't store the certificate in the “System” keychain, create it in the “login” keychain, then export it. You can then import it into the “System” keychain.
- In keychains select “System”, and you should find your new certificate. Use the contextual menu for the certificate, select “Get Info”, open the “Trust” item, and set “Code Signing” to “Always Trust”.
- You must quit “Keychain Access” application in order to use the certificate and restart “taskgated” service by killing the current running “taskgated” process. Alternatively you can restart your computer.
Finally you can sign gdb:
codesign -s gdb-cert /usr/local/bin/gdb
At first use you will be asked for password.