Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gdb attach to a process without stop

Tags:

Everytime I attach to a process using gdb, it will stop the target program, and I need to type 'cont' to let it go. Is there a way to attach to a process without stopping it? This makes things easier if the process will behave differently if it stops for a while.

like image 293
Kan Li Avatar asked Mar 17 '12 00:03

Kan Li


People also ask

How do I stop continuing gdb?

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.

How do I detach a process in gdb?

When you have finished debugging the attached process, you can use the detach command to release it from GDB control. Detaching the process continues its execution. After the detach command, that process and GDB become completely independent once more, and you are ready to attach another process or start one with run .


1 Answers

I know there is already a fine answer for this, but I prefer not using an additional file.

Here is another answer:

gdb attach $(pidof process_name) -ex cont 
like image 121
dashesy Avatar answered Oct 14 '22 22:10

dashesy