LLDB  mainline
GDBRemoteCommunicationServer.h
Go to the documentation of this file.
1 //===-- GDBRemoteCommunicationServer.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 
9 #ifndef LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTECOMMUNICATIONSERVER_H
10 #define LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTECOMMUNICATIONSERVER_H
11 
12 #include <functional>
13 #include <map>
14 
15 #include "GDBRemoteCommunication.h"
17 
18 #include "llvm/Support/Errc.h"
19 #include "llvm/Support/Error.h"
20 
22 
23 namespace lldb_private {
24 namespace process_gdb_remote {
25 
26 class ProcessGDBRemote;
27 
29 public:
30  using PacketHandler =
31  std::function<PacketResult(StringExtractorGDBRemote &packet,
32  Status &error, bool &interrupt, bool &quit)>;
33 
34  GDBRemoteCommunicationServer(const char *comm_name,
35  const char *listener_name);
36 
38 
39  void
41  PacketHandler handler);
42 
44  Status &error, bool &interrupt,
45  bool &quit);
46 
47 protected:
48  std::map<StringExtractorGDBRemote::ServerPacketType, PacketHandler>
50  bool m_exit_now; // use in asynchronous handling to indicate process should
51  // exit.
52 
53  bool m_send_error_strings = false; // If the client enables this then
54  // we will send error strings as well.
55 
57 
59 
61 
62  PacketResult SendUnimplementedResponse(const char *packet);
63 
65 
67  const char *error_message);
68 
70 
71  /// Serialize and send a JSON object response.
72  PacketResult SendJSONResponse(const llvm::json::Value &value);
73 
74  /// Serialize and send a JSON object response, or respond with an error if the
75  /// input object is an \a llvm::Error.
76  PacketResult SendJSONResponse(llvm::Expected<llvm::json::Value> value);
77 
78 private:
81  operator=(const GDBRemoteCommunicationServer &) = delete;
82 };
83 
84 } // namespace process_gdb_remote
85 } // namespace lldb_private
86 
87 #endif // LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTECOMMUNICATIONSERVER_H
lldb_private::process_gdb_remote::GDBRemoteCommunicationServer::SendErrorResponse
PacketResult SendErrorResponse(const Status &error)
Definition: GDBRemoteCommunicationServer.cpp:106
lldb_private::process_gdb_remote::GDBRemoteCommunicationServer::RegisterPacketHandler
void RegisterPacketHandler(StringExtractorGDBRemote::ServerPacketType packet_type, PacketHandler handler)
Definition: GDBRemoteCommunicationServer.cpp:38
lldb_private::process_gdb_remote::GDBRemoteCommunication::PacketResult
PacketResult
Definition: GDBRemoteCommunication.h:91
lldb_private::process_gdb_remote::GDBRemoteCommunicationServer::GetPacketAndSendResponse
PacketResult GetPacketAndSendResponse(Timeout< std::micro > timeout, Status &error, bool &interrupt, bool &quit)
Definition: GDBRemoteCommunicationServer.cpp:45
lldb_private::process_gdb_remote::GDBRemoteCommunication
Definition: GDBRemoteCommunication.h:83
lldb_private::process_gdb_remote::GDBRemoteCommunicationServer
Definition: GDBRemoteCommunicationServer.h:28
lldb_private::process_gdb_remote::GDBRemoteCommunicationServer::PacketHandler
std::function< PacketResult(StringExtractorGDBRemote &packet, Status &error, bool &interrupt, bool &quit)> PacketHandler
Definition: GDBRemoteCommunicationServer.h:32
lldb_private::process_gdb_remote::GDBRemoteCommunicationServer::~GDBRemoteCommunicationServer
~GDBRemoteCommunicationServer() override
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
lldb-private-forward.h
lldb_private::process_gdb_remote::GDBRemoteCommunicationServer::operator=
const GDBRemoteCommunicationServer & operator=(const GDBRemoteCommunicationServer &)=delete
lldb_private::process_gdb_remote::GDBRemoteCommunicationServer::SendJSONResponse
PacketResult SendJSONResponse(const llvm::json::Value &value)
Serialize and send a JSON object response.
lldb_private::process_gdb_remote::GDBRemoteCommunicationServer::Handle_QErrorStringEnable
PacketResult Handle_QErrorStringEnable(StringExtractorGDBRemote &packet)
Definition: GDBRemoteCommunicationServer.cpp:132
lldb_private::process_gdb_remote::GDBRemoteCommunicationServer::m_exit_now
bool m_exit_now
Definition: GDBRemoteCommunicationServer.h:50
lldb_private::process_gdb_remote::GDBRemoteCommunicationServer::SendUnimplementedResponse
PacketResult SendUnimplementedResponse(const char *packet)
Definition: GDBRemoteCommunicationServer.cpp:92
lldb_private::process_gdb_remote::GDBRemoteCommunicationServer::m_packet_handlers
std::map< StringExtractorGDBRemote::ServerPacketType, PacketHandler > m_packet_handlers
Definition: GDBRemoteCommunicationServer.h:49
StringExtractorGDBRemote::ServerPacketType
ServerPacketType
Definition: StringExtractorGDBRemote.h:46
lldb_private::Status
Definition: Status.h:44
lldb_private::Timeout< std::micro >
lldb_private::process_gdb_remote::GDBRemoteCommunicationServer::SendOKResponse
PacketResult SendOKResponse()
Definition: GDBRemoteCommunicationServer.cpp:149
GDBRemoteCommunication.h
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
Error
llvm::Error Error
Definition: UdtRecordCompleter.cpp:29
lldb_private::process_gdb_remote::GDBRemoteCommunicationServer::m_send_error_strings
bool m_send_error_strings
Definition: GDBRemoteCommunicationServer.h:53
StringExtractorGDBRemote
Definition: StringExtractorGDBRemote.h:21
lldb_private::process_gdb_remote::GDBRemoteCommunicationServer::GDBRemoteCommunicationServer
GDBRemoteCommunicationServer(const char *comm_name, const char *listener_name)
Definition: GDBRemoteCommunicationServer.cpp:27
lldb_private::process_gdb_remote::GDBRemoteCommunicationServer::SendIllFormedResponse
PacketResult SendIllFormedResponse(const StringExtractorGDBRemote &packet, const char *error_message)
Definition: GDBRemoteCommunicationServer.cpp:139