The Permission Error

If you see this error when attaching the GDB to a process:

ptrace: Operation not permitted.

The Solution

  1. (Temporarily, sudo required) run echo "0"|sudo tee /proc/sys/kernel/yama/ptrace_scope
  2. (Permanently, sudo required) editing the file /etc/sysctl.d/10-ptrace.conf and change the line: kernel.yama.ptrace_scope = 1 to kernel.yama.ptrace_scope = 0

References