This is an archive of the discontinued LLVM Phabricator instance.

[lldb] [gdb-remote] Support reading notification packets
Needs ReviewPublic

Authored by mgorny on Aug 3 2022, 12:38 PM.



Add explicit support for reading (or skipping) notification packets
to GDBRemoteCommunication::ReadPacket(). Previously, the code would not
really distinguish between regular replies and notifications,
and would return the next packet to the caller without even a clear
indication whether it is a regular or notification packet.

Since the majority of existing call sites do not expect to read
notifications, add a new "allow_notification" parameter that defaults to
false. If it is false, then any notifications received from the server
are stashed onto a queue and the function waits for a regular reply
instead. If it is true, then the function either returns the first
notification queued previously or waits for any packet (either regular
or notification).

To make it possible to clearly distinguish between regular
and notification packets, add a new PacketResult::Notify. It is used
in lieu of PacketResult::Success when a notification packet is read.
While admittedly this is not the cleanest possible solution, it requires
minimal changes to the existing code. In the end, we expect only a few
call sites to actually expect and read notifications.

Split from the non-stop protocol support in D126614.

Sponsored by: The FreeBSD Foundation

Diff Detail