SBCommunication.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. #ifndef LLDB_API_SBCOMMUNICATION_H
  9. #define LLDB_API_SBCOMMUNICATION_H
  10. #include "lldb/API/SBDefines.h"
  11. #include "lldb/API/SBError.h"
  12. namespace lldb {
  13. class LLDB_API SBCommunication {
  14. public:
  15. FLAGS_ANONYMOUS_ENUM(){
  16. eBroadcastBitDisconnected =
  17. (1 << 0), ///< Sent when the communications connection is lost.
  18. eBroadcastBitReadThreadGotBytes =
  19. (1 << 1), ///< Sent by the read thread when bytes become available.
  20. eBroadcastBitReadThreadDidExit =
  21. (1
  22. << 2), ///< Sent by the read thread when it exits to inform clients.
  23. eBroadcastBitReadThreadShouldExit =
  24. (1 << 3), ///< Sent by clients that need to cancel the read thread.
  25. eBroadcastBitPacketAvailable =
  26. (1 << 4), ///< Sent when data received makes a complete packet.
  27. eAllEventBits = 0xffffffff};
  28. typedef void (*ReadThreadBytesReceived)(void *baton, const void *src,
  29. size_t src_len);
  30. SBCommunication();
  31. SBCommunication(const char *broadcaster_name);
  32. ~SBCommunication();
  33. explicit operator bool() const;
  34. bool IsValid() const;
  35. lldb::SBBroadcaster GetBroadcaster();
  36. static const char *GetBroadcasterClass();
  37. lldb::ConnectionStatus AdoptFileDesriptor(int fd, bool owns_fd);
  38. lldb::ConnectionStatus Connect(const char *url);
  39. lldb::ConnectionStatus Disconnect();
  40. bool IsConnected() const;
  41. bool GetCloseOnEOF();
  42. void SetCloseOnEOF(bool b);
  43. size_t Read(void *dst, size_t dst_len, uint32_t timeout_usec,
  44. lldb::ConnectionStatus &status);
  45. size_t Write(const void *src, size_t src_len, lldb::ConnectionStatus &status);
  46. bool ReadThreadStart();
  47. bool ReadThreadStop();
  48. bool ReadThreadIsRunning();
  49. bool SetReadThreadBytesReceivedCallback(ReadThreadBytesReceived callback,
  50. void *callback_baton);
  51. private:
  52. SBCommunication(const SBCommunication &) = delete;
  53. const SBCommunication &operator=(const SBCommunication &) = delete;
  54. lldb_private::Communication *m_opaque;
  55. bool m_opaque_owned;
  56. };
  57. } // namespace lldb
  58. #endif // LLDB_API_SBCOMMUNICATION_H