Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:42:41

0001 //===-- SBCommunication.h ---------------------------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef LLDB_API_SBCOMMUNICATION_H
0010 #define LLDB_API_SBCOMMUNICATION_H
0011 
0012 #include "lldb/API/SBDefines.h"
0013 #include "lldb/API/SBError.h"
0014 
0015 namespace lldb {
0016 
0017 class LLDB_API SBCommunication {
0018 public:
0019   FLAGS_ANONYMOUS_ENUM(){
0020       eBroadcastBitDisconnected =
0021           (1 << 0), ///< Sent when the communications connection is lost.
0022       eBroadcastBitReadThreadGotBytes =
0023           (1 << 1), ///< Sent by the read thread when bytes become available.
0024       eBroadcastBitReadThreadDidExit =
0025           (1
0026            << 2), ///< Sent by the read thread when it exits to inform clients.
0027       eBroadcastBitReadThreadShouldExit =
0028           (1 << 3), ///< Sent by clients that need to cancel the read thread.
0029       eBroadcastBitPacketAvailable =
0030           (1 << 4), ///< Sent when data received makes a complete packet.
0031       eAllEventBits = 0xffffffff};
0032 
0033   typedef void (*ReadThreadBytesReceived)(void *baton, const void *src,
0034                                           size_t src_len);
0035 
0036   SBCommunication();
0037   SBCommunication(const char *broadcaster_name);
0038   ~SBCommunication();
0039 
0040   explicit operator bool() const;
0041 
0042   bool IsValid() const;
0043 
0044   lldb::SBBroadcaster GetBroadcaster();
0045 
0046   static const char *GetBroadcasterClass();
0047 
0048   lldb::ConnectionStatus AdoptFileDesriptor(int fd, bool owns_fd);
0049 
0050   lldb::ConnectionStatus Connect(const char *url);
0051 
0052   lldb::ConnectionStatus Disconnect();
0053 
0054   bool IsConnected() const;
0055 
0056   bool GetCloseOnEOF();
0057 
0058   void SetCloseOnEOF(bool b);
0059 
0060   size_t Read(void *dst, size_t dst_len, uint32_t timeout_usec,
0061               lldb::ConnectionStatus &status);
0062 
0063   size_t Write(const void *src, size_t src_len, lldb::ConnectionStatus &status);
0064 
0065   bool ReadThreadStart();
0066 
0067   bool ReadThreadStop();
0068 
0069   bool ReadThreadIsRunning();
0070 
0071   bool SetReadThreadBytesReceivedCallback(ReadThreadBytesReceived callback,
0072                                           void *callback_baton);
0073 
0074 private:
0075   SBCommunication(const SBCommunication &) = delete;
0076   const SBCommunication &operator=(const SBCommunication &) = delete;
0077 
0078   lldb_private::ThreadedCommunication *m_opaque = nullptr;
0079   bool m_opaque_owned = false;
0080 };
0081 
0082 } // namespace lldb
0083 
0084 #endif // LLDB_API_SBCOMMUNICATION_H