Go to the documentation of this file.
11 #include "lldb/Host/Config.h"
19 #include "llvm/Support/JSON.h"
27 GDBRemoteCommunicationServer::GDBRemoteCommunicationServer(
28 const char *comm_name,
const char *listener_name)
53 switch (packet_type) {
59 error.SetErrorString(
"invalid packet");
72 packet_result = handler_it->second(packet,
error, interrupt, quit);
77 error.SetErrorString(
"lost connection");
80 error.SetErrorString(
"timeout");
100 int packet_len = ::snprintf(packet,
sizeof(packet),
"E%2.2x", err);
101 assert(packet_len < (
int)
sizeof(packet));
109 packet.
Printf(
"E%2.2x;",
static_cast<uint8_t
>(
error.GetError()));
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)",
156 raw_string_ostream os(json_string);
160 escaped_response.
PutEscapedBytes(json_string.c_str(), json_string.size());
PacketResult SendErrorResponse(const Status &error)
void RegisterPacketHandler(StringExtractorGDBRemote::ServerPacketType packet_type, PacketHandler handler)
#define LLDB_LOGF(log,...)
PacketResult GetPacketAndSendResponse(Timeout< std::micro > timeout, Status &error, bool &interrupt, bool &quit)
std::function< PacketResult(StringExtractorGDBRemote &packet, Status &error, bool &interrupt, bool &quit)> PacketHandler
size_t PutStringAsRawHex8(llvm::StringRef s)
llvm::StringRef GetString() const
~GDBRemoteCommunicationServer() override
static llvm::raw_ostream & error(Stream &strm)
PacketResult SendJSONResponse(const llvm::json::Value &value)
Serialize and send a JSON object response.
PacketResult Handle_QErrorStringEnable(StringExtractorGDBRemote &packet)
string(SUBSTRING ${p} 10 -1 pStripped) if($
PacketResult SendUnimplementedResponse(const char *packet)
std::map< StringExtractorGDBRemote::ServerPacketType, PacketHandler > m_packet_handlers
PacketResult ReadPacket(StringExtractorGDBRemote &response, Timeout< std::micro > timeout, bool sync_on_timeout)
message(FATAL_ERROR "invalid libipt include path provided") endif() include_directories($
PacketResult SendPacketNoLock(llvm::StringRef payload)
bool IsConnected() const
Check if the connection is valid.
PacketResult SendOKResponse()
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
A class that represents a running process on the host machine.
int PutEscapedBytes(const void *s, size_t src_len)
Output a block of data to the stream performing GDB-remote escaping.
bool m_send_error_strings
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
PacketResult SendIllFormedResponse(const StringExtractorGDBRemote &packet, const char *error_message)