https://github.com/DavidSpickett created 
https://github.com/llvm/llvm-project/pull/157432

Due to a fallback in GDBRemoteCommunicationClient.cpp, on Linux we will assume 
a PID of 1 if the remote does not respond in some way that tells us the real 
PID.

So if PID 1 happened to be a process that the current user could read, we would 
try to debug that instead. On my current machine, PID 1 was sshd run by root so 
we would ignore it. If I changed the fallback to some process ID run by my 
user, the test would fail.

To prevent this, return something to LLDB that tells it there is no remote PID, 
preventing the host lookup.

Fixes #155895

>From c0f08a5823327e83f17e921e65d6234ce98fce6b Mon Sep 17 00:00:00 2001
From: David Spickett <david.spick...@linaro.org>
Date: Mon, 8 Sep 2025 11:41:33 +0000
Subject: [PATCH] [lldb][test] Prevent TestqOffsets.py picking up host binaries

Due to a fallback in GDBRemoteCommunicationClient.cpp, on Linux we
will assume a PID of 1 if the remote does not respond in some
way that tells us the real PID.

So if PID 1 happened to be a process that the current user could
read, we would try to debug that instead. On my current machine,
PID 1 was sshd run by root so we would ignore it. If I changed
the fallback to some process ID run by my user, the test would fail.

To prevent this, return something to LLDB that tells it there is
no remote PID, preventing the host lookup.

Fixes #155895
---
 .../API/functionalities/gdb_remote_client/TestqOffsets.py    | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/lldb/test/API/functionalities/gdb_remote_client/TestqOffsets.py 
b/lldb/test/API/functionalities/gdb_remote_client/TestqOffsets.py
index a1adc20e864ba..e069f10b19e1e 100644
--- a/lldb/test/API/functionalities/gdb_remote_client/TestqOffsets.py
+++ b/lldb/test/API/functionalities/gdb_remote_client/TestqOffsets.py
@@ -10,6 +10,11 @@ class Responder(MockGDBServerResponder):
         def qOffsets(self):
             return "Text=470000;Data=470000"
 
+        def qfThreadInfo(self):
+            # Prevent LLDB defaulting to PID of 1 and looking up some other
+            # process when on an AArch64 host.
+            return "m-1"
+
     def test(self):
         self.server.responder = TestqOffsets.Responder()
         target = self.createTarget("qOffsets.yaml")

_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to