OS X v10.9(Mavericks)中缺少 GDB

我在 OS X v10.9(Mavericks)中使用了 GDB,但它不在那里。它去哪里了?

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

我还发布了 Xcode 5.0.1:

参考资料 > 下载

而且不再有可用的命令行工具!

98976 次浏览

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

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.

Run this to install command line tools:

xcode-select --install

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

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.

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)

You can install it on Mavericks with Homebrew.

brew install homebrew/dupes/gdb

This Homebrew command works to install GDB tools on Mavericks:

brew install https://raw.github.com/Homebrew/homebrew-dupes/master/gdb.rb

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

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.

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

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.