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 65 of file Debugging.py.
66 """On kernels with Yama enabled, ptrace may not work by default on processes
67 which are not decendants of the tracing process. Among other things, that
68 causes the way we attach the debugger to fail. However, we can disable this
69 on a per-process basis. Do that here.
71 See https://www.kernel.org/doc/Documentation/security/Yama.txt and prctl(2).
77 if not os.path.exists (
'/proc/sys/kernel/yama/ptrace_scope'):
return
80 with open(
'/proc/sys/kernel/yama/ptrace_scope')
as f:
81 if f.readline().strip() ==
'0':
85 from ctypes
import CDLL
86 libc = CDLL(
"libc.so.6")
89 libc.prctl (0x59616d61, 0xffffffffffffffff)