1 //===-- SBCommunication.h ---------------------------------------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #ifndef LLDB_SBCommunication_h_ 11 #define LLDB_SBCommunication_h_ 12 13 #include "lldb/API/SBDefines.h" 14 #include "lldb/API/SBError.h" 15 16 namespace lldb { 17 18 class SBCommunication 19 { 20 public: 21 enum { 22 eBroadcastBitDisconnected = (1 << 0), ///< Sent when the communications connection is lost. 23 eBroadcastBitReadThreadGotBytes = (1 << 1), ///< Sent by the read thread when bytes become available. 24 eBroadcastBitReadThreadDidExit = (1 << 2), ///< Sent by the read thread when it exits to inform clients. 25 eBroadcastBitReadThreadShouldExit = (1 << 3), ///< Sent by clients that need to cancel the read thread. 26 eBroadcastBitPacketAvailable = (1 << 4), ///< Sent when data received makes a complete packet. 27 eAllEventBits = 0xffffffff 28 }; 29 30 typedef void (*ReadThreadBytesReceived) (void *baton, const void *src, size_t src_len); 31 32 SBCommunication (); 33 SBCommunication (const char * broadcaster_name); 34 ~SBCommunication (); 35 36 37 bool 38 IsValid () const; 39 40 lldb::SBBroadcaster 41 GetBroadcaster (); 42 43 static const char *GetBroadcasterClass(); 44 45 lldb::ConnectionStatus 46 AdoptFileDesriptor (int fd, bool owns_fd); 47 48 lldb::ConnectionStatus 49 Connect (const char *url); 50 51 lldb::ConnectionStatus 52 Disconnect (); 53 54 bool 55 IsConnected () const; 56 57 bool 58 GetCloseOnEOF (); 59 60 void 61 SetCloseOnEOF (bool b); 62 63 size_t 64 Read (void *dst, 65 size_t dst_len, 66 uint32_t timeout_usec, 67 lldb::ConnectionStatus &status); 68 69 size_t 70 Write (const void *src, 71 size_t src_len, 72 lldb::ConnectionStatus &status); 73 74 bool 75 ReadThreadStart (); 76 77 bool 78 ReadThreadStop (); 79 80 bool 81 ReadThreadIsRunning (); 82 83 bool 84 SetReadThreadBytesReceivedCallback (ReadThreadBytesReceived callback, 85 void *callback_baton); 86 87 88 private: 89 90 DISALLOW_COPY_AND_ASSIGN (SBCommunication); 91 92 lldb_private::Communication *m_opaque; 93 bool m_opaque_owned; 94 }; 95 96 97 } // namespace lldb 98 99 #endif // LLDB_SBCommunication_h_ 100