I used gud-gdb in emacs. First, I attached to a program1's PID 29514
(gdb) attach 29514
Attaching to program: program1
...
Then detached it.
(gdb) detach
Detaching from program: program1, process 29514
Then I wanted to another program program2 with pid 4917.
(gdb) attach 4917
Attaching to program: program1, process 4917
Reading symbols from /lib64/ld-linux-x86-64.so.2...(no debugging symbols found)...done.
0x00007fbfc52604c0 in ?? ()
We saw that GDB still wanted to use program1. Is there a way to let gdb clear the last detached program?