Skip to content

Instantly share code, notes, and snippets.

@ymyzk

ymyzk/gdb.rb

Created Jul 21, 2014
Embed
What would you like to do?
Homebrew formula of GDB with patch for OS X Yosemite
require "formula"
class UniversalBrewedPython < Requirement
satisfy { archs_for_command("python").universal? }
def message; <<-EOS.undent
A build of GDB using a brewed Python was requested, but Python is not
a universal build.
GDB requires Python to be built as a universal binary or it will fail
if attempting to debug a 32-bit binary on a 64-bit host.
EOS
end
end
class Gdb < Formula
homepage "http://www.gnu.org/software/gdb/"
url "http://ftpmirror.gnu.org/gdb/gdb-7.7.1.tar.gz"
mirror "http://ftp.gnu.org/gnu/gdb/gdb-7.7.1.tar.gz"
sha1 "bb49bdb5781ea62ccdc2ec6869872e1b43168572"
if MacOS.version >= "10.10"
patch :DATA
end
depends_on "readline"
if build.with? "brewed-python"
depends_on UniversalBrewedPython
end
option "with-brewed-python", "Use the Homebrew version of Python"
option "with-version-suffix", "Add a version suffix to program"
def install
args = [
"--prefix=#{prefix}",
"--disable-debug",
"--disable-dependency-tracking",
"--with-system-readline"
]
if build.with? "brewed-python"
args << "--with-python=#{HOMEBREW_PREFIX}"
else
args << "--with-python=/usr"
end
if build.with? "version-suffix"
args << "--program-suffix=-#{version.to_s.slice(/^\d/)}"
end
system "./configure", *args
system "make"
system "make", "install"
# Remove conflicting items with binutils
rm_rf include
rm_rf lib
rm_rf share/"locale"
# Conflicts with other GNU packages
rm_f info/"standards.info"
end
def caveats; <<-EOS.undent
gdb requires special privileges to access Mach ports.
You will need to codesign the binary. For instructions, see:
http://sourceware.org/gdb/wiki/BuildingOnDarwin
EOS
end
end
__END__
diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c
index a21bb0f..3144dd4 100644
--- a/gdb/darwin-nat.c
+++ b/gdb/darwin-nat.c
@@ -42,7 +42,7 @@
#include <sys/ptrace.h>
#include <sys/signal.h>
-#include <machine/setjmp.h>
+#include <setjmp.h>
#include <sys/types.h>
#include <unistd.h>
#include <signal.h>
@oHaiyang

This comment has been minimized.

Copy link

@oHaiyang oHaiyang commented Sep 3, 2014

This works well, thank you so much!

@dmonagle

This comment has been minimized.

Copy link

@dmonagle dmonagle commented Sep 21, 2014

Thank you very much for this! You saved me a lot of time.

@ramunas

This comment has been minimized.

Copy link

@ramunas ramunas commented Oct 30, 2014

Worked for me as well! Thanks so much!

@jvergar2

This comment has been minimized.

Copy link

@jvergar2 jvergar2 commented Dec 15, 2014

I'm sorry, I'm not good with this type of files.
What do I have to do with this file?.
Do I have to compile via terminal?.

Thanks for the help.

@tweidhofer

This comment has been minimized.

Copy link

@tweidhofer tweidhofer commented Mar 3, 2015

@jvergar2 better late than never, and for anyone who ends up here and has no idea.
I don't know if this is the "proper" way to do it, but it worked for me:

I hit the "raw" button at the top and then copied the URL and pasted it into my terminal:
$ brew install "the_URL_you_copied"

I hope this helps
and thank you so much for writing this code, worked like a charm, once i found out how :-D

@rad-hombre

This comment has been minimized.

Copy link

@rad-hombre rad-hombre commented Apr 19, 2015

Yes! Thanks so much. Worked like a charm after I set up the cert for gdb.

@tommymcdonald

This comment has been minimized.

Copy link

@tommymcdonald tommymcdonald commented May 22, 2015

Works beautifully, +1! Thank you!

@wuxicn

This comment has been minimized.

Copy link

@wuxicn wuxicn commented Aug 6, 2015

Great! Thx man!

And most people may need to create a code sign for gdb to make it work properly on OS X 10.10. Here's the instruction:

http://wiki.lazarus.freepascal.org/GDB_on_OS_X_Mavericks_and_Xcode_5#Codesigning_gdb

@XBOOS

This comment has been minimized.

Copy link

@XBOOS XBOOS commented Oct 21, 2015

Thank you so much! Spent a lot of time struggling with the OSO warning on gdb7.10

@FranklinYu

This comment has been minimized.

Copy link

@FranklinYu FranklinYu commented Dec 6, 2015

This is really the only way out, if anyone do not want to manually configure a compilation and installation. Great thank for eliminating the OSO/coreTLS warning!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.