forked from qt-creator/qt-creator
Terminal: Support yama/ptrace_scope=1
We set "PR_SET_PTRACER" to "PR_SET_PTRACER_ANY" which will allow the debugger to attach to the inferior in both mode 0 and mode 1 of yama/ptrace_scope. Mode 2 and 3 are still not supported. Fixes: QTCREATORBUG-29554 Change-Id: I61d9ef3d9128f03769436010c6f250ccdada52bc Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
#ifdef Q_OS_LINUX
|
||||
#include <sys/ptrace.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/prctl.h>
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
@@ -260,7 +261,11 @@ void setupUnixInferior()
|
||||
});
|
||||
#else
|
||||
// PTRACE_TRACEME will stop execution of the child process as soon as execve is called.
|
||||
inferiorProcess.setChildProcessModifier([] { ptrace(PTRACE_TRACEME, 0, 0, 0); });
|
||||
inferiorProcess.setChildProcessModifier([] {
|
||||
ptrace(PTRACE_TRACEME, 0, 0, 0);
|
||||
// Disable attachment restrictions so we are not bound by yama/ptrace_scope mode 1
|
||||
prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY);
|
||||
});
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user