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?
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 supported on M1 Macs; you can instead consider using lldb.
GDB currently (September 2022) does not support the aarch64 architecture. See also:
https://mcmap.net/q/393173/-building-gdb-from-source-on-macos
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.
I had the same problem and was able to solve it using lima as mentioned above (it's a virtual linux terminal inside macos - similar to WSL in Windows). Here's a detailed step by step guide to activate this and integrate it into vs code:
Install lima
using homebrew
brew install lima
start the lima terminal from your mac terminal
limactl start
This will initialize the linux terminal (i.e., install ubuntu image by default and activate it). Wait for it to finish the installation process.
open ubuntu terminal from mac terminal using
lima
Now, you will see that your terminal becomes an ubuntu terminal and you can access all your files from there. You can exit your linux terminal using exit
. This will return you back to mac terminal.
Install the needed libraries within ubuntu terminal
sudo apt install build-essential gdb gfortran
Give lima
write access to your local files (to be able to run codes and write outputs).
a. from mac terminal do the following:
open ~/.lima/default/lima.yaml
In this file set writable: true
for - location: "~"
b. restart lima (linux termianl) using the following:
limactl stop default #or name of the machine
limactl start default #or name of the machine
note, that your machine's name is default (this is the default name).
Now you have your linux machine (terminal) ready and you can use gdb from the terminal.
Once you do the above steps, you can allow an ssh connection to your linux virtual machine to be able to connect to it and debug codes using gdb from vs code.
Install Remote Development
extention in vs code, which enables ssh connection to your virtual machine
add the ssh configuration of your linux vm to vs code
a. do the following from mac terminal:
open ${LIMA_HOME:-$HOME/.lima}/default/ssh.config
this will open the ssh.config file of your vm
b. copy the content of the above file and paste it into ~/.ssh/config
, which is vs code ssh config file. If you don't have that file, create a new one in the same location.
open vs code and establish an ssh connection using command
+ shift
+ p
-> Remote-SSH: connect to host -> choose lima-default.
Now, you are connected to the virtual machine (lima), you can navigate to your local files by opening a new directory and navigating to /Users/username/..
. Note that vs code by default directs you to /home/username.linux/
, which won't have your local files.
You can install any needed extensions from vs code to the ssh (linux vm) by clicking on the install in SSH: lima-default
option under the locally installed extensions.
You now can debug codes in vs code using gdb on mac silicon M series.
This is only a partial answer, but for cross-architecture debugging, eg to communicate with gdbserver running on another device, you can try brew install arm-none-eabi-gdb
or brew install aarch64-elf-gdb
which should work to let you connect with gdbservers on those respective architectures.
© 2022 - 2025 — McMap. All rights reserved.