🌐
Homebrew
formulae.brew.sh › formula › gdb
gdb — Homebrew Formulae
brew install gdb · GNU debugger · https://www.gnu.org/software/gdb/ License: GPL-3.0-or-later · Formula JSON API: /api/formula/gdb.json · Formula code: gdb.rb on GitHub ·

source-level debugger

GNU_gdb_12.1_screenshot.png
The GNU Debugger (GDB) is a portable debugger that runs on many Unix-like systems and works for many programming languages, including Ada, Assembly, C, C++, D, Fortran, Haskell, Go, Objective-C, OpenCL C, … Wikipedia
Factsheet
Developer GNU Project
Initial release 1986; 39 years ago (1986)
Stable release 16.3
/ 20 April 2025
Factsheet
Developer GNU Project
Initial release 1986; 39 years ago (1986)
Stable release 16.3
/ 20 April 2025
🌐
UCI ICS
ics.uci.edu › ~pattis › common › handouts › macmingweclipse › allexperimental › mac-gdb-install.html
ICS 46: GDB Installation on Mac OS X
As with GCC, the easiest way to install GDB is through Homebrew. In a Terminal window, run the command brew install gdb, and wait for it to complete.
🌐
GitHub
gist.github.com › mike-myers-tob › 9a6013124bad7ff074d3297db2c98247
Steps to get GDB actually working in April 2021 on macOS (Intel x86-64 only) · GitHub
HOMEBREW_NO_INSTALL_FROM_API=1 brew tap --force homebrew/core # That'll take a while, if you don't already have the repo cloned cd $(brew --repository homebrew/core) git log --oneline --follow Formula/g/gdb.rb # Pick a commit you want to roll back to git checkout <commit_sha> brew install ./Formula/g/gdb.rb # Or Formula/gdb.rb, if you check out # a commit from before the rename
🌐
GitHub
github.com › orgs › Homebrew › discussions › 1114
Support for gdb on m1? · Homebrew · Discussion #1114
You can try to install from source with: brew install --build-from-source gdb Please note building from source is unsupported. You will encounter build failures with some formulae. If you experience any issues please create pull requests instead of asking for help on Homebrew's GitHub, Twitter or any other official channels.
🌐
Homebrew
formulae.brew.sh › formula › x86_64-elf-gdb
x86_64-elf-gdb — Homebrew Formulae
brew install x86_64-elf-gdb · GNU debugger for x86_64-elf cross development · https://www.gnu.org/software/gdb/ License: GPL-3.0-or-later · Formula JSON API: /api/formula/x86_64-elf-gdb.json · Formula code: x86_64-elf-gdb.rb on GitHub ·
🌐
DEV Community
dev.to › jasonelwood › setup-gdb-on-macos-in-2020-489k
Install Gdb Mac: Setup gdb on macOS in 2020 - DEV Community
September 18, 2020 - If you don't already have gdb on your system, then you'll need to install it. I'm going to show you how to install gdb by using Homebrew.
Find elsewhere
Top answer
1 of 1
7

Just figured it out. I created a modified version of the formula .rb file in my /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/gdbCustom.rb and added the missing build options. I based it on this formula: https://raw.githubusercontent.com/Homebrew/homebrew-core/9ec9fb27a33698fc7636afce5c1c16787e9ce3f3/Formula/gdb.rb

Yes, I'm a newbie to Homebrew, but have a better understanding of how formulas work now. In case it helps others, see below final .rb. After adding the file to the above homebrew-core/Formula directory, run brew install gdbCustom --with-all-targets. The make takes several minutes, so be patient.

