GDB Hangs after "New Thread"

I have built GDB from source on macOS 12.0 (the same issue occurred in Big Sur, too) 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 off" in .gdbinit


I do *not* get taskgated / Mach Port errors; only the New Thread message.


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


Posted on Jul 15, 2021 6:59 PM

Reply

Similar questions

4 replies
Sort By: 

Jul 16, 2021 5:07 PM in response to etresoft

lldb? I'll try that. I already have the Command Line Tools package installed.

30GB is a lot of space on a 250GB disk with 42GB taken up by Bootcamp, and 15GB used by 2 VMs.


Edit: lldb works fine. Thanks for the suggestion. In general, though, I'd rather get one tool working than switch to an alternative.

Reply

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

GDB Hangs after "New Thread"

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.