Videos
GDB has not (yet) been ported to MacOS running on the M2 (AArch64) architecture. Even GDB for MacOS on the old x86-64 was not very well tested as far as I know.
I believe lldb might be available for the MacOS/M2 target, but I know nothing about installing this debugger on MacOS.
If you really want to use gdb on mac, which is as Andrew stated, not well tested, you can use x86_64 version of brew:
First, you need to install x86_64 brew:
arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
Then, you can install gdb right away using:
arch -x86_64 zsh
arch -x86_64 brew install gdb
In addition, you might want need to alias x86_64 brew by adding it to your .zshrc
alias x86brew='arch -x86_64 /usr/local/bin/brew'
So you can just use "x86brew" to install without having to "arch -x86_64 zsh"
After hours and hours of searching, I finally found an obscure gist identifying the issue and detailing the solution.
TL;DR The GNU Debugger requires a patch before it can work with MacOS. gdb v8.0.1 is the last known good version of GDB for MacOS.
Uninstall the latest version of
gdb(i.e. v8.1)brew uninstall --force gdbForce Homebrew to install a version of
gdbwith the patch for MacOS.brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/c3128a5c335bd2fa75ffba9d721e9910134e4644/Formula/gdb.rbUse the existing certificate to codesign the new install of
gdbcodesign -f -s "<GNU GDB Certificate>" $(which gdb)
Now, gdb works as expected!
Special thanks to https://github.com/marcoparente and https://github.com/lokoum for their gist comments!
I got gdb working on Mojave yesterday by:
a) getting the latest gdb source archive (at time of writing, ftp://sourceware.org/pub/gdb/snapshots/current/gdb-weekly-8.2.50.20190212.tar.xz
b) build gdb. I got errors for variable shadowing in darwin-nat.c so I edited the file and rebuilt.
c) follow steps in https://forward-in-code.blogspot.com/2018/11/mojave-vs-gdb.html
Voila!
(source: GDB on Mac/Mojave: During startup program terminated with signal ?, Unknown signal)
Can I use GCC and GDB on an M1 Mac? I was wandering if it could support my development of my University assignment (they require GCC). I was also wandering if I could develop application with OpenGL with the Apple Chip?
Someone that is using them can help me?
Figured out what the issue was, turns out that clang really doesn't like when you try and use strncmp without first including string.h. Meanwhile gcc is perfectly happy to compile elf-bfd.h without including string.h. As a result, even though GDB will compile on macOS, it simply refuses to load any ELF files because the ELF code isn't compiled correctly. The fix is just to add #include <string.h> to the top of elf-bfd.h and GDB will correctly load ELF binaries.
For macos if you are using brew you can install and use i386-elf-gdb - https://formulae.brew.sh/formula/i386-elf-gdb.
brew install i386-elf-gdb