简体   繁体   English

分离后附加到另一个程序

[英]attach to a different program after detach

I used gud-gdb in emacs. 我在emacs中使用了gud-gdb。 First, I attached to a program1's PID 29514 首先,我附加到program1的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. 然后我想使用pid 4917另一个程序program2。

(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. 我们看到GDB仍然想使用program1。 Is there a way to let gdb clear the last detached program? 有没有办法让gdb清除最后一个分离的程序?

I reproduced this behavior using current trunk GDB. 我使用当前的主干GDB重现了此行为。

I believe it's a bug: the documentation says: 我相信这是一个错误: 文档中说:

"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) ..."

It doesn't distinguish between the first and the second attach, and it doesn't say that GDB will not find the program again if the new process is running different program from the old one. 它没有区分第一和第二个附件,也没有说如果新进程运行的程序与旧程序不同,则GDB将不会再次找到该程序。

You can work around this with the file command: 您可以使用file命令解决此问题:

(gdb) attach $PID1
...
(gdb) detach

(gdb) file prog2    # you shouldn't have to do this
(gdb) attach $PID2  # works fine

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM