• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===-- SWIG Interface for SBCommunication ----------------------*- 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 namespace lldb {
10 
11 class SBCommunication
12 {
13 public:
14     enum {
15         eBroadcastBitDisconnected           = (1 << 0), ///< Sent when the communications connection is lost.
16         eBroadcastBitReadThreadGotBytes     = (1 << 1), ///< Sent by the read thread when bytes become available.
17         eBroadcastBitReadThreadDidExit      = (1 << 2), ///< Sent by the read thread when it exits to inform clients.
18         eBroadcastBitReadThreadShouldExit   = (1 << 3), ///< Sent by clients that need to cancel the read thread.
19         eBroadcastBitPacketAvailable        = (1 << 4), ///< Sent when data received makes a complete packet.
20         eAllEventBits                       = 0xffffffff
21     };
22 
23     typedef void (*ReadThreadBytesReceived) (void *baton, const void *src, size_t src_len);
24 
25     SBCommunication ();
26     SBCommunication (const char * broadcaster_name);
27    ~SBCommunication ();
28 
29 
30     bool
31     IsValid () const;
32 
33     explicit operator bool() const;
34 
35     lldb::SBBroadcaster
36     GetBroadcaster ();
37 
38     static const char *GetBroadcasterClass();
39 
40     lldb::ConnectionStatus
41     AdoptFileDesriptor (int fd, bool owns_fd);
42 
43     lldb::ConnectionStatus
44     Connect (const char *url);
45 
46     lldb::ConnectionStatus
47     Disconnect ();
48 
49     bool
50     IsConnected () const;
51 
52     bool
53     GetCloseOnEOF ();
54 
55     void
56     SetCloseOnEOF (bool b);
57 
58     size_t
59     Read (void *dst,
60           size_t dst_len,
61           uint32_t timeout_usec,
62           lldb::ConnectionStatus &status);
63 
64     size_t
65     Write (const void *src,
66            size_t src_len,
67            lldb::ConnectionStatus &status);
68 
69     bool
70     ReadThreadStart ();
71 
72     bool
73     ReadThreadStop ();
74 
75     bool
76     ReadThreadIsRunning ();
77 
78     bool
79     SetReadThreadBytesReceivedCallback (ReadThreadBytesReceived callback,
80                                         void *callback_baton);
81 };
82 
83 } // namespace lldb
84