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.
Asked
Active
Viewed 2.1k times
3 Answers
46
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
dashesy
- 2,455
- 3
- 45
- 58
-
1I had to disable pagination, because on attach there were too many threads, and gdb did not perform 'continue' before user intervention: `gdb -iex "set pagination off" -q -ex cont -p $PID` – Alex Cohn Apr 27 '22 at 14:19
15
You can't make it not stop. You can however instantly continue... Create a simple batch script which will attach to a specific process and instantly continuing execution after attaching:
gdb attach $1 -x <(echo "cont")
./attach PID
Community
- 1
- 1
QuantumBlack
- 1,489
- 11
- 24
3
For when you don't know the PID of the process...
gdb attach $(pgrep -f myApp) -ex cont
Dan
- 1,057
- 10
- 13