Path: blob/main/contrib/llvm-project/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h
39644 views
//===-- GDBRemoteCommunicationServer.h --------------------------*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#ifndef LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTECOMMUNICATIONSERVER_H9#define LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTECOMMUNICATIONSERVER_H1011#include <functional>12#include <map>1314#include "GDBRemoteCommunication.h"15#include "lldb/lldb-private-forward.h"1617#include "llvm/Support/Errc.h"18#include "llvm/Support/Error.h"1920class StringExtractorGDBRemote;2122namespace lldb_private {23namespace process_gdb_remote {2425class ProcessGDBRemote;2627class GDBRemoteCommunicationServer : public GDBRemoteCommunication {28public:29using PacketHandler =30std::function<PacketResult(StringExtractorGDBRemote &packet,31Status &error, bool &interrupt, bool &quit)>;3233GDBRemoteCommunicationServer();3435~GDBRemoteCommunicationServer() override;3637void38RegisterPacketHandler(StringExtractorGDBRemote::ServerPacketType packet_type,39PacketHandler handler);4041PacketResult GetPacketAndSendResponse(Timeout<std::micro> timeout,42Status &error, bool &interrupt,43bool &quit);4445protected:46std::map<StringExtractorGDBRemote::ServerPacketType, PacketHandler>47m_packet_handlers;48bool m_exit_now; // use in asynchronous handling to indicate process should49// exit.5051bool m_send_error_strings = false; // If the client enables this then52// we will send error strings as well.5354PacketResult Handle_QErrorStringEnable(StringExtractorGDBRemote &packet);5556PacketResult SendErrorResponse(const Status &error);5758PacketResult SendErrorResponse(llvm::Error error);5960PacketResult SendUnimplementedResponse(const char *packet);6162PacketResult SendErrorResponse(uint8_t error);6364PacketResult SendIllFormedResponse(const StringExtractorGDBRemote &packet,65const char *error_message);6667PacketResult SendOKResponse();6869/// Serialize and send a JSON object response.70PacketResult SendJSONResponse(const llvm::json::Value &value);7172/// Serialize and send a JSON object response, or respond with an error if the73/// input object is an \a llvm::Error.74PacketResult SendJSONResponse(llvm::Expected<llvm::json::Value> value);7576private:77GDBRemoteCommunicationServer(const GDBRemoteCommunicationServer &) = delete;78const GDBRemoteCommunicationServer &79operator=(const GDBRemoteCommunicationServer &) = delete;80};8182} // namespace process_gdb_remote83} // namespace lldb_private8485#endif // LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTECOMMUNICATIONSERVER_H868788