我在emacs中使用了gud-gdb。首先,我附加了program1的PID 29514
(gdb) attach 29514
Attaching to program: program1
...
然后分开了。
(gdb) detach
Detaching from program: program1, process 29514
然后我想要另一个带有pid 4917的程序2。
(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 ?? ()
我们看到GDB仍然想使用program1。有没有办法让gdb清除最后一个分离的程序?
答案 0 :(得分:2)
我使用当前的主干GDB重现了这种行为。
我认为这是一个错误:documentation说:
"When you use attach, the debugger finds the program running in the process
first by looking in the current working directory, then (if the program
is not found) ..."
它没有区分第一个和第二个附加,并且它没有说如果新进程运行与旧程序不同的程序,GDB将不会再次找到该程序。
您可以使用file
命令解决此问题:
(gdb) attach $PID1
...
(gdb) detach
(gdb) file prog2 # you shouldn't have to do this
(gdb) attach $PID2 # works fine