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.

Answer from Andrew on Stack Overflow
🌐
GitHub
gist.github.com › mike-myers-tob › 9a6013124bad7ff074d3297db2c98247
Steps to get GDB actually working in April 2021 on macOS (Intel x86-64 only) · GitHub
Really, as Andrew said on StackOverflow (2 years ago, so the details aren't fully current, but the gist still very much is): "GDB has not (yet) been ported to MacOS running on the M2 (AArch64) architecture.
🌐
Reddit
reddit.com › r/asahilinux › gdb on m2 (osx)
r/AsahiLinux on Reddit: GDB on M2 (OSX)
January 4, 2023 -

Hey! I know this isn't an Asahi Linux question, but you people will probably know more than your generic r/m2 or whatever the sub is. Has anyone gotten gdb installed in osx? I just want to debug a simple C program, so I'm also happy to use whatever cli alternative you might have.

🌐
Apple Community
discussions.apple.com › thread › 253272158
gdb compiler - Apple Community
I’d expect gdb to install with gcc, so (if this is not already what you are trying) try installing gcc:
🌐
Medium
medium.com › @AI_and_Blockchain › how-to-get-gdb-running-on-macos-with-arm-chips-using-qemu-ff9041d6f380
How to Get GDB Running on macOS with ARM Chips Using QEMU | by AI_and_Blockchain | Medium
December 13, 2023 - Unfortunately, GDB doesn’t run natively on macOS with these chips, and LLDB, the default debugger on macOS, doesn’t support the 32-bit RISC-V architecture.
🌐
Tweaking4All
tweaking4all.com › forums › software developmen... › delphi, lazarus, fr...
macOS - Install GDB in 2023 (for use with Lazarus Pascal)
August 2, 2021 - Especially for Apple Silicon Mac's you'd probably want to use LLDB as it seems GDB does not [yet] support Apple Silicon.
🌐
GitHub
github.com › kingking888 › gdb-plugins-for-mac
GitHub - kingking888/gdb-plugins-for-mac: Mac M1 M2 gdb plugins
This is a script which installs Pwndbg, GEF, and Peda GDB plugins in a single command.
Author   kingking888
Find elsewhere
🌐
MacPorts
ports.macports.org › port › gdb-apple
Install gdb-apple on macOS with MacPorts
GDB can run on most popular UNIX and Microsoft Windows variants. ... If not done already, install MacPorts.
🌐
GitHub
gist.github.com › m0sys › 711d0ec5e52102c6ba44451caf38bd38
Apple M1 ARM GDB Build from Source with Python Support · GitHub
Even with all of these things done, I have an arm-none-eabi-gdb but it's not able to load mach-o binaries, so even trivial stuff like gcc-12 main.c -g -o main && gdb main (with CC from either homebrew gcc OR xcode) will result in "[...]/main": not in executable format: file format not recognized (file: main: Mach-O 64-bit executable arm64).
🌐
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 tried debugging with gdb now, you would likely receive a "No symbol table is loaded" error. In order to solve this, you'll need to compile programs with the -ggdb option, as in the following example: ... At this point you should be able to successfully debug your programs on Mac using gdb.
🌐
Does It Arm
doesitarm.com › formula › gdb
Does gdb work on Apple Silicon? - Does It ARM
Latest reported support status of gdb on Apple Silicon and Apple M3 Max and M2 Ultra Processors.
🌐
GitHub
github.com › microsoft › vscode-cpptools › issues › 10788
Unable to Debug on Apple M1/M2 when using linux/amd64 devcontainer · Issue #10788 · microsoft/vscode-cpptools
December 26, 2022 - } ], "version": "2.0.0" } ### Debugger Logs ```shell **Debug Console** --> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (141) LaunchOptions{\"name\":\"(gdb) Launch\",\"type\":\"cppdbg\",\"request\":\"launch\",\"program\":\"/workspaces/sample-cpp/src/test_app\",\"args\":[],\"stopAtEntry\":false,\"cwd\":\"/workspaces/sample-cpp/.vscode\",\"environment\":[],\"externalConsole\":false,\"MIMode\":\"gdb\",\"setupCommands\":[{\"description\":\"Enable pretty-printing for gdb\",\"text\":\"-enable-pretty-printing\",\"ignoreFailures\":true},{\"description\":\"Set
Published   Apr 08, 2023
🌐
Medium
thomaskov.medium.com › gdb-debugger-for-macos-5cb7751dc0a9
gdb Debugger for macOS. This guide will walk you through the… | by Thomas Chou | Medium
June 30, 2021 - This guide will walk you through the steps of installing the gdb debugger on a macOS machine and having it run properly.
🌐
UCI ICS
ics.uci.edu › ~pattis › common › handouts › macmingweclipse › allexperimental › mac-gdb-install.html
ICS 46: GDB Installation on Mac OS X
The problem is caused by Apple switching away from GDB, the GNU debugger, to LLDB, the LLVM debugger, in their Xcode toolchain (along with the transition from GCC to Clang). Unfortunately, Eclipse is not capable of communicating with any debugger other than GDB (yet).
🌐
MacPorts
ports.macports.org › port › gdb
Install gdb on macOS with MacPorts
GDB can run on most popular UNIX and Microsoft Windows variants. ... If not done already, install MacPorts.