class Gdbcustom < Formula
    desc "GNU debugger"
    homepage "https://www.gnu.org/software/gdb/"
    head "https://sourceware.org/git/binutils-gdb.git"

    stable do
      url "https://ftp.gnu.org/gnu/gdb/gdb-8.2.1.tar.xz"
      mirror "https://ftpmirror.gnu.org/gdb/gdb-8.2.1.tar.xz"
      sha256 "0a6a432907a03c5c8eaad3c3cffd50c00a40c3a5e3c4039440624bae703f2202"

      # Fix build with all targets. Remove for 8.3
      # https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commitdiff;h=0c0a40e0abb9f1a584330a1911ad06b3686e5361
      patch do
        url "https://raw.githubusercontent.com/Homebrew/formula-patches/d457e55/gdb/all-targets.diff"
        sha256 "1cb8a1b8c4b4833212e16ba8cfbe620843aba0cba0f5111c2728c3314e10d8fd"
      end

      # Fix debugging of executables of Xcode 10 and later
      # created for 10.14 and newer versions of macOS. Remove for 8.3
      # https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=fc7b364aba41819a5d74ae0ac69f050af282d057
      patch do
        url "https://raw.githubusercontent.com/Homebrew/formula-patches/d457e55/gdb/mojave.diff"
        sha256 "6264c71b57a0d5d4aed11430d352b03639370b7d36a5b520e189a6a1f105e383"
      end
    end

    bottle do
        sha256 "01b06c2983503c78bc346b5f5e2c2bdccbc41d6f5ca759542eef712bf123ca30" => :mojave
        sha256 "9824d06b8d0d44e725a1d29f6631828b3b43abb1952c883e9fad559b6a816c04" => :high_sierra
        sha256 "cf7371e9f6257d1a7dee80239d05917e424e5bb3e7577bd93f0e139fe5174198" => :sierra
    end

    # Owen: deprecated_option "with-brewed-python" => "with-python"
    # Owen: deprecated_option "with-guile" => "[email protected]"

    option "with-python", "Use the Homebrew version of Python; by default system Python is used"
    option "with-version-suffix", "Add a version suffix to program"
    option "with-all-targets", "Build with support for all targets"

    depends_on "pkg-config" => :build
    # Owen: depends_on "python" => :optional
    # Owen: depends_on "[email protected]" => :optional

    fails_with :clang do
        build 800
        cause <<~EOS
          probe.c:63:28: error: default initialization of an object of const type
          'const any_static_probe_ops' without a user-provided default constructor
        EOS
    end

    fails_with :clang do
      build 600
      cause <<~EOS
        clang: error: unable to execute command: Segmentation fault: 11
        Test done on: Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
      EOS
    end

    def install
      args = %W[
        --prefix=#{prefix}
        --disable-debug
        --disable-dependency-tracking
        --enable-targets=all
        --with-python=/usr
        --disable-binutils
    ]

        # Owen: args << "--with-guile" if build.with? "[email protected]"
        # Owen: args << "--enable-targets=all" if build.with? "all-targets"

      if build.with? "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"

      # Don't install bfd or opcodes, as they are provided by binutils
      # Owen: inreplace ["bfd/Makefile", "opcodes/Makefile"], /^install:/, "dontinstall:"

      # Owen: system "make", "install"
      system "make", "install-gdb"
    end

    def caveats; <<~EOS
      gdb requires special privileges to access Mach ports.
      You will need to codesign the binary. For instructions, see:

        https://sourceware.org/gdb/wiki/BuildingOnDarwin

      On 10.12 (Sierra) or later with SIP, you need to run this:

        echo "set startup-with-shell off" >> ~/.gdbinit
      EOS
    end

    test do
      system bin/"gdb", bin/"gdb", "-configuration"
    end
  end
🌐
Homebrew
formulae.brew.sh › formula › arm-none-eabi-gdb
arm-none-eabi-gdb — Homebrew Formulae
brew install arm-none-eabi-gdb · GNU debugger for arm-none-eabi cross development · https://www.gnu.org/software/gdb/ License: GPL-3.0-or-later · Formula JSON API: /api/formula/arm-none-eabi-gdb.json · Formula code: arm-none-eabi-gdb.rb on GitHub · Bottle (binary package) installation support provided for: Current versions: Revision: 1 ·
🌐
GitHub
github.com › RetroReversing › homebrew-gdb-multiarch
GitHub - RetroReversing/homebrew-gdb-multiarch: GDB Multiarch for MacOSX
GDB compiled with all targets enabled, this is useful for debugging console games through a GDB emulator interface.
Starred by 10 users
Forked by 4 users
Languages   Ruby
🌐
Deepan Seeralan
deepanseeralan.com › tech › gdb-on-macOS-BigSur
Running GDB on macOS Big Sur - Deepan Seeralan
July 24, 2021 - git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask fetch --unshallow . . % brew update . . You have 43 outdated formulae and 1 outdated cask installed. You can upgrade them with brew upgrade or list them with brew outdated. % brew install gdb ==> Downloading https://ghcr.io/v2/homebrew/core/gdbm/manifests/1.20 ######################################################################## 100.0% ==> Downloading https://ghcr.io/v2/homebrew/core/gdbm/blobs/sha256:ea88ce09e934407b1c7dfcc1b74e2d4f1b409f8264b4475b
🌐
GitHub
github.com › domq › homebrew-gdb
GitHub - domq/homebrew-gdb: Backported 8.0.1 gdb
Backported 8.0.1 gdb. Contribute to domq/homebrew-gdb development by creating an account on GitHub.
Starred by 9 users
Forked by 3 users
Languages   Ruby
🌐
Reddit
reddit.com › r/c_programming › does installing gdb on a mac usually take a while? or is it only me?
r/C_Programming on Reddit: Does installing GDB on a mac usually take a while? or is it only me?
April 13, 2024 - I am currently using lldb. Continue this thread Continue this thread Continue this thread · LevelHelicopter9420 • 2y ago · You can use homebrew to install gcc, gdb and other tools ·
🌐
Homebrew
formulae.brew.sh › formula › gdbgui
gdbgui — Homebrew Formulae
brew install gdbgui · Modern, browser-based frontend to gdb (gnu debugger) https://www.gdbgui.com/ License: GPL-3.0-only · Formula JSON API: /api/formula/gdbgui.json · Formula code: gdbgui.rb on GitHub ·
🌐
Quora
quora.com › How-can-I-install-GDB-on-a-Mac
How to install GDB on a Mac - Quora
Answer (1 of 7): The question is “How can I install GDB on a Mac?” I’ve never tried - but if you’re using Xcode or the “command line development tools” on the Mac from Apple and want to use a command line debugger, then use “lldb” instead (llvm/clang seems to be the native compiler.)
🌐
GitHub
github.com › Homebrew › homebrew-core › issues › 108309
gdb installation does not work on Mac M1 machines. · Issue #108309 · Homebrew/homebrew-core
May 5, 2022 - $ brew install gdb gdb: The x86_64 architecture is required for this software. Error: gdb: An unsatisfied requirement failed this build. ... bugReproducible Homebrew/homebrew-core bugReproducible Homebrew/homebrew-core bugoutdatedPR was locked due to agePR was locked due to age
Published   Aug 17, 2022