diff options
author | Michał Górny <mgorny@moritz.systems> | 2022-04-12 16:21:09 +0200 |
---|---|---|
committer | Michał Górny <mgorny@moritz.systems> | 2022-06-21 19:04:20 +0200 |
commit | bc04d240850bab340341eaf3601c5ca996667319 (patch) | |
tree | 944278a6b1a29d3be9e2f3c7dd0f24397fe6c1b4 /lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h | |
parent | eb12ad9d7ff64398add1a9cc84e56cc20aed09f8 (diff) | |
download | llvm-bc04d240850bab340341eaf3601c5ca996667319.zip llvm-bc04d240850bab340341eaf3601c5ca996667319.tar.gz llvm-bc04d240850bab340341eaf3601c5ca996667319.tar.bz2 |
[lldb] [llgs] Implement non-stop style stop notification packets
Implement the support for %Stop asynchronous notification packet format
in LLGS. This does not implement full support for non-stop mode for
threaded programs -- process plugins continue stopping all threads
on every event. However, it will be used to implement asynchronous
events in multiprocess debugging.
The non-stop protocol is enabled using QNonStop packet. When it is
enabled, the server uses notification protocol instead of regular stop
replies. Since all threads are always stopped, notifications are always
generated for all active threads and copied into stop notification
queue.
If the queue was empty, the initial asynchronous %Stop notification
is sent to the client immediately. The client needs to (eventually)
acknowledge the notification by sending the vStopped packet, in which
case it is popped from the queue and the stop reason for the next thread
is reported. This continues until notification queue is empty again,
in which case an OK reply is sent.
Asychronous notifications are also used for vAttach results and program
exits. The `?` packet uses a hybrid approach -- it returns the first
stop reason synchronously, and exposes the stop reasons for remaining
threads via vStopped queue.
The change includes a test case for a program generating a segfault
on 3 threads. The server is expected to generate a stop notification
for the segfaulting thread, along with the notifications for the other
running threads (with "no stop reason"). This verifies that the stop
reasons are correctly reported for all threads, and that notification
queue works.
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.llvm.org/D125575
Diffstat (limited to 'lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h')
-rw-r--r-- | lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h index e226714..6a2ef89 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h @@ -106,6 +106,8 @@ protected: uint32_t m_next_saved_registers_id = 1; bool m_thread_suffix_supported = false; bool m_list_threads_in_stop_reply = false; + bool m_non_stop = false; + std::deque<std::string> m_stop_notification_queue; NativeProcessProtocol::Extension m_extensions_supported = {}; @@ -113,11 +115,17 @@ protected: PacketResult SendWResponse(NativeProcessProtocol *process); + StreamString PrepareStopReplyPacketForThread(NativeThreadProtocol &thread); + PacketResult SendStopReplyPacketForThread(NativeProcessProtocol &process, - lldb::tid_t tid); + lldb::tid_t tid, + bool force_synchronous); PacketResult SendStopReasonForState(NativeProcessProtocol &process, - lldb::StateType process_state); + lldb::StateType process_state, + bool force_synchronous); + + void EnqueueStopReplyPackets(lldb::tid_t thread_to_skip); PacketResult Handle_k(StringExtractorGDBRemote &packet); @@ -219,6 +227,12 @@ protected: PacketResult Handle_qSaveCore(StringExtractorGDBRemote &packet); + PacketResult Handle_QNonStop(StringExtractorGDBRemote &packet); + + PacketResult Handle_vStopped(StringExtractorGDBRemote &packet); + + PacketResult Handle_vCtrlC(StringExtractorGDBRemote &packet); + PacketResult Handle_g(StringExtractorGDBRemote &packet); PacketResult Handle_qMemTags(StringExtractorGDBRemote &packet); @@ -246,6 +260,10 @@ protected: std::vector<std::string> HandleFeatures( const llvm::ArrayRef<llvm::StringRef> client_features) override; + // Provide a response for successful continue action, i.e. send "OK" + // in non-stop mode, no response otherwise. + PacketResult SendContinueSuccessResponse(); + private: llvm::Expected<std::unique_ptr<llvm::MemoryBuffer>> BuildTargetXml(); |