The GNU compiler collection has long been the underlying compiler, linker and debugger in Xcode, but in recent years, Apple has been moving toward a newer set of tools, the LLVM compiler Infrastructure: http://llvm.org/ The clang compiler (http://clang.llvm.org/) provided at least some part of the performance increase between the Leopard and Snow Leopard releases of Mac OS X.
Recently, lldb (http://lldb.llvm.org/ ) has become available as an alternative to the gdb debugger, but gdb is probably still the first choice.
Xcode includes a very sophisticated IDE for creating Macintosh applications. Its primary focus, however, is creating single large complicated applications (like GarageBand or iPhoto) rather than many simpler tools. Getting started with Xcode from a regular Unix Make environment is relatively difficult.
% xcode-select --install
One interesting option is -dump-tokens, which can be used like either of these commands:/Developer/usr/bin/../libexec/clang-cc --help
Other interesting options are -ast-dump. The -v option can be passed directly to the apple clang script, to show what it invokes and also be passed on to the real clang compiler.% /Developer/usr/bin/../libexec/clang-cc -I$antelope/include -dump-tokens dbcp.c % clang -Xclang -dump-tokens -I$ANTELOPE/include -c dbcp.c
Turn on malloc debugging with
See man libgmalloc for more info. Also look at CrashReporter Some other environment variables you might try setting:setenv DYLD_INSERT_LIBRARIES /usr/lib/libgmalloc.dylib
Inside gdb, use
set environment DYLD_INSERT_LIBRARIES /usr/lib/libgmalloc.dylib
otool can also help in other situations. Here's a report from a bus error on a Mac:
You can get a lot of potentially useful information from otool in this situation, withaspenrt:log superuser$ more /Library/Logs/DiagnosticReports/orbserver_2010-03-12-223713_localhost.crash Process: orbserver [2019] Path: /opt/antelope/4.11/bin/orbserver Identifier: orbserver Version: ??? (???) Code Type: X86 (Native) Parent Process: perl [199] Date/Time: 2010-03-12 22:37:12.991 +0500 OS Version: Mac OS X 10.6.2 (10C2234) Report Version: 6 Exception Type: EXC_BAD_ACCESS (SIGBUS) Exception Codes: KERN_PROTECTION_FAILURE at 0x0000000000000000 Crashed Thread: 0 Dispatch queue: com.apple.main-thread Thread 0 Crashed: Dispatch queue: com.apple.main-thread 0 orbserver 0x00005673 setup_Status + 162 1 orbserver 0x00005184 main + 980 2 orbserver 0x00001816 start + 54 Thread 0 crashed with X86 Thread State (32-bit): eax: 0x00000000 ebx: 0x000055e1 ecx: 0x00200690 edx: 0x0000001c edi: 0x00000005 esi: 0x00000000 ebp: 0xbffffb88 esp: 0xbffff630 ss: 0x0000001f efl: 0x00010286 eip: 0x00005673 cs: 0x00000017 ds: 0x0000001f es: 0x0000001f fs: 0x00000000 gs: 0x00000037 cr2: 0x00000000 Binary Images: 0x1000 - 0x10fff +orbserver ??? (???) <9E583B6F-533E-E324-1D56-33999757DAC1> /opt/antelope/4.11/bin/orbserver 0x17000 - 0x26fff +liborb.dylib ??? (???) <D5814D70-72C8-2FE2-9C8F-0A3C9F7E1C36> /opt/antelope/4.11/lib/liborb.dylib 0x2e000 - 0x34ff3 +libcoords.dylib ??? (???) <A9849BD1-ECBD-ED5A-6A29-B8D732312EF6> /opt/antelope/4.11/lib/libcoords.dylib 0x3a000 - 0xabfeb +libstock.dylib ??? (???) <6959D38D-BD2C-4A40-70DD-FF594D5B9CD7> /opt/antelope/4.11/lib/libstock.dylib 0xd5000 - 0xe7ff7 +libdeviants.dylib ??? (???) <83CFFCC8-6F4B-06A5-1834-5F7CEAFBAA68> /opt/antelope/4.11/lib/libdeviants.dylib 0xf6000 - 0xf6ffc +libbrttpool.dylib ??? (???) <7BB15689-C70F-2DF5-67D8-52D9E27DD85B> /opt/antelope/4.11/lib/libbrttpool.dylib 0x8fe00000 - 0x8fe41627 dyld 132.1 (???) <7E8A62A5-BB2D-C9C5-940D-B493DC9CD231> /usr/lib/dyld 0x918cf000 - 0x918d2fe7 libmathCommon.A.dylib ??? (???) <1622A54F-1A98-2CBE-B6A4-2122981A500E> /usr/lib/system/libmathCommon.A.dylib 0x979b7000 - 0x97b5bfeb libSystem.B.dylib ??? (???) <D84E6C3F-163B-315B-AA8B-D6D0B383F207> /usr/lib/libSystem.B.dylib 0xffff0000 - 0xffff1fff libSystem.B.dylib ??? (???) <D84E6C3F-163B-315B-AA8B-D6D0B383F207> /usr/lib/libSystem.B.dylib
This might show the actual location in the code where the bus error occurred.% otool -t -v -V setup_Status.o
xdb some-program program-arguments
For the Antelope 4.7 release, I moved all the dynamic libg2c*.dylib to a hidden directory, so that fortran used the static libraries. I couldn't figure out how to get the loader to use the dynamic libraries if I copied them to $antelope/lib, before or after linking.
http://code.google.com/p/git-osx-installer/
** Beware, however, MacPorts sneakily modifies your path by adding something to .tcshrc:
This will break compilation of programs against Antelope, so we strongly advise you to get rid of it!# MacPorts Installer addition on 2009-11-11_at_08:47:32: adding an appropriate PATH variable for use with MacPorts. setenv PATH /opt/local/bin:/opt/local/sbin:$PATH # Finished adapting your PATH environment variable for use with MacPorts.
% man -t <whatever> | open -f -a /Applications/Preview.app
notes_mac_bookshelf(5) notes_mac_extras(5) notes_mac_setup(5) notes_mac_unix_anomalies(5) notes_mac_mavericks(5)
Look at this Apple document for some debugging hints:
http://developer.apple.com/technotes/tn2004/tn2124.html
Search the Mac OS X Developer Library for specific information about debugging:
You might search for "Mac OS X Debugging Magic".http://developer.apple.com/library/mac/navigation/
otool(1) http://ctags.sourceforge.net