]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm-project/lldb/include/lldb/API/SBCommunication.h
MFC r355940:
[FreeBSD/FreeBSD.git] / contrib / llvm-project / lldb / include / lldb / API / SBCommunication.h
1 //===-- SBCommunication.h ---------------------------------------*- C++ -*-===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
8
9 #ifndef LLDB_SBCommunication_h_
10 #define LLDB_SBCommunication_h_
11
12 #include "lldb/API/SBDefines.h"
13 #include "lldb/API/SBError.h"
14
15 namespace lldb {
16
17 class LLDB_API SBCommunication {
18 public:
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 =
25           (1
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};
32
33   typedef void (*ReadThreadBytesReceived)(void *baton, const void *src,
34                                           size_t src_len);
35
36   SBCommunication();
37   SBCommunication(const char *broadcaster_name);
38   ~SBCommunication();
39
40   explicit operator bool() const;
41
42   bool IsValid() const;
43
44   lldb::SBBroadcaster GetBroadcaster();
45
46   static const char *GetBroadcasterClass();
47
48   lldb::ConnectionStatus AdoptFileDesriptor(int fd, bool owns_fd);
49
50   lldb::ConnectionStatus Connect(const char *url);
51
52   lldb::ConnectionStatus Disconnect();
53
54   bool IsConnected() const;
55
56   bool GetCloseOnEOF();
57
58   void SetCloseOnEOF(bool b);
59
60   size_t Read(void *dst, size_t dst_len, uint32_t timeout_usec,
61               lldb::ConnectionStatus &status);
62
63   size_t Write(const void *src, size_t src_len, lldb::ConnectionStatus &status);
64
65   bool ReadThreadStart();
66
67   bool ReadThreadStop();
68
69   bool ReadThreadIsRunning();
70
71   bool SetReadThreadBytesReceivedCallback(ReadThreadBytesReceived callback,
72                                           void *callback_baton);
73
74 private:
75   DISALLOW_COPY_AND_ASSIGN(SBCommunication);
76
77   lldb_private::Communication *m_opaque;
78   bool m_opaque_owned;
79 };
80
81 } // namespace lldb
82
83 #endif // LLDB_SBCommunication_h_