Skip to content

Instantly share code, notes, and snippets.

@tyilo
Last active December 15, 2015 04:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tyilo/5201486 to your computer and use it in GitHub Desktop.
Save tyilo/5201486 to your computer and use it in GitHub Desktop.

This doesn't work with OS X 10.9 or later. If you want to build gdb-ng either use Mountain Lion or ask gdbinit (github)/osxreverser (twitter)/fractalg (irc) to fix it for you ;^)

Install darwinbuild:

sudo port install darwinbuild

Download and pack gdb-ng:

cd /tmp
wget --no-check-certificate https://github.com/gdbinit/gdb-ng/archive/master.zip
unzip master.zip
cd gdb-ng-master
sh pack.sh

Create .dmg for darwinbuild:

hdiutil create -size 2G -type UDIF -fs HFSX -volname Builds -uid 0 -gid 0 -attach /tmp/Builds.dmg

Switch to root prompt (all commands from now on will require root):

sudo sh

Initialize darwinbuild:

vsdbutil -a /Volumes/Builds
cd /Volumes/Builds
mkdir Build12A269 # Mountain Lion version
cd Build12A269
darwinbuild -init 12A269
darwinxref edit

Change the line with RC_ARCHS to:

RC_ARCHS = "i386";

Add the following lines after projects = {:

gdb = {
	version = 1824;
};

Copy gdb-ng to Build image:

cp /tmp/gdb-ng-master/gdb-1824.tar.gz Sources

Build gdb:

darwinbuild -nochroot gdb

Backup old version of gdb:

cp /usr/libexec/gdb/gdb-i386-apple-darwin /usr/libexec/gdb/gdb-i386-apple-darwin.orig

Copy new version of gdb to /usr/libexec/gdb:

cp Roots/gdb/gdb-1824.root*/usr/libexec/gdb/gdb-i386-apple-darwin /usr/libexec/gdb/

Sign the new gdb binary using this guide (replace lldb with gdb): http://www.opensource.apple.com/source/lldb/lldb-69/docs/code-signing.txt

Clean up:

rm -rf /tmp/master.zip /tmp/gdb-ng-master

# Not sure if these 2 lines are correct:
hdiutil detach /Volumes/Builds/.build/*.sparseimage
hdiutil detach /tmp/Builds.dmg

rm -rf /tmp/Builds.dmg
@jroblak
Copy link

jroblak commented Jun 28, 2013

Thanks! But I'm getting darwinxref [edit cancelled]: cancelled by user. Any ideas?

@tyilo
Copy link
Author

tyilo commented Jul 8, 2013

Try export EDITOR=vim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment