[Lldb-commits] [lldb] [lldb][test] Prevent TestqOffsets.py picking up host binaries (PR #157432)

David Spickett via lldb-commits lldb-commits at lists.llvm.org
Mon Sep 8 07:08:30 PDT 2025


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

>From c0f08a5823327e83f17e921e65d6234ce98fce6b Mon Sep 17 00:00:00 2001
From: David Spickett <david.spickett at linaro.org>
Date: Mon, 8 Sep 2025 11:41:33 +0000
Subject: [PATCH 1/2] [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")

>From 040fcd7a26fabce2291a4cff8103c55df444ba79 Mon Sep 17 00:00:00 2001
From: David Spickett <david.spickett at linaro.org>
Date: Mon, 8 Sep 2025 14:07:48 +0000
Subject: [PATCH 2/2] platform select instead

---
 .../API/functionalities/gdb_remote_client/TestqOffsets.py  | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/lldb/test/API/functionalities/gdb_remote_client/TestqOffsets.py b/lldb/test/API/functionalities/gdb_remote_client/TestqOffsets.py
index e069f10b19e1e..629361c6ae5b8 100644
--- a/lldb/test/API/functionalities/gdb_remote_client/TestqOffsets.py
+++ b/lldb/test/API/functionalities/gdb_remote_client/TestqOffsets.py
@@ -10,13 +10,10 @@ 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()
+        # This ensures that we do not pick up any binaries on the host.
+        self.runCmd("platform select remote-linux")
         target = self.createTarget("qOffsets.yaml")
         text = target.modules[0].FindSection(".text")
         self.assertEqual(text.GetLoadAddress(target), lldb.LLDB_INVALID_ADDRESS)



More information about the lldb-commits mailing list