108

I went to use GDB in OS X v10.9 (Mavericks), and it's not there. Where has it gone?

# /usr/lib/gdb
-bash: /usr/bin/gdb: No such file or directory
# gdb
-bash: gdb: command not found

I also launched Xcode 5.0.1:

Preferences > Downloads

..and there's no longer command line tools available — ffs!

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
l'L'l
  • 44,951
  • 10
  • 95
  • 146
  • Command line tools are available, at https://developer.apple.com/downloads/index.action?name=for%20Xcode%20-# To get there, from XCode go to XCode > Open Developer Tool > More Developer Tools... – Parker Nov 18 '13 at 07:19
  • EDIT: Doesn't matter, as GDB is absent from command line tools as well... – Parker Nov 18 '13 at 07:48
  • 3
    Since I asked this question many people have asked what ./configure options I used to get this working: `./configure --prefix=/usr/local --enable-targets=x86_64-apple-darwin13.0.0 --enable-64-bit-bfd --disable-werror --build=x86_64-apple-darwin13.0.0 --host=x86_64-apple-darwin13.0.0 --target=x86_64-apple-darwin13.0.0` – l'L'l Jan 07 '14 at 18:08

12 Answers12

143

gdb has been replaced by lldb, and is no longer supported. gcc and llvm-gcc are also gone, replaced by clang.

kenorb
  • 155,785
  • 88
  • 678
  • 743
Catfish_Man
  • 41,261
  • 11
  • 67
  • 84
  • 2
    is there a way to use gdb though still? – l'L'l Oct 24 '13 at 00:39
  • Not that I'm aware of. You could build it yourself (say, via homebrew), but I don't know how well that would work. – Catfish_Man Oct 24 '13 at 01:43
  • Hi Mr. Catfish, I got it to work. It just required compiling it from source with the correct ./configure command :) thx! – l'L'l Oct 24 '13 at 06:23
  • 2
    I'm also curious about the ./configure. I built using the default settings and everything works except for attaching to live processes. The symbols are wrong and it crashes when I ctrl-C. – RawwrBag Oct 28 '13 at 20:32
  • 1
    I installed via brew, and keep getting "_____: not in executable format: File format not recognized" when I try to load an executable. Can anyone comment on how they got a successful install? – Parker Nov 18 '13 at 07:20
  • @GerardGrundy, sorry it took me so long to answer; i put my ./configure options in a comment of my original question. hopefully it helps you :) – l'L'l Jan 07 '14 at 18:37
  • @I'L'I I have reverted back to mountain loin as I use my mac for recording with protocols and mavericks is not compatible.thanks for your help. Once mavericks is more compatible I'll think about it in the future. – uplearned.com Jan 08 '14 at 11:12
  • I have gdb installed but want to add it to the list of debuggers in Xcode. How do I go about doing that? I only see lldb right now. – Translunar Jun 09 '14 at 15:38
  • @Parker: The "not in executable format: File format not recognized" error occurs when trying to use gdb with a universal (or fat) binary, which gdb does not support: http://stackoverflow.com/q/20553784/196844 – Daniel Trebbien Jul 23 '14 at 18:47
38

You can install it on Mavericks with Homebrew.

