Files
David Spickett 157e886374 [lldb][test] Prevent TestqOffsets.py picking up host binaries (#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, select the remote-linux platform before creating the
target. This means we won't attempt any host lookups.

Fixes #155895
2025-09-09 09:30:29 +01:00

23 lines
845 B
Python

import lldb
from lldbsuite.test.lldbtest import *
from lldbsuite.test.decorators import *
from lldbsuite.test.gdbclientutils import *
from lldbsuite.test.lldbgdbclient import GDBRemoteTestBase
class TestqOffsets(GDBRemoteTestBase):
class Responder(MockGDBServerResponder):
def qOffsets(self):
return "Text=470000;Data=470000"
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)
process = self.connect(target)
self.assertEqual(text.GetLoadAddress(target), 0x471000)