Why does gdb hang after running?

Viewed 3369

I recently installed gdb 9.1 on my mac version 10.0.1. and followed the darwin page to get the keyring set up. Every once in a while I'm able to run gdb executable but a majority of the time it hangs right after the r command.

I'm able to run the code fine, but when I run it in gdb it prints

[New Thread 0x2603 of process 48685]

sometimes it will make two or three new threads but it then hangs. I've tried compiling with both -g and -ggdb as well as setting breakpoints at the start of the code and it freezes regardless.

Its frustrating because I can't kill it with control c, control z, or kill -9 so I usually end up restarting the terminal. I'm not quite sure how to debug this, any help is appreciated

3 Answers

Every time running gdb, start with sudo:

sudo gdb ./main.out

After looking through all the solution, this works for me :)

Related