[lldb] [Windows] Let LLGS TestClient tolerate async `O` output packets (#225521)
My PR (swiftlang/llvm-project#14269) has a pre-merge test failure on
Windows, and that lead me looking at test LLGSTest.cpp deeply
```
Send Packet: vCont;c
Read Packet: O1b5b3f32356c
lldb-server exiting...
LLGSTest.cpp(30): error: Value of:
llvm::detail::TakeError(Client.ContinueAll())
Expected: succeeded
Actual: failed (Unable to parse StopReply: Invalid packet)
```
`TestClient::SendMessage` read exactly one packet and had no handling
for `O`
(inferior stdout) packets, but inferior output arriving before a stop
reply
was parsed as the stop reply itself. `StopReply::create` accepts only
`T` and
`W`, so it failed. The `O1b5b3f32356c` decodes to `ESC [ ? 2 5 l`, the
sequence that hides the cursor. Windows lldb-server gives the inferior a
ConPTY
created with `PSEUDOCONSOLE_INHERIT_CURSOR`, and ConPTY writes its own
VT
initialization bytes to the output pipe, which reach the client as an
`O` packet.
The fix is that `SendMessage` now uses the inherited
`SendPacketAndReceiveResponseWithOutputSupport`, which loops over
leading `O`
packets via `ReadPacketWithOutputSupport` and passes each payload to a
callback. `TestClient::Continue` had the same gap in the opposite order:
after a
`W` or `X` reply it read one raw packet and required
`ErrorDisconnected`, so an `O`
packet arriving before the socket closed failed the test. It now reads
through
`ReadPacketWithOutputSupport` as well.
The fix reverts 5032c6ea0803 ("[lldb-server] Disable a test on Windows
until it can be
fixed"), which disabled `LaunchModePreservesEnvironment` on Windows.
18b211cb1521 ("Disable stdin/stdout for environment_check inferior
process")
worked around the same root cause from a different source, where an
allocator
message on stderr under sanitizers reached the client the same way. That
commit noted the client "doesn't handle that unexpected output"; this
handles
it.
Assisted-by: claude
GitOrigin-RevId: 29ce634abb29fc59a147e63e72426c343becf4f9
2 files changed