Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does gdb hang after running?

Tags:

macos

gdb

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

like image 282
Andrew Valdez Avatar asked Mar 03 '20 03:03

Andrew Valdez


People also ask

How do I stop GDB after continue?

To stop your program while it is running, type "(ctrl) + c" (hold down the ctrl key and press c). gdb will stop your program at whatever line it has just executed. From here you can examine variables and move through your program. To specify other places where gdb should stop, see the section on breakpoints below.

Does GDB slow down?

Yes. There are several aspects which slow down when a debugger is attached.

How do I set a breakpoint in GDB?

Breakpoints are set with the break command (abbreviated b ). The debugger convenience variable `$bpnum' records the number of the breakpoint you've set most recently; see section Convenience variables, for a discussion of what you can do with convenience variables.


2 Answers

Every time running gdb, start with sudo:

sudo gdb ./main.out

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

like image 158
Paparikaw Avatar answered Oct 17 '22 01:10

Paparikaw


from this page https://timnash.co.uk/getting-gdb-to-semi-reliably-work-on-mojave-macos/

sudo DevToolsSecurity -disable

works for me.

like image 1
skyinfall Avatar answered Oct 17 '22 03:10

skyinfall