This is an archive of the discontinued LLVM Phabricator instance.

[lldb-server] Exit the DataAvailableCallback loop when `done` or `interrupt` are set
AbandonedPublic

Authored by JDevlieghere on Feb 18 2021, 7:06 PM.

Details

Reviewers
labath
omjavaid
Summary

When looking at GDBRemoteCommunicationServerLLGS::DataAvailableCallback I noticed that the done and interrupt flags are currently being ignored. I assumed the reason is that GetPacketAndSendResponse always returns either PacketResult::Success or PacketResult::ErrorReplyTimeout but there are plenty of code paths that return PacketResult::Success but set done or interrupt to true.

Diff Detail

Repository
rLLDB LLDB

Event Timeline

JDevlieghere requested review of this revision.Feb 18 2021, 7:06 PM
JDevlieghere created this revision.
omjavaid added inline comments.Feb 19 2021, 12:21 AM
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
950

May be we can set m_exit_now instead of setting done, or interrupt. if we have to exit on empty response.

1064

GDBRemoteCommunicationServer::GetPacketAndSendResponse sets done on eServerPacketType_invalid (empty packet) wouldnt termination be too strict for that case.

What are the situations where we set done or interrupt? The ones I could find are:

  • the k packet. This packet is (for good reasons) specified very vaguely. The spec says it should have no reply, but lldb will actually try to listen for a reply anyway. I think that making lldb-server stop sending the k reply might be a good thing (for protocol conformance), but that still doesn't mean we should exit immediately after receiving it. The ideal behavior would be to wait(2) for the inferior, and only exit after it has been reaped properly.
  • the interrupt (^C) packet in the platform personality. I'm not sure that we ever actually send this packet on platform connections, but even if we did, exiting does not seem like the proper response.

So overall, I'm not sure that this patch is really a good idea.

lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
1064

Possibly. Although, I don't think a well-behaved client should ever be sending an empty packet, so terminating the connection when it does send it, wouldn't be too bad imo.

omjavaid resigned from this revision.Jul 11 2021, 9:26 PM
JDevlieghere abandoned this revision.Jul 20 2021, 1:09 PM