I have built GDB from source on macOS 12.0 and codesigned it. However, every time I try to debug a program, I get this:
(gdb) b main Breakpoint 1 at 0x10000324f: file main.cpp, line 50. (gdb) run Starting program: /Users/fluzzlesnuff/Documents/C++/a.out [New Thread 0x2a03 of process 2389] and then GDB hangs. I have been compiling C++ programs with g++. Here are some things I have tried:
- Compile with -g option.
- Compile with -ggdb option.
- Compile with -ggdb3 option.
- Run with
sudo - Kill and re-run gdb repeatedly.
- Try different binaries.
- Disable SIP
- Add more breakpoints.
set startup-with-shell offin.gdbinit
I do not get taskgated / Mach Port errors; only the New Thread message.
I realize that this is a near-duplicate of this, but I didn't see a working answer on that question.
For reference, here are my versions:
$ g++ --version Apple clang version 12.0.0 (clang-1200.0.32.29) Target: x86_64-apple-darwin21.0.0 Thread model: posix InstalledDir: /Library/Developer/CommandLineTools/usr/bin $ gdb --version GNU gdb (GDB) 10.2
g++is an alias ofgccwith some C++ options, so it’s definitely GNU. gcc.gnu.orglldbyou can sidestep this altogether and have a working debugger. I wasn't able to getgdbworking and hit this same error. No such issue with lldb which provides very similar functionality.