On kernels with Yama enabled, ptrace may not work by default on processes
which are not decendants of the tracing process. Among other things, that
causes the way we attach the debugger to fail. However, we can disable this
on a per-process basis. Do that here.
See https://www.kernel.org/doc/Documentation/security/Yama.txt and prctl(2).
Definition at line 68 of file Debugging.py.
69 """On kernels with Yama enabled, ptrace may not work by default on processes
70 which are not decendants of the tracing process. Among other things, that
71 causes the way we attach the debugger to fail. However, we can disable this
72 on a per-process basis. Do that here.
74 See https://www.kernel.org/doc/Documentation/security/Yama.txt and prctl(2).
80 if not os.path.exists (
'/proc/sys/kernel/yama/ptrace_scope'):
return
83 with open(
'/proc/sys/kernel/yama/ptrace_scope')
as f:
84 if f.readline().strip() ==
'0':
88 from ctypes
import CDLL
89 libc = CDLL(
"libc.so.6")
92 libc.prctl (0x59616d61, 0xffffffffffffffff)