How to solve “ptrace operation not permitted” when trying to attach GDB to a process?

前端 未结 13 2222
予麋鹿
予麋鹿 2020-11-30 18:28

I\'m trying to attach a program with gdb but it returns:

Attaching to process 29139
Could not attach to process. If your uid matches the ui

13条回答
  •  悲哀的现实
    2020-11-30 19:07

    I was running my code with higher privileges to deal with Ethernet Raw Sockets by setting set capability command in Debian Distribution. I tried the above solution: echo 0 > /proc/sys/kernel/yama/ptrace_scope or by modifying it in /etc/sysctl.d/10-ptrace.conf but that did not work for me.

    Additionally, I also tried with set capabilities command for gdb in installed directory (usr/bin/gdb) and it works: /sbin/setcap CAP_SYS_PTRACE=+eip /usr/bin/gdb. Be sure to run this command with root privileges.

提交回复
热议问题