Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to install gdb on MacBook Air m2

I am getting segmentation fault error in C code so I think the best thing to use to find error would be gdb but gdb is not found.

like image 768
serenitycodes Avatar asked Oct 26 '25 05:10

serenitycodes


2 Answers

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.

like image 54
Andrew Avatar answered Oct 29 '25 09:10

Andrew


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"

like image 37
Reyomi Avatar answered Oct 29 '25 08:10

Reyomi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!