LLDB mainline
|
An IOTransport sends and receives messages using an IOObject. More...
#include <JSONTransport.h>
Public Types | |
using | Message = typename JSONTransport<Proto>::Message |
using | MessageHandler = typename JSONTransport<Proto>::MessageHandler |
Public Types inherited from lldb_private::transport::JSONTransport< Proto > | |
using | Req = typename Proto::Req |
using | Resp = typename Proto::Resp |
using | Evt = typename Proto::Evt |
using | Message = std::variant<Req, Resp, Evt> |
Public Member Functions | |
IOTransport (lldb::IOObjectSP in, lldb::IOObjectSP out) | |
llvm::Error | Send (const typename Proto::Evt &evt) override |
llvm::Error | Send (const typename Proto::Req &req) override |
llvm::Error | Send (const typename Proto::Resp &resp) override |
llvm::Expected< MainLoop::ReadHandleUP > | RegisterMessageHandler (MainLoop &loop, MessageHandler &handler) override |
RegisterMessageHandler registers the Transport with the given MainLoop and handles any incoming messages using the given MessageHandler. | |
Public Member Functions inherited from lldb_private::transport::JSONTransport< Proto > | |
virtual | ~JSONTransport ()=default |
virtual llvm::Error | Send (const Evt &)=0 |
Sends an event, a message that does not require a response. | |
virtual llvm::Error | Send (const Req &)=0 |
Sends a request, a message that expects a response. | |
virtual llvm::Error | Send (const Resp &)=0 |
Sends a response to a specific request. |
Static Public Attributes | |
static constexpr size_t | kReadBufferSize = 1024 |
Public for testing purposes, otherwise this should be an implementation detail. |
Protected Member Functions | |
llvm::Error | Write (const llvm::json::Value &message) |
virtual llvm::Expected< std::vector< std::string > > | Parse ()=0 |
virtual std::string | Encode (const llvm::json::Value &message)=0 |
Protected Member Functions inherited from lldb_private::transport::JSONTransport< Proto > | |
template<typename... Ts> | |
auto | Logv (const char *Fmt, Ts &&...Vals) |
virtual void | Log (llvm::StringRef message)=0 |
Protected Attributes | |
llvm::SmallString< kReadBufferSize > | m_buffer |
Private Member Functions | |
void | OnRead (MainLoopBase &loop, MessageHandler &handler) |
Private Attributes | |
lldb::IOObjectSP | m_in |
lldb::IOObjectSP | m_out |
An IOTransport sends and receives messages using an IOObject.
Definition at line 180 of file JSONTransport.h.
using lldb_private::transport::IOTransport< Proto >::Message = typename JSONTransport<Proto>::Message |
Definition at line 182 of file JSONTransport.h.
using lldb_private::transport::IOTransport< Proto >::MessageHandler = typename JSONTransport<Proto>::MessageHandler |
Definition at line 183 of file JSONTransport.h.
|
inline |
Definition at line 185 of file JSONTransport.h.
|
protectedpure virtual |
|
inlineprivate |
Definition at line 230 of file JSONTransport.h.
References error(), kReadBufferSize, m_buffer, m_in, and Parse().
Referenced by RegisterMessageHandler().
|
protectedpure virtual |
|
inlineoverridevirtual |
RegisterMessageHandler registers the Transport with the given MainLoop and handles any incoming messages using the given MessageHandler.
If an unexpected error occurs, the MainLoop will be terminated and a log message will include additional information about the termination reason.
Implements lldb_private::transport::JSONTransport< Proto >.
Definition at line 199 of file JSONTransport.h.
References lldb_private::Status::Fail(), m_in, OnRead(), lldb_private::MainLoopPosix::RegisterReadObject(), and lldb_private::Status::takeError().
|
inlineoverride |
Definition at line 188 of file JSONTransport.h.
References Write().
|
inlineoverride |
Definition at line 191 of file JSONTransport.h.
References Write().
|
inlineoverride |
Definition at line 194 of file JSONTransport.h.
References Write().
|
inlineprotected |
Definition at line 217 of file JSONTransport.h.
References Encode(), lldb_private::transport::JSONTransport< Proto >::Logv(), and m_out.
|
staticconstexpr |
Public for testing purposes, otherwise this should be an implementation detail.
Definition at line 214 of file JSONTransport.h.
Referenced by OnRead().
|
protected |
Definition at line 227 of file JSONTransport.h.
Referenced by OnRead(), lldb_private::transport::HTTPDelimitedJSONTransport< Proto >::Parse(), and lldb_private::transport::JSONRPCTransport< Proto >::Parse().
|
private |
Definition at line 271 of file JSONTransport.h.
Referenced by IOTransport(), OnRead(), and RegisterMessageHandler().
|
private |
Definition at line 272 of file JSONTransport.h.
Referenced by IOTransport(), and Write().