|
LLDB mainline
|
Binder collects a table of functions that handle calls. More...
#include <JSONTransport.h>
Classes | |
| class | ReplyOnce |
| Function object to reply to a call. More... | |
Public Member Functions | |
| Binder (Transport &transport) | |
| Binder (const Binder &)=delete | |
| Binder & | operator= (const Binder &)=delete |
| template<typename Fn, typename... Args> | |
| void | OnDisconnect (Fn &&fn, Args &&...args) |
| Bind a handler on transport disconnect. | |
| template<typename Fn, typename... Args> | |
| void | OnError (Fn &&fn, Args &&...args) |
| Bind a handler on error when communicating with the transport. | |
| template<typename Result, typename Params, typename Fn, typename... Args> | |
| void | Bind (llvm::StringLiteral method, Fn &&fn, Args &&...args) |
| Bind a handler for an incoming request. | |
| template<typename Result, typename Params, typename Fn, typename... Args> | |
| void | BindAsync (llvm::StringLiteral method, Fn &&fn, Args &&...args) |
| Bind an asynchronous handler for an incoming request. | |
| template<typename Params, typename Fn, typename... Args> | |
| void | Bind (llvm::StringLiteral method, Fn &&fn, Args &&...args) |
| Bind a handler for an incoming event. | |
| template<typename Result, typename Params> | |
| OutgoingRequest< Result, Params > | Bind (llvm::StringLiteral method) |
| Bind a function object to be used for outgoing requests. | |
| template<typename Params> | |
| OutgoingEvent< Params > | Bind (llvm::StringLiteral method) |
| Bind a function object to be used for outgoing events. | |
| void | Received (const Evt &evt) override |
| Called when an event is received. | |
| void | Received (const Req &req) override |
| Called when a request is received. | |
| void | Received (const Resp &resp) override |
| Called when a response is received. | |
| void | OnError (llvm::Error err) override |
| Called when an error occurs while reading from the transport. | |
| void | OnClosed () override |
| Called on EOF or client disconnect. | |
| void | FailPendingRequests (llvm::StringRef reason) |
| Fails every in-flight outgoing request, invoking its reply with an error. | |
| Public Member Functions inherited from lldb_private::transport::JSONTransport< Proto >::MessageHandler | |
| virtual | ~MessageHandler ()=default |
Private Types | |
| using | Req = typename Proto::Req |
| using | Resp = typename Proto::Resp |
| using | Evt = typename Proto::Evt |
| using | Id = typename Proto::Id |
| using | Transport = JSONTransport<Proto> |
| using | MessageHandler = typename Transport::MessageHandler |
| template<typename T> | |
| using | Callback = llvm::unique_function<T> |
Static Private Member Functions | |
| template<typename T> | |
| static llvm::Expected< T > | Parse (const llvm::json::Value &raw, llvm::StringRef method) |
Private Attributes | |
| std::recursive_mutex | m_mutex |
| Transport & | m_transport |
| Id | m_seq |
| std::map< Id, Callback< void(const Resp &)> > | m_pending_responses |
| llvm::StringMap< Callback< void(const Req &, Callback< void(const Resp &)>)> > | m_request_handlers |
| llvm::StringMap< Callback< void(const Evt &)> > | m_event_handlers |
| Callback< void()> | m_disconnect_handler |
| Callback< void(llvm::Error)> | m_error_handler |
Binder collects a table of functions that handle calls.
The wrapper takes care of parsing/serializing responses.
This allows a JSONTransport to handle incoming and outgoing requests and events.
A bind of an incoming request to a lambda.
A bind of an outgoing request.
Definition at line 524 of file JSONTransport.h.
|
private |
Definition at line 659 of file JSONTransport.h.
|
private |
Definition at line 527 of file JSONTransport.h.
|
private |
Definition at line 528 of file JSONTransport.h.
|
private |
Definition at line 530 of file JSONTransport.h.
|
private |
Definition at line 525 of file JSONTransport.h.
|
private |
Definition at line 526 of file JSONTransport.h.
|
private |
Definition at line 529 of file JSONTransport.h.
|
inlineexplicit |
Definition at line 533 of file JSONTransport.h.
|
delete |
| OutgoingRequest< Result, Params > lldb_private::transport::Binder< Proto >::Bind | ( | llvm::StringLiteral | method | ) |
Bind a function object to be used for outgoing requests.
e.g. OutgoingRequest<Params, Result> Edit = bind("edit"); Params must be JSON-serializable, Result must be parsable.
Definition at line 835 of file JSONTransport.h.
References error(), m_mutex, m_pending_responses, m_seq, m_transport, OnError(), and Parse().
| OutgoingEvent< Params > lldb_private::transport::Binder< Proto >::Bind | ( | llvm::StringLiteral | method | ) |
Bind a function object to be used for outgoing events.
e.g. OutgoingEvent<LogParams> Log = bind("log"); LogParams must be JSON-serializable.
Definition at line 903 of file JSONTransport.h.
References error(), m_transport, OnError(), and lldb_private::toJSON().
| void lldb_private::transport::Binder< Proto >::Bind | ( | llvm::StringLiteral | method, |
| Fn && | fn, | ||
| Args &&... | args ) |
Bind a handler for an incoming request.
e.g. bind("peek", &ThisModule::peek, this);. Handler should be e.g. Expected<PeekResult> peek(const PeekParams&); PeekParams must be JSON parsable and PeekResult must be serializable.
Definition at line 748 of file JSONTransport.h.
References m_request_handlers, Parse(), and lldb_private::toJSON().
| void lldb_private::transport::Binder< Proto >::Bind | ( | llvm::StringLiteral | method, |
| Fn && | fn, | ||
| Args &&... | args ) |
Bind a handler for an incoming event.
e.g. bind("peek", &ThisModule::peek, this); Handler should be e.g. void peek(const PeekParams&); PeekParams must be JSON parsable.
Definition at line 809 of file JSONTransport.h.
References m_event_handlers, OnError(), and Parse().
| void lldb_private::transport::Binder< Proto >::BindAsync | ( | llvm::StringLiteral | method, |
| Fn && | fn, | ||
| Args &&... | args ) |
Bind an asynchronous handler for an incoming request.
The handler receives a Reply to invoke later instead of returning a result. This lets it defer the response, e.g. until a request it forwarded elsewhere is answered. Handler should be e.g. void peek(const PeekParams&, Reply<PeekResult>); PeekParams must be JSON parsable and PeekResult must be serializable.
Definition at line 945 of file JSONTransport.h.
References m_request_handlers, Parse(), and lldb_private::toJSON().
|
inline |
Fails every in-flight outgoing request, invoking its reply with an error.
Call when the connection is going away, so pending replies are satisfied rather than destroyed unanswered.
Definition at line 644 of file JSONTransport.h.
|
inlineoverridevirtual |
Called on EOF or client disconnect.
Implements lldb_private::transport::JSONTransport< Proto >::MessageHandler.
Definition at line 626 of file JSONTransport.h.
| void lldb_private::transport::Binder< Proto >::OnDisconnect | ( | Fn && | fn, |
| Args &&... | args ) |
Bind a handler on transport disconnect.
Definition at line 723 of file JSONTransport.h.
References m_disconnect_handler.
| void lldb_private::transport::Binder< Proto >::OnError | ( | Fn && | fn, |
| Args &&... | args ) |
Bind a handler on error when communicating with the transport.
Definition at line 735 of file JSONTransport.h.
References error(), and m_error_handler.
Referenced by Bind(), Bind(), lldb_private::transport::Binder< ProtocolDescriptor >::Received(), and lldb_private::transport::Binder< ProtocolDescriptor >::Received().
|
inlineoverridevirtual |
Called when an error occurs while reading from the transport.
NOTE: This does NOT indicate that a specific request failed, but that there was an error in the underlying transport.
Implements lldb_private::transport::JSONTransport< Proto >::MessageHandler.
Definition at line 620 of file JSONTransport.h.
|
delete |
|
staticprivate |
Definition at line 925 of file JSONTransport.h.
References lldb_private::fromJSON(), and lldb_private::OS.
Referenced by Bind(), Bind(), and BindAsync().
|
inlineoverridevirtual |
Called when an event is received.
Implements lldb_private::transport::JSONTransport< Proto >::MessageHandler.
Definition at line 580 of file JSONTransport.h.
|
inlineoverridevirtual |
Called when a request is received.
Implements lldb_private::transport::JSONTransport< Proto >::MessageHandler.
Definition at line 591 of file JSONTransport.h.
|
inlineoverridevirtual |
Called when a response is received.
Implements lldb_private::transport::JSONTransport< Proto >::MessageHandler.
Definition at line 605 of file JSONTransport.h.
|
private |
Definition at line 668 of file JSONTransport.h.
Referenced by OnDisconnect().
|
private |
Definition at line 669 of file JSONTransport.h.
Referenced by OnError(), and lldb_private::transport::Binder< ProtocolDescriptor >::OnError().
|
private |
Definition at line 667 of file JSONTransport.h.
Referenced by Bind().
|
private |
Definition at line 661 of file JSONTransport.h.
Referenced by Bind().
|
private |
Definition at line 664 of file JSONTransport.h.
Referenced by Bind().
|
private |
Definition at line 666 of file JSONTransport.h.
Referenced by Bind(), and BindAsync().
|
private |
Definition at line 663 of file JSONTransport.h.
Referenced by Bind().
|
private |
Definition at line 662 of file JSONTransport.h.
Referenced by Bind().