brew install homebrew/dupes/gdb
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Jakub Głazik
  • 893
  • 9
  • 13
  • `brew install dupx` keeps telling me `checking for gdb... no` – lajarre Nov 19 '13 at 11:50
  • 1
    This did not work for me on Maverics. Homebrew gave me an error and there seems to be quite a few open issues with the install. – Dan Bradbury Jan 10 '14 at 22:06
  • This almost worked for me, then complained that GDB wasn't properly signed (when I actually tried to debug something with it). – mpontillo Jan 21 '14 at 19:52
  • 1
    FYI: This worked for me. I guess different people are having different levels of difficulty with this. If you are able to install it, make sure you look [here](https://sourceware.org/gdb/wiki/BuildingOnDarwin) for signing instructions. – Neil Traft Jan 21 '14 at 21:24
  • 2
    I also got the signing error, but it got resolved when I ran sudo gdb target. – Vlad Lifliand Jan 24 '14 at 02:50
  • For signing, I ran through these instructions (as listed in the homebrew Caveats) and things now seem to work fine. http://sourceware.org/gdb/wiki/BuildingOnDarwin – jriggins Oct 22 '14 at 15:43
  • This didn't work for me on El Capitan. I was getting a prompt for username/password and failing authentication. I had to do the Brew instructions on this site: http://ntraft.com/installing-gdb-on-os-x-mavericks/ – Billy Jan 10 '16 at 20:48
  • @Billy the link is broken do you have another link somewhere? – user2635088 May 19 '16 at 14:37
  • @user2635088 Oh that's not good. Unfortunately I don't remember what was on the page anymore. Try the instructions on this page, it looks sorta familiar: http://digitizor.com/install-homebrew-osx-el-capitan/ – Billy May 24 '16 at 23:04
9

This Homebrew command works to install GDB tools on Mavericks:

brew install https://raw.github.com/Homebrew/homebrew-dupes/master/gdb.rb
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
xin
  • 161
  • 4
3

Thanks I'L'I. I used your ./configure options and worked like a charm. Next step is to tell OS X that we allow GDB to debug. This is done by creating a certificate through the keychain, export it and then sudo codesing -s gdb-cert /route/to/gdb, give credential and we are done.

See GDB wiki detailed instructions

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
user1008139
  • 191
  • 1
  • 2
2

I compiled GDB from the source in Maverics.

I altered the makefile (after ./configure) to suppress some errors that should have been warnings...(added the -Wno-string-plus-int)

Line 385:
CFLAGS = -g -O2 -Wno-string-plus-int

Line 388:
CXXFLAGS = -g -O2 -Wno-string-plus-int

Don't know if both are necessary.

But

As it turns out the standard version does not support debugging from .app files (as needed for Lazarus apps using the Carbon interface)

If you want to do it yourself follow this link: https://sourceware.org/gdb/wiki/BuildingOnDarwin

Dmitry
  • 13,797
  • 6
  • 32
  • 48
Ben
  • 21
  • 1
  • This probably won't work. I've tried in the past and the gdb produced could not debug apps. – jww Apr 12 '14 at 23:51
  • I was able to compile from source as well on Mavericks, after setting CFLAGS="-I /usr/local/include" so it picked up libintl.h. Don't forget to sign the code though, or gdb won't work. See http://ntraft.com/installing-gdb-on-os-x-mavericks/ for info on this. The end result of all this was successful debugging in NetBeans (my main reason for getting GDB). – Pete855217 Nov 20 '15 at 08:59
1

Follow the steps given at here, it is working fine:http://wiki.lazarus.freepascal.org/GDB_on_OS_X_Mavericks_and_Xcode_5

Mehul Thakkar
  • 12,440
  • 10
  • 52
  • 81
1

In my case I got it working on OS X with the following steps:

  1. Setup GDB Homebrew exactly like described here http://wiki.lazarus.freepascal.org/GDB_on_OS_X_Mavericks_and_Xcode_5

  2. Then set debugging to Dwarf2: Project -> Project Options.. Enter image description here

If Run/Build hangs up then restart computer (taskgated or some other process certificate most likely not authenticated), debugging settings back to "automatic (-g)" compile & run (authentication dialog appears & log in), then change debugging settings to "Dwarf2" and it should compile again

Try to always stop GDB when if it crashes after a run operation to prevent this authentication failure.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Evalds Urtans
  • 6,436
  • 1
  • 41
  • 31
0

You could install www.macports.org and install GDB. However, you'll have to wait for the MacPorts installer for Mavericks, as at the time of writing this it is not yet released.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
antonae
  • 11
  • 3
0

When I looked MacPorts WAS not yet available for Mavericks, but now it is!

Fink still isn't.

But the standard GDB still does not support debugging .app files.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Ben
  • 21
  • 1
-1

Run this to install command line tools:

xcode-select --install
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
  • 4
    CLT for OS X 10.9 Mavericks doesn't have GDB, that is the issue the OP is trying to solve. – Parker Nov 18 '13 at 07:49
-1

Command line utils isn't included in the new Xcode, but you can get it following these directions. (The Xcode select comment above didn't work for me.)

Open up Xcode

In the application menu item "Xcode", select Open Developer ToolMore Developer Tools...

This takes you to a site with a bunch of software. Go ahead and download and install "Command Line Tools (OS X Mavericks) for Xcode - Late October 2013".

(Credit to Jore https://discussions.apple.com/message/23513040#23513040)

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
George
  • 25
  • 2
-4

Install Mac OS X v10.8 (Mountain Lion) with Xcode 4.6 in a virtual machine and get fun )))

I use VMware Fusion, but you can try the free VirtualBox. You can get old versions of MacOS from AppStore and old version of Xcode from Apple Developer site.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131