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.
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.
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 .
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With