1 //===-- SBCommunication.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 LLDB_SBCommunication_h_
10 #define LLDB_SBCommunication_h_
12 #include "lldb/API/SBDefines.h"
13 #include "lldb/API/SBError.h"
17 class LLDB_API SBCommunication {
19 FLAGS_ANONYMOUS_ENUM(){
20 eBroadcastBitDisconnected =
21 (1 << 0), ///< Sent when the communications connection is lost.
22 eBroadcastBitReadThreadGotBytes =
23 (1 << 1), ///< Sent by the read thread when bytes become available.
24 eBroadcastBitReadThreadDidExit =
26 << 2), ///< Sent by the read thread when it exits to inform clients.
27 eBroadcastBitReadThreadShouldExit =
28 (1 << 3), ///< Sent by clients that need to cancel the read thread.
29 eBroadcastBitPacketAvailable =
30 (1 << 4), ///< Sent when data received makes a complete packet.
31 eAllEventBits = 0xffffffff};
33 typedef void (*ReadThreadBytesReceived)(void *baton, const void *src,
37 SBCommunication(const char *broadcaster_name);
40 explicit operator bool() const;
44 lldb::SBBroadcaster GetBroadcaster();
46 static const char *GetBroadcasterClass();
48 lldb::ConnectionStatus AdoptFileDesriptor(int fd, bool owns_fd);
50 lldb::ConnectionStatus Connect(const char *url);
52 lldb::ConnectionStatus Disconnect();
54 bool IsConnected() const;
58 void SetCloseOnEOF(bool b);
60 size_t Read(void *dst, size_t dst_len, uint32_t timeout_usec,
61 lldb::ConnectionStatus &status);
63 size_t Write(const void *src, size_t src_len, lldb::ConnectionStatus &status);
65 bool ReadThreadStart();
67 bool ReadThreadStop();
69 bool ReadThreadIsRunning();
71 bool SetReadThreadBytesReceivedCallback(ReadThreadBytesReceived callback,
72 void *callback_baton);
75 DISALLOW_COPY_AND_ASSIGN(SBCommunication);
77 lldb_private::Communication *m_opaque;
83 #endif // LLDB_SBCommunication_h_