11#include "lldb/Host/Config.h"
19#include "llvm/Support/JSON.h"
52 switch (packet_type) {
71 packet_result = handler_it->second(packet,
error, interrupt, quit);
99 int packet_len = ::snprintf(packet,
sizeof(packet),
"E%2.2x", err);
100 assert(packet_len < (
int)
sizeof(packet));
109 packet.
Printf(
"E%2.2x;", code);
119 std::unique_ptr<llvm::ErrorInfoBase> EIB;
120 std::unique_ptr<UnimplementedError> UE;
121 llvm::handleAllErrors(
123 [&](std::unique_ptr<UnimplementedError> E) { UE = std::move(E); },
124 [&](std::unique_ptr<llvm::ErrorInfoBase> E) { EIB = std::move(E); });
142 LLDB_LOGF(log,
"GDBRemoteCommunicationServer::%s: ILLFORMED: '%s' (%s)",
144 message ? message :
"");
155 std::string json_string;
156 raw_string_ostream os(json_string);
159 escaped_response.
PutEscapedBytes(json_string.c_str(), json_string.size());
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_LOGF(log,...)
bool IsConnected() const
Check if the connection is valid.
static Status FromErrorString(const char *str)
static Status FromError(llvm::Error error)
Avoid using this in new code. Migrate APIs to llvm::Expected instead.
int PutEscapedBytes(const void *s, size_t src_len)
Output a block of data to the stream performing GDB-remote escaping.
llvm::StringRef GetString() const
size_t PutStringAsRawHex8(llvm::StringRef s)
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
std::function< PacketResult(StringExtractorGDBRemote &packet, Status &error, bool &interrupt, bool &quit)> PacketHandler
void RegisterPacketHandler(StringExtractorGDBRemote::ServerPacketType packet_type, PacketHandler handler)
~GDBRemoteCommunicationServer() override
std::map< StringExtractorGDBRemote::ServerPacketType, PacketHandler > m_packet_handlers
GDBRemoteCommunicationServer()
bool m_send_error_strings
PacketResult Handle_QErrorStringEnable(StringExtractorGDBRemote &packet)
PacketResult SendErrorResponse(const Status &error)
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.
PacketResult SendUnimplementedResponse(const char *packet)
PacketResult SendOKResponse()
PacketResult ReadPacket(StringExtractorGDBRemote &response, Timeout< std::micro > timeout, bool sync_on_timeout)
PacketResult SendPacketNoLock(llvm::StringRef payload)
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
@ eErrorTypePOSIX
POSIX error codes.