Gdb associated with the process of deleting the executable

I have a working process, but its executable has been deleted. If I try to connect gdb, I got the following error

/home/vivek/binary/releases/20120328101511/bin/app.exe (deleted): No such file or directory.

How to connect gdb to this process?

Example: 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 remove a.out from another terminal. And fire gdb attach pgrep a.outb.out file This does not work.

GDB shows the 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.
+5
source share
2 answers

Try using /proc/<pid>/exeas an executable file. Nowadays, it looks like a symbolic link, but in the past it was possible to extract a remote executable from it.

See Detecting Remote Executables .

gdb

gdb <path-to-binary> <pid>
+7

. GDB , .

+2

All Articles