Under linux, can I use GDB to debug a process that is currently running?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes. Use the
attachcommand. Check out this link for more information. Typinghelp attachat a GDB console gives the following:Attach to a process or file outside of GDB.
This command attaches to another target, of the same type as your last
"
target" command ("info files" will show your target stack).The command may take as argument a process id, a process name
(with an optional process-id as a suffix), or a device file.
For a process id, you must have permission to send the process a signal,
and it must have the same effective uid as the debugger.
When using "
attach" to an existing process, the debugger finds theprogram running in the process, looking first in the current working
directory, or (if not found there) using the source file search path
(see the "
directory" command). You can also use the "file" commandto specify the program, and to load its symbol table.
NOTE: You may have difficulty attaching to a process due to improved security in the Linux kernel – for example attaching to the child of one shell from another.
You’ll likely need to set
/proc/sys/kernel/yama/ptrace_scopedepending on your requirements. Many systems now default to1or higher.