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
17
18#include "llvm/Support/Errc.h"
19#include "llvm/Support/Error.h"
20
22
23namespace lldb_private {
24namespace process_gdb_remote {
25
26class ProcessGDBRemote;
27
29public:
31 std::function<PacketResult(StringExtractorGDBRemote &packet,
32 Status &error, bool &interrupt, bool &quit)>;
33
35
37
38 void
40 PacketHandler handler);
41
43 Status &error, bool &interrupt,
44 bool &quit);
45
46protected:
47 std::map<StringExtractorGDBRemote::ServerPacketType, PacketHandler>
49 bool m_exit_now; // use in asynchronous handling to indicate process should
50 // exit.
51
52 bool m_send_error_strings = false; // If the client enables this then
53 // we will send error strings as well.
54
56
58
60
61 PacketResult SendUnimplementedResponse(const char *packet);
62
64
66 const char *error_message);
67
69
70 /// Serialize and send a JSON object response.
71 PacketResult SendJSONResponse(const llvm::json::Value &value);
72
73 /// Serialize and send a JSON object response, or respond with an error if the
74 /// input object is an \a llvm::Error.
75 PacketResult SendJSONResponse(llvm::Expected<llvm::json::Value> value);
76
77private:
81};
82
83} // namespace process_gdb_remote
84} // namespace lldb_private
85
86#endif // LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTECOMMUNICATIONSERVER_H
static llvm::raw_ostream & error(Stream &strm)
An error handling class.
Definition: Status.h:115
GDBRemoteCommunicationServer(const GDBRemoteCommunicationServer &)=delete
std::function< PacketResult(StringExtractorGDBRemote &packet, Status &error, bool &interrupt, bool &quit)> PacketHandler
void RegisterPacketHandler(StringExtractorGDBRemote::ServerPacketType packet_type, PacketHandler handler)
const GDBRemoteCommunicationServer & operator=(const GDBRemoteCommunicationServer &)=delete
std::map< StringExtractorGDBRemote::ServerPacketType, PacketHandler > m_packet_handlers
PacketResult SendJSONResponse(llvm::Expected< llvm::json::Value > value)
Serialize and send a JSON object response, or respond with an error if the input object is an llvm::E...
PacketResult Handle_QErrorStringEnable(StringExtractorGDBRemote &packet)
PacketResult SendIllFormedResponse(const StringExtractorGDBRemote &packet, const char *error_message)
PacketResult GetPacketAndSendResponse(Timeout< std::micro > timeout, Status &error, bool &interrupt, bool &quit)
PacketResult SendJSONResponse(const llvm::json::Value &value)
Serialize and send a JSON object response.
A class that represents a running process on the host machine.