1 //===-- GDBRemoteCommunicationReplayServer.h --------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #ifndef liblldb_GDBRemoteCommunicationReplayServer_h_
10 #define liblldb_GDBRemoteCommunicationReplayServer_h_
12 // Other libraries and framework includes
13 #include "GDBRemoteCommunication.h"
14 #include "GDBRemoteCommunicationHistory.h"
17 #include "lldb/Host/HostThread.h"
18 #include "lldb/Utility/Broadcaster.h"
19 #include "lldb/lldb-private-forward.h"
20 #include "llvm/Support/Error.h"
28 class StringExtractorGDBRemote;
30 namespace lldb_private {
31 namespace process_gdb_remote {
33 class ProcessGDBRemote;
35 /// Dummy GDB server that replays packets from the GDB Remote Communication
36 /// history. This is used to replay GDB packets.
37 class GDBRemoteCommunicationReplayServer : public GDBRemoteCommunication {
39 GDBRemoteCommunicationReplayServer();
41 ~GDBRemoteCommunicationReplayServer() override;
43 PacketResult GetPacketAndSendResponse(Timeout<std::micro> timeout,
44 Status &error, bool &interrupt,
47 bool HandshakeWithClient() { return GetAck() == PacketResult::Success; }
49 llvm::Error LoadReplayHistory(const FileSpec &path);
51 bool StartAsyncThread();
52 void StopAsyncThread();
56 eBroadcastBitAsyncContinue = (1 << 0),
57 eBroadcastBitAsyncThreadShouldExit = (1 << 1),
60 static void ReceivePacket(GDBRemoteCommunicationReplayServer &server,
62 static lldb::thread_result_t AsyncThread(void *arg);
64 /// Replay history with the oldest packet at the end.
65 std::vector<GDBRemoteCommunicationHistory::Entry> m_packet_history;
68 Broadcaster m_async_broadcaster;
69 lldb::ListenerSP m_async_listener_sp;
70 HostThread m_async_thread;
71 std::recursive_mutex m_async_thread_state_mutex;
76 DISALLOW_COPY_AND_ASSIGN(GDBRemoteCommunicationReplayServer);
79 } // namespace process_gdb_remote
80 } // namespace lldb_private
82 #endif // liblldb_GDBRemoteCommunicationReplayServer_h_