docker container中gdb调试程序,报错:
Attaching to process 29139 Could not attach to process. If your uid matches the uid of the target process,
check the setting of /proc/sys/kernel/yama/ptrace_scope, or try again as the root user. For more details,
see /etc/sysctl.d/10-ptrace.conf ptrace: Operation not permitted.
原因是docker中做了限制,ptrace限制?
需要加上--cap-add=SYS_PTRACE --security-opt seccomp=unconfined,例如:
docker run --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -it docker镜像 bash
如果不是docker环境,可能需要
/etc/sysctl.d/10-ptrace.conf中的值由1改为0
sysctl -p