Skip to content

Commit dfcd21a

Browse files
committed
This test was incorrectly assuming that by the time connect to a
gdb-server was complete, lldb MUST have fetched the complete register state for the stopped thread. There's no reason why it has to do that (especially since we get the PC from the stop message). In a previous patch, I made it not unnecessarily pull the full register contect, causing this test to fail. This commit changes the test to only require the 'g' packet AFTER we had done 'read_register'.
1 parent aadd0d3 commit dfcd21a

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,32 @@ def test_read_registers_using_g_packets(self):
132132
target = self.createTarget("a.yaml")
133133
process = self.connect(target)
134134

135-
self.assertEqual(1, self.server.responder.packetLog.count("g"))
136-
self.server.responder.packetLog = []
135+
# We want to make sure that the process is using the g packet, but it's
136+
# not required the "connect" should read all registers. However, it might
137+
# have... So we need to wait till we explicitly 'read_registers' to do
138+
# test.
139+
# Also, even with the use-g-packet-for-reading lldb will sometimes send p0
140+
# early on to see if the packet is supported. So we can't say that there
141+
# will be NO p packets.
142+
# But there certainly should be no p packets after the g packet.
143+
137144
self.read_registers(process)
138-
# Reading registers should not cause any 'p' packets to be exchanged.
145+
print(f"\nPACKET LOG:\n{self.server.responder.packetLog}\n")
146+
g_pos = 0
147+
try:
148+
g_pos = self.server.responder.packetLog.index("g")
149+
except err:
150+
self.fail("'g' packet not found after fetching registers")
151+
152+
try:
153+
second_g = self.server.responder.packetLog.index("g", g_pos)
154+
self.fail("Found more than one 'g' packet")
155+
except:
156+
pass
157+
158+
# Make sure there aren't any `p` packets after the `g` packet:
139159
self.assertEqual(
140-
0, len([p for p in self.server.responder.packetLog if p.startswith("p")])
160+
0, len([p for p in self.server.responder.packetLog[g_pos:] if p.startswith("p")])
141161
)
142162

143163
def test_read_registers_using_p_packets(self):

0 commit comments

Comments
 (0)