GDB that can debug Mach-Os on Linux
Go to file
2017-08-10 17:41:33 -07:00
bfd Automatic date update in version.in 2017-01-18 00:00:27 +00:00
binutils Add support for processing lex source files with flex v 2.6.3 2017-01-18 13:38:27 +00:00
config picflag.m4 high bit set in comment 2017-01-05 00:02:57 +10:30
cpu Add fall through comment to source in cpu/ 2016-10-06 22:48:37 +10:30
elfcpp Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
etc update-copyright.py for binutils 2017-01-05 00:03:07 +10:30
gas Add support for processing lex source files with flex v 2.6.3 2017-01-18 13:38:27 +00:00
gdb Fix loading fat Mach-Os without .dylib extension 2017-04-10 22:23:32 +02:00
gold Gold: Fix build with GCC 4.2 2017-01-13 07:47:52 -08:00
gprof Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
include [DWARF] Sync GCC dwarf.def change on AArch64 2017-01-04 14:27:52 +00:00
intl Regen intl/configure 2015-08-31 12:53:36 +09:30
ld Skip linker tests for unique symbols in shared libraries if the target does not support building shared libraries. 2017-01-18 12:23:19 +00:00
libdecnumber Remove leading/trailing white spaces in ChangeLog 2015-07-24 04:16:47 -07:00
libiberty Sync libiberty from gcc 2017-01-05 00:03:07 +10:30
opcodes Return -1 on memory error in print_insn_m68k 2017-01-13 12:27:39 +00:00
readline Improve MinGW support in Readline 2016-09-17 11:50:37 +03:00
sim Fixes for addv and xtn2 instructions. 2017-01-17 16:11:09 -08:00
src/gdb Link to CF using the new way 2017-08-10 17:41:33 -07:00
texinfo
zlib sync binutils config/ with gcc 2016-12-08 21:35:11 +10:30
.cvsignore
.gitattributes Add a .gitattributes file for use with git-merge-changelog 2014-07-25 18:07:23 -04:00
.gitignore Add archives and make stamps to the .gitignore file. 2016-09-27 15:10:42 +01:00
ChangeLog Import config.sub 2016-12-31 11:47:16 +10:30
compile Update from upstream Automake 2014-11-16 13:43:48 +01:00
config-ml.in Sync toplevel files with GCC 2015-07-27 07:49:05 -07:00
config.guess Sync config.sub,config.guess with upstream. 2016-11-07 13:08:55 -08:00
config.rpath
config.sub Import config.sub 2016-12-31 11:47:16 +10:30
configure sync binutils config/ with gcc 2016-12-08 21:35:11 +10:30
configure.ac Add support for Fushia OS. 2016-12-02 10:44:29 +00:00
COPYING
COPYING3
COPYING3.LIB
COPYING.LIB
COPYING.LIBGLOSS 2013-01-07 Jeff Johnston <jjohnstn@redhat.com> 2013-01-07 21:39:26 +00:00
COPYING.NEWLIB 2013-10-01 Jeff Johnston <jjohnstn@redhat.com> 2013-10-01 18:14:04 +00:00
depcomp Update from upstream Automake 2014-11-16 13:43:48 +01:00
djunpack.bat
install-sh Update from upstream Automake 2014-11-16 13:43:48 +01:00
libtool.m4 Sync top-level btool.m4 with GCC 2016-01-12 08:44:52 -08:00
lt~obsolete.m4
ltgcc.m4
ltmain.sh PR target/59788 2014-02-06 11:01:57 +01:00
ltoptions.m4
ltsugar.m4
ltversion.m4
MAINTAINERS Update description of ownership of files in include/ 2014-11-04 16:14:14 -08:00
Makefile.def Sync top-level Makefile.def with GCC 2016-01-12 08:34:40 -08:00
Makefile.in Add dependencies to configure rule 2016-05-28 22:36:04 +09:30
Makefile.tpl Add dependencies to configure rule 2016-05-28 22:36:04 +09:30
makefile.vms
missing Update from upstream Automake 2014-11-16 13:43:48 +01:00
mkdep
mkinstalldirs Update from upstream Automake 2014-11-16 13:43:48 +01:00
move-if-change Update `move-if-change' from gnulib 2014-11-16 17:04:02 +01:00
README-maintainer-mode
README.md Update README 2017-04-11 10:26:47 +02:00
README.upstream Initial support for debugging Mach-Os in Darling 2017-01-18 20:49:06 +01:00
setup.com
src-release.sh fix gdb version parsing in src-release.sh 2016-01-17 10:01:55 +04:00
symlink-tree
ylwrap Update from upstream Automake 2014-11-16 13:43:48 +01:00

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.