gdb <PROCESS NAME> <PROCESS ID>
we can grab the process id with ps command.
Suppose your program name is a.out
so command to get the process id would be?
ps -elf | grep a.out
usr1 4473 3529 0 16:42 pts/0 00:00:00 grep --color=auto a.out
here process name is a.out and process id is 4473
so command to attach the running process a.out with process id a.out would be
gdb a.out 4473
Note: You might require to execute as sudo user.
You may also like: