Path: blob/main/contrib/llvm-project/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.h
39644 views
//===-- GDBRemoteCommunicationServerCommon.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_GDBREMOTECOMMUNICATIONSERVERCOMMON_H9#define LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTECOMMUNICATIONSERVERCOMMON_H1011#include <string>1213#include "lldb/Host/ProcessLaunchInfo.h"14#include "lldb/lldb-private-forward.h"1516#include "GDBRemoteCommunicationServer.h"1718class StringExtractorGDBRemote;1920namespace lldb_private {21namespace process_gdb_remote {2223class ProcessGDBRemote;2425class GDBRemoteCommunicationServerCommon : public GDBRemoteCommunicationServer {26public:27GDBRemoteCommunicationServerCommon();2829~GDBRemoteCommunicationServerCommon() override;3031protected:32ProcessLaunchInfo m_process_launch_info;33Status m_process_launch_error;34ProcessInstanceInfoList m_proc_infos;35uint32_t m_proc_infos_index;3637PacketResult Handle_A(StringExtractorGDBRemote &packet);3839PacketResult Handle_qHostInfo(StringExtractorGDBRemote &packet);4041PacketResult Handle_qProcessInfoPID(StringExtractorGDBRemote &packet);4243PacketResult Handle_qfProcessInfo(StringExtractorGDBRemote &packet);4445PacketResult Handle_qsProcessInfo(StringExtractorGDBRemote &packet);4647PacketResult Handle_qUserName(StringExtractorGDBRemote &packet);4849PacketResult Handle_qGroupName(StringExtractorGDBRemote &packet);5051PacketResult Handle_qSpeedTest(StringExtractorGDBRemote &packet);5253PacketResult Handle_vFile_Open(StringExtractorGDBRemote &packet);5455PacketResult Handle_vFile_Close(StringExtractorGDBRemote &packet);5657PacketResult Handle_vFile_pRead(StringExtractorGDBRemote &packet);5859PacketResult Handle_vFile_pWrite(StringExtractorGDBRemote &packet);6061PacketResult Handle_vFile_Size(StringExtractorGDBRemote &packet);6263PacketResult Handle_vFile_Mode(StringExtractorGDBRemote &packet);6465PacketResult Handle_vFile_Exists(StringExtractorGDBRemote &packet);6667PacketResult Handle_vFile_symlink(StringExtractorGDBRemote &packet);6869PacketResult Handle_vFile_unlink(StringExtractorGDBRemote &packet);7071PacketResult Handle_vFile_FStat(StringExtractorGDBRemote &packet);7273PacketResult Handle_vFile_Stat(StringExtractorGDBRemote &packet);7475PacketResult Handle_vFile_MD5(StringExtractorGDBRemote &packet);7677PacketResult Handle_qEcho(StringExtractorGDBRemote &packet);7879PacketResult Handle_qModuleInfo(StringExtractorGDBRemote &packet);8081PacketResult Handle_jModulesInfo(StringExtractorGDBRemote &packet);8283PacketResult Handle_qPlatform_shell(StringExtractorGDBRemote &packet);8485PacketResult Handle_qPlatform_mkdir(StringExtractorGDBRemote &packet);8687PacketResult Handle_qPlatform_chmod(StringExtractorGDBRemote &packet);8889PacketResult Handle_qSupported(StringExtractorGDBRemote &packet);9091PacketResult Handle_QSetDetachOnError(StringExtractorGDBRemote &packet);9293PacketResult Handle_QStartNoAckMode(StringExtractorGDBRemote &packet);9495PacketResult Handle_QSetSTDIN(StringExtractorGDBRemote &packet);9697PacketResult Handle_QSetSTDOUT(StringExtractorGDBRemote &packet);9899PacketResult Handle_QSetSTDERR(StringExtractorGDBRemote &packet);100101PacketResult Handle_qLaunchSuccess(StringExtractorGDBRemote &packet);102103PacketResult Handle_QEnvironment(StringExtractorGDBRemote &packet);104105PacketResult Handle_QEnvironmentHexEncoded(StringExtractorGDBRemote &packet);106107PacketResult Handle_QLaunchArch(StringExtractorGDBRemote &packet);108109static void CreateProcessInfoResponse(const ProcessInstanceInfo &proc_info,110StreamString &response);111112static void CreateProcessInfoResponse_DebugServerStyle(113const ProcessInstanceInfo &proc_info, StreamString &response);114115template <typename T>116void RegisterMemberFunctionHandler(117StringExtractorGDBRemote::ServerPacketType packet_type,118PacketResult (T::*handler)(StringExtractorGDBRemote &packet)) {119RegisterPacketHandler(packet_type,120[this, handler](StringExtractorGDBRemote packet,121Status &error, bool &interrupt,122bool &quit) {123return (static_cast<T *>(this)->*handler)(packet);124});125}126127/// Launch a process with the current launch settings.128///129/// This method supports running an lldb-gdbserver or similar130/// server in a situation where the startup code has been provided131/// with all the information for a child process to be launched.132///133/// \return134/// An Status object indicating the success or failure of the135/// launch.136virtual Status LaunchProcess() = 0;137138virtual FileSpec FindModuleFile(const std::string &module_path,139const ArchSpec &arch);140141// Process client_features (qSupported) and return an array of server features142// to be returned in response.143virtual std::vector<std::string>144HandleFeatures(llvm::ArrayRef<llvm::StringRef> client_features);145146private:147ModuleSpec GetModuleInfo(llvm::StringRef module_path, llvm::StringRef triple);148};149150} // namespace process_gdb_remote151} // namespace lldb_private152153#endif // LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTECOMMUNICATIONSERVERCOMMON_H154155156