Search code examples
linuxgdbcentos

Is it possible to attach to an already running gdb process?


Good morning, I started a gdb debug session several hours ago. Is possible to use gdb to attach to a process already being debugged by gdb?

I tried to attach as root but I get the following error message:

[root@localhost lirh5g_deb]# gdb ./MatchUpAccurate.exe  12327
ptrace: Operation not permitted.
/home/frank/DQT/MatchUpTest/lirh5g_deb/12327: No such file or directory.

We are using Centos Linux Version 5.5. Thank you.


Solution

  • Unfortunately, not directly. Your only option, if you didn't use screen/tmux, is to search for a tty hijacker (it's possible to "steal" tty's - this is an ugly solution though) and grab the tty which has your existing gdb session