GDB附加到可执行文件被删除的进程 [英] GDB attaching to a process where executable is deleted
问题描述
我正在运行进程,但它的可执行文件已被删除。
如果我尝试附加gdb,我得到以下错误:
pre $ / home / vivek / binary / releases / 20120328101511 / bin /app.exe(删除):没有这样的文件或目录。
如何将gdb附加到此过程中?
示例测试用例:
源代码:
#include< stdio.h>
#include< stdlib.h>
int main(){
for(;;){
printf(Sleeping);
sleep(1);
$ / code $ / pre
编译它
gcc main.cc -o a.out
gcc main.cc -o b.out
运行
./a.out
现在从不同的终端删除a.out。
和fire gdb附加 pgrep a.out
文件b.out
无效。
GDB显示以下错误:
/tmp/temp/a.out(删除):没有这样的文件或目录。
程序已被调试。杀了它? (y或n)n
程序没有死亡。
解决方案尝试使用 / proc / < pid> / exe
作为可执行文件。它似乎是一个符号链接,但是,过去有可能从中提取被删除的可执行文件。
请参阅检测删除的可执行文件。
我们可以使用以下命令来附加gdb
gdb<路径二进制> < PID>
I have running process but it's executable file has got deleted.
If I try to attach gdb I got following error
/home/vivek/binary/releases/20120328101511/bin/app.exe (deleted): No such file or directory.
How can I attach gdb to this process ?
Sample Test case:
Source code:
#include<stdio.h>
#include<stdlib.h>
int main(){
for (;;){
printf("Sleeping");
sleep(1);
}
}
compile it
gcc main.cc -o a.out
gcc main.cc -o b.out
Run
./a.out
Now from different terminal delete a.out.
And fire gdb attach pgrep a.out
file b.out
It doesn't work.
GDB shows following error:
/tmp/temp/a.out (deleted): No such file or directory.
A program is being debugged already. Kill it? (y or n) n
Program not killed.
解决方案 Try using /proc/<pid>/exe
as the executable. It appears as a symbolic link these days, however, in the past it was possible to extract the deleted executable from it.
See Detecting deleted executables.
We can use following command to attach gdb
gdb <path-to-binary> <pid>
这篇关于GDB附加到可执行文件被删除的进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!