With the arrival of MacOS X Mavericks, and the new XCode tools (5.x), gdb is no longer supplied with XCode and debugging under Lazarus is broken ... (thanks Apple we really appreciate that fucked up move!)
Alternative tricks include copying the gdb from an older XCode, but serious issue have been reported with that - and in the end the best option would be that Apple brings gdb back or that the Lazarus team starts using lldb (the debugger Apple now seems to favor). The implementation however in Lazarus is far from trivial ... again: Thank you Apple! You're making it harder and harder to develop for your platforms ...
ruby -e "$(curl -fsSkL raw.github.com/mxcl/homebrew/go)"
followed by:
brew doctor
* this might state that XQuartz is missing or outdated(2.7.5 is needed for Mavericks) - install it from the XQuartz website. After downloading and installing, run brew doctor again.
If all went well, the message "Your system is ready to brew." should appear.
Next step is to install gdb:
brew install homebrew/dupes/gdb
This will take a little bit and installs gdb.
Next we need to certify gdb which is done as such (source):
Start the "Keychain Access" application (found in "Applications" - "Utilities") and open the "Keychain Access" menu (far left) and choose "Certificate Assistant" - "Create a Certificate...".
Enter a recognizable name (for example "gdb cert"),
make sure "Identity Type" is set to "Self Signed Root",
set "Certificate Type" to "Code Signing" and
check the option "Let me override defaults".
Click several 9 times the "Continue" button until you get to the "Specify a Location For The Certificate" screen, where you set "Keychain" to "System" and click "Create", enter your password in the popup and finally click "Done".
Next in the Keychain window, select "System" under "Keychains" and find your newly made Certificate (find by the name you just entered where the "kind" field says "certificate"). Right click it and from the popup menu choose "Get Info".
Open the "Trust" section and set "Code signing" to "Always trust" - if you can't change this value, toggle "When using this certificate" to "Use System Defaults", you'll be able to edit this after that.
Now close the certificate and KeyChain and in a terminal window kill the "taskgated" task.
In my case I did:
ps -ax | grep taskgated
Which showed:
13 ?? 0:02.89 /usr/libexec/taskgated -s
41163 ttys001 0:00.00 grep taskgated
Here, in this example, we see that we want to kill task "13", which is likely a different number for your system, which we kill as such:
sudo kill -9 13
Now that we have a certificate, time to digitally sign gdb:
codesign -s "GDB Cert" /usr/local/bin/gdb
Here "GDB Cert" is the name you just used to create a certificate.
A popup wil ask for username and password.
Now start Lazarus and go to "Tools" - "Options" - "Debugger" - "General" and set "Debugger path and type" to "GNU Debugger (gdb)" and set the path to "/usr/local/bin/gdb".
Next for your project go to the menu "Project" - "Project Options ..." - "Compiler Options" - "Linking" and under "Debugging Info" set "Choose type of debug info" to "Dwarf with sets (-gw -godwarfsets)".
This - unpractical - trick should do the trick ... but it's far from ideal ...
If you run into the "Inappropriate ioctl for device" error, then the debugger cannot seem to find your executable. You can try to change the executable using the Lazarus menu "Run" - "Run Parameter" and set the Host Application correctly, which can be a pain if the full path has spaces in it ...