I failed using brew to install gdb. I was using the following command:
brew install gdb
Is gdb available on mac m1 (apple silicon)? If so, what should I do?
gdb is not support, but you can use lldb .
GDB currently (September 2022) does not support the aarch64 architecture. See also:
I had the same problem, my university requires the use of gdb as a debugger.
I thought about using a virtual machine (a kind of WSL for M1) and I discovered lima.
I installed and configured my virtual machine with Ubuntu and then installed gdb on it (apt-get install gdb).
The remaining problem was configuring VS Code to use gdb (which was installed on the virtual machine). To do this, I used a VS Code extension called Remote - SSH.
With this extension, I was able to connect to my virtual machine (localhost) and use VS Code as if I were on a Linux environment.
I hope this can help you.
The solution is : opening the rosetta option in Finder-Applications-Terminal-Profile, reinstall Homebrew to /usr/local, and then install gdb
The official Homebrew script will determine whether the mac system has an Intel or M1 chip based on whether it is an Arm64 architecture, and choose the installation path as /usr/local/ or /opt/Homebrew/. The general idea is to open the terminal rosetta option, uninstall brew(You can also keep the brew folder under /opt, But when you install software for arm, you need to specify the directory under the opt, for example: /opt/homebrew/bin/brew install vim) or just delete the folder, make sure there is no Homebrew folder under /opt, and reinstall Homebrew to /usr/local.
This is the script I used to install brew:/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
tbz@TBZ-2 ~ % gdb -v
zsh: command not found: gdb
tbz@TBZ-2 ~ % brew install gdb
==> Fetching gdb
==> Downloading https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles//gdb-13.2.
######################################################################### 100.0%
==> Pouring gdb-13.2.ventura.bottle.tar.gz
==> Caveats
gdb requires special privileges to access Mach ports.
You will need to codesign the binary. For instructions, see:
https://sourceware.org/gdb/wiki/PermissionsDarwin
==> Summary
/usr/local/Cellar/gdb/13.2: 67 files, 30.6MB
==> Running `brew cleanup gdb`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
tbz@TBZ-2 ~ % which brew
/usr/local/Homebrew/bin/brew
tbz@TBZ-2 ~ %
I am an undergraduate student, the level is limited, please bear with me
Reinstall Homebrew to /usr/local, personal reference:https://blog.csdn.net/Le_1M/article/details/122685709
(Apple M1 pro - Ventura 13.4 (22F66))