我正在尝试使用gdb附加程序,但它返回给我:
附加到进程29139无法附加到进程.如果您的uid与目标进程的uid匹配,请检查/ proc/sys/kernel/yama/ptrace_scope的设置,或以root用户身份再次尝试.有关更多详细信息,请参阅/etc/sysctl.d/10-ptrace.conf ptrace:不允许操作.
edb-debugger返回"无法附加到进程,请检查权限,然后重试."
strace返回"attach:ptrace(PTRACE_ATTACH,...):不允许操作"
我将"kernel.yama.ptrace_scope"1更改为0并将"/ proc/sys/kernel/yama/ptrace_scope"1更改为0并尝试使用以下方法设置"set environment LD_PRELOAD =./ ptrace.so":
#include <stdio.h>
int ptrace(int i, int j, int k, int l) {
printf(" ptrace(%i, %i, %i, %i), returning -1\n", i, j, k, l);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
但它仍然返回相同的错误.我如何将它附加到调试器?
C++在Qt创建器中调试代码时,我收到以下错误
ptrace: Operation not permitted.
Could not attach to the process. Make sure no other debugger traces this process.
Check the settings of
/proc/sys/kernel/yama/ptrace_scope
For more details, see /etc/sysctl.d/10-ptrace.conf
Run Code Online (Sandbox Code Playgroud)
这里找到了一个临时解决方案:尝试在QtProject中调试时收到错误
临时解决方案(无法重启):
echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
但是每次启动PC使用Qt时,很难在终端中运行相同的代码.
What is the permanent solution for this?
Run Code Online (Sandbox Code Playgroud)