GDB that can debug Mach-Os on Linux
C Assembly Makefile D C++ Scheme Other
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
bfd Automatic date update in version.in Jan 18, 2017
binutils Add support for processing lex source files with flex v 2.6.3 Jan 18, 2017
config picflag.m4 high bit set in comment Jan 4, 2017
cpu Add fall through comment to source in cpu/ Oct 6, 2016
elfcpp Update year range in copyright notice of all files. Jan 2, 2017
etc update-copyright.py for binutils Jan 4, 2017
gas Add support for processing lex source files with flex v 2.6.3 Jan 18, 2017
gdb Fix loading fat Mach-Os without .dylib extension Apr 10, 2017
gold Gold: Fix build with GCC 4.2 Jan 13, 2017
gprof Update year range in copyright notice of all files. Jan 2, 2017
include [DWARF] Sync GCC dwarf.def change on AArch64 Jan 4, 2017
intl Regen intl/configure Aug 31, 2015
ld Skip linker tests for unique symbols in shared libraries if the targe… Jan 18, 2017
libdecnumber Remove leading/trailing white spaces in ChangeLog Jul 24, 2015
libiberty Sync libiberty from gcc Jan 4, 2017
opcodes Return -1 on memory error in print_insn_m68k Jan 13, 2017
readline Improve MinGW support in Readline Sep 17, 2016
sim Fixes for addv and xtn2 instructions. Jan 18, 2017
src/gdb Link to CF using the new way Aug 11, 2017
texinfo * texinfo/texinfo.tex: Update to version 2009-03-28.05. Apr 21, 2009
zlib sync binutils config/ with gcc Dec 8, 2016
.cvsignore add autom4te.cache to .cvsignore Feb 13, 2007
.gitattributes Add a .gitattributes file for use with git-merge-changelog Jul 25, 2014
.gitignore Add archives and make stamps to the .gitignore file. Sep 27, 2016
COPYING 2005-07-14 Kelley Cook <kcook@gcc.gnu.org> Jul 14, 2005
COPYING.LIB 2005-07-16 Kelley Cook <kcook@gcc.gnu.org> Jul 16, 2005
COPYING.LIBGLOSS 2013-01-07 Jeff Johnston <jjohnstn@redhat.com> Jan 7, 2013
COPYING.NEWLIB 2013-10-01 Jeff Johnston <jjohnstn@redhat.com> Oct 1, 2013
COPYING3 * COPYING3: New file. Contains version 3 of the GNU General Public Li… Jul 17, 2007
COPYING3.LIB * COPYING3: New file. Contains version 3 of the GNU General Public Li… Jul 17, 2007
ChangeLog Import config.sub Dec 31, 2016
MAINTAINERS Update description of ownership of files in include/ Nov 5, 2014
Makefile.def Sync top-level Makefile.def with GCC Jan 12, 2016
Makefile.in Add dependencies to configure rule May 28, 2016
Makefile.tpl Add dependencies to configure rule May 28, 2016
README-maintainer-mode Cleanups after the update to Autoconf 2.64, Automake 1.11. Aug 22, 2009
README.md Update README Apr 11, 2017
README.upstream Initial support for debugging Mach-Os in Darling Jan 18, 2017
compile Update from upstream Automake Nov 16, 2014
config-ml.in Sync toplevel files with GCC Jul 27, 2015
config.guess Sync config.sub,config.guess with upstream. Nov 7, 2016
config.rpath Remove freebsd1 from libtool.m4 macros and config.rpath. Feb 13, 2011
config.sub Import config.sub Dec 31, 2016
configure sync binutils config/ with gcc Dec 8, 2016
configure.ac Add support for Fushia OS. Dec 2, 2016
depcomp Update from upstream Automake Nov 16, 2014
djunpack.bat * djunpack.bat: Use ".." quoting in Sed command, for the sake of Mar 27, 2009
install-sh Update from upstream Automake Nov 16, 2014
libtool.m4 Sync top-level btool.m4 with GCC Jan 12, 2016
ltgcc.m4 * libtool.m4: Update to libtool 2.2.6. Sep 29, 2008
ltmain.sh PR target/59788 Feb 6, 2014
ltoptions.m4 Sync Libtool from GCC. Jan 9, 2010
ltsugar.m4 * libtool.m4: Update to libtool 2.2.6. Sep 29, 2008
ltversion.m4 Sync Libtool from GCC. Jan 9, 2010
lt~obsolete.m4 Sync Libtool from GCC. Jan 9, 2010
makefile.vms 19990502 sourceware import May 3, 1999
missing Update from upstream Automake Nov 16, 2014
mkdep * mkdep: New file. Aug 8, 1999
mkinstalldirs Update from upstream Automake Nov 16, 2014
move-if-change Update `move-if-change' from gnulib Nov 16, 2014
setup.com 2009-09-01 Tristan Gingold <gingold@adacore.com> Sep 1, 2009
src-release.sh fix gdb version parsing in src-release.sh Jan 17, 2016
symlink-tree 2005-07-14 Kelley Cook <kcook@gcc.gnu.org> Jul 14, 2005
ylwrap Update from upstream Automake Nov 16, 2014

README.md

GDB for Darling

This is GDB modified for use with Darling. It enables you to debug Mach-O code loaded by dyld (via Darling's mldr).

I build GDB like this, adapt it to your preferences:

./configure --disable-werror --disable-binutils --disable-etc \
	--disable-gas --disable-gold --disable-gprof --disable-ld \
	--enable-gdbserver=auto --enable-64-bit-bfd --disable-install-libbfd \
	--disable-install-libiberty --without-guile --disable-readline \
	--with-system-readline --without-zlib --with-system-zlib \
	--with-separate-debug-dir=/usr/lib/debug --without-expat \
	--without-lzma --enable-nls --enable-targets=all --program-suffix=-darling \
	--prefix=/usr/local/libexec/darling

Usage example

It is not yet possible to run Mach-O executables directly, you must tell gdb to run them through mldr:

gdb-darling /bin/mldr
(gdb) r /some/apple/binary

Explanation: mldr is a simple Mach-O loader that loads Apple's dynamic loader (dyld) and hands control over to it.

You should be able to see valid backtraces where debug info is available:

(gdb) bt
#0  puts (s=0x7ffff7618faa "Hello world") at /home/lubos/Projects/darling/src/libc/stdio/FreeBSD/puts.c:64
#1  0x00007ffff7618f7d in main () from /home/lubos/Projects/hello
#2  0x00007ffef74e6455 in start () from /usr/local/libexec/darling/usr/lib/system/libdyld.dylib
#3  0x00007ffef74e6455 in start () from /usr/local/libexec/darling/usr/lib/system/libdyld.dylib
#4  0x0000000000000000 in ?? ()

Or examine what libraries are loaded at which addresses:

(gdb) info sharedlibrary 
From                To                  Syms Read   Shared Object Library
0x00007ffff7ddaaa0  0x00007ffff7df5de0  Yes         /lib64/ld-linux-x86-64.so.2
0x00007ffff7bc2a60  0x00007ffff7bcf871  Yes         /lib/x86_64-linux-gnu/libpthread.so.0
0x00007ffff79b9d80  0x00007ffff79ba93e  Yes         /lib/x86_64-linux-gnu/libdl.so.2
0x00007ffff763a910  0x00007ffff77642c3  Yes         /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff7618f60  0x00007ffff7619018  Yes (*)     /home/lubos/Projects/hello
0x00007ffff7ff0780  0x00007ffff7ff1210  Yes         /usr/local/libexec/darling/usr/lib/libSystem.B.dylib
0x00007ffff7fec990  0x00007ffff7fed020  Yes (*)     /usr/local/libexec/darling/usr/lib/system/libsystem_sandbox.dylib
0x00007ffff7fe9900  0x00007ffff7fea070  Yes         /usr/local/libexec/darling/usr/lib/system/libquarantine.dylib
0x00007ffff7fe4930  0x00007ffff7fe7168  Yes (*)     /usr/local/libexec/darling/usr/lib/system/libremovefile.dylib
0x00007ffff7fd5a20  0x00007ffff7fe1350  Yes (*)     /usr/local/libexec/darling/usr/lib/system/libcopyfile.dylib
0x00007ffff7e1a550  0x00007ffff7e28b21  Yes         /usr/local/libexec/darling/usr/lib/system/libunwind.dylib
0x00007ffff7fd26b0  0x00007ffff7fd3478  Yes (*)     /usr/local/libexec/darling/usr/lib/system/libsystem_coreservices.dylib
0x00007ffef75d5f90  0x00007ffef7614070  Yes (*)     /usr/local/libexec/darling/usr/lib/libcommonCrypto.dylib
0x00007ffef7587450  0x00007ffef75bb6e8  Yes         /usr/local/libexec/darling/usr/lib/system/libsystem_info.dylib
0x00007ffff7e01200  0x00007ffff7e13400  Yes (*)     /usr/local/libexec/darling/usr/lib/system/libsystem_notify.dylib
0x00007ffef753cf80  0x00007ffef7568a68  Yes         /usr/local/libexec/darling/usr/lib/system/libdispatch.dylib
0x00007ffff7fcd2e0  0x00007ffff7fcf9f0  Yes (*)     /usr/local/libexec/darling/usr/lib/system/libsystem_blocks.dylib
0x00007ffef74f2750  0x00007ffef752c6ad  Yes         /usr/local/libexec/darling/usr/lib/system/libsystem_malloc.dylib
0x00007ffef74ee5e0  0x00007ffef74ef098  Yes (*)     /usr/local/libexec/darling/usr/lib/system/libkeymgr.dylib
0x00007ffef74e2620  0x00007ffef74e8554  Yes (*)     /usr/local/libexec/darling/usr/lib/system/libdyld.dylib
0x00007ffef74c6330  0x00007ffef74d65a0  Yes         /usr/local/libexec/darling/usr/lib/system/liblaunch.dylib
0x00007ffef72c3500  0x00007ffef743749c  Yes         /usr/local/libexec/darling/usr/lib/system/libsystem_c.dylib
0x00007ffef726fde0  0x00007ffef72aa294  Yes         /usr/local/libexec/darling/usr/lib/system/libsystem_m.dylib
0x00007ffef72638d0  0x00007ffef726c7c0  Yes (*)     /usr/local/libexec/darling/usr/lib/system/libmacho.dylib
0x00007ffef71d5dd0  0x00007ffef7229ce0  Yes         /usr/local/libexec/darling/usr/lib/system/libsystem_kernel.dylib
0x00007ffff7dfd790  0x00007ffff7dfe01c  Yes (*)     /usr/local/libexec/darling/usr/lib/system/libsystem_duct.dylib
0x00007ffef71bad40  0x00007ffef71cc1f8  Yes (*)     /usr/local/libexec/darling/usr/lib/system/libcompiler_rt.dylib
0x00007ffef7173970  0x00007ffef71b10d0  Yes (*)     /usr/local/libexec/darling/usr/lib/libresolv.9.dylib
(*): Shared library is missing debugging information.