1 parent b3f9080 commit 0268f84Copy full SHA for 0268f84
1 file changed
ptrlib/debugger/unix/debug.py
@@ -14,7 +14,8 @@
14
logger = getLogger(__name__)
15
16
CUSTOM_SUDO_PROMPT = "[sudo] password: "
17
-GDB_PTRACE_ERROR = b"ptrace: Operation not permitted.\n"
+GDB_ATTACH_MSG = b"Attaching to process "
18
+GDB_PTRACE_ERROR = b"ptrace: "
19
ANSI_RE = re.compile(rb'\x1B\[[0-?]*[ -/]*[@-~]')
20
CTRL_RE = re.compile(rb'[\x00-\x08\x0B-\x1F]')
21
@@ -84,6 +85,7 @@ def pid(self) -> int:
84
85
86
def _attach_direct(self):
87
self._gdb = unix_process()(["gdb", "-q", "-p", str(self._pid)])
88
+ self._gdb.recvuntil(GDB_ATTACH_MSG)
89
init_msg = self._gdb.recvuntil(self._gdb_prompt, lookahead=True)
90
if GDB_PTRACE_ERROR in init_msg:
91
raise PermissionError(f"Cannot attach pid={self._pid}")
0 commit comments