LLDB  mainline
GDBRemoteCommunicationServerCommon.h
Go to the documentation of this file.
1 //===-- GDBRemoteCommunicationServerCommon.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_GDBREMOTECOMMUNICATIONSERVERCOMMON_H
10 #define LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTECOMMUNICATIONSERVERCOMMON_H
11 
12 #include <string>
13 
16 
18 
20 
21 namespace lldb_private {
22 namespace process_gdb_remote {
23 
24 class ProcessGDBRemote;
25 
27 public:
28  GDBRemoteCommunicationServerCommon(const char *comm_name,
29  const char *listener_name);
30 
32 
33 protected:
38 
40 
42 
44 
46 
48 
50 
52 
54 
56 
58 
60 
62 
64 
66 
68 
70 
72 
74 
76 
78 
80 
82 
84 
86 
88 
90 
92 
94 
96 
98 
100 
102 
104 
106 
108 
110 
111  static void CreateProcessInfoResponse(const ProcessInstanceInfo &proc_info,
112  StreamString &response);
113 
115  const ProcessInstanceInfo &proc_info, StreamString &response);
116 
117  template <typename T>
120  PacketResult (T::*handler)(StringExtractorGDBRemote &packet)) {
121  RegisterPacketHandler(packet_type,
122  [this, handler](StringExtractorGDBRemote packet,
123  Status &error, bool &interrupt,
124  bool &quit) {
125  return (static_cast<T *>(this)->*handler)(packet);
126  });
127  }
128 
129  /// Launch a process with the current launch settings.
130  ///
131  /// This method supports running an lldb-gdbserver or similar
132  /// server in a situation where the startup code has been provided
133  /// with all the information for a child process to be launched.
134  ///
135  /// \return
136  /// An Status object indicating the success or failure of the
137  /// launch.
138  virtual Status LaunchProcess() = 0;
139 
140  virtual FileSpec FindModuleFile(const std::string &module_path,
141  const ArchSpec &arch);
142 
143  // Process client_features (qSupported) and return an array of server features
144  // to be returned in response.
145  virtual std::vector<std::string>
146  HandleFeatures(llvm::ArrayRef<llvm::StringRef> client_features);
147 
148 private:
149  ModuleSpec GetModuleInfo(llvm::StringRef module_path, llvm::StringRef triple);
150 };
151 
152 } // namespace process_gdb_remote
153 } // namespace lldb_private
154 
155 #endif // LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTECOMMUNICATIONSERVERCOMMON_H
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::Handle_qSpeedTest
PacketResult Handle_qSpeedTest(StringExtractorGDBRemote &packet)
Definition: GDBRemoteCommunicationServerCommon.cpp:469
lldb_private::ProcessInstanceInfo
Definition: ProcessInfo.h:108
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::Handle_qsProcessInfo
PacketResult Handle_qsProcessInfo(StringExtractorGDBRemote &packet)
Definition: GDBRemoteCommunicationServerCommon.cpp:415
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::GetModuleInfo
ModuleSpec GetModuleInfo(llvm::StringRef module_path, llvm::StringRef triple)
Definition: GDBRemoteCommunicationServerCommon.cpp:1320
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::Handle_vFile_Exists
PacketResult Handle_vFile_Exists(StringExtractorGDBRemote &packet)
Definition: GDBRemoteCommunicationServerCommon.cpp:686
lldb_private::ArchSpec
Definition: ArchSpec.h:33
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::Handle_qGroupName
PacketResult Handle_qGroupName(StringExtractorGDBRemote &packet)
Definition: GDBRemoteCommunicationServerCommon.cpp:450
lldb_private::process_gdb_remote::GDBRemoteCommunicationServer::RegisterPacketHandler
void RegisterPacketHandler(StringExtractorGDBRemote::ServerPacketType packet_type, PacketHandler handler)
Definition: GDBRemoteCommunicationServer.cpp:38
lldb_private::process_gdb_remote::GDBRemoteCommunication::PacketResult
PacketResult
Definition: GDBRemoteCommunication.h:91
ProcessLaunchInfo.h
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::Handle_vFile_Mode
PacketResult Handle_vFile_Mode(StringExtractorGDBRemote &packet)
Definition: GDBRemoteCommunicationServerCommon.cpp:665
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::Handle_vFile_pRead
PacketResult Handle_vFile_pRead(StringExtractorGDBRemote &packet)
Definition: GDBRemoteCommunicationServerCommon.cpp:573
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::Handle_qPlatform_shell
PacketResult Handle_qPlatform_shell(StringExtractorGDBRemote &packet)
Definition: GDBRemoteCommunicationServerCommon.cpp:736
lldb_private::process_gdb_remote::GDBRemoteCommunicationServer
Definition: GDBRemoteCommunicationServer.h:28
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::LaunchProcess
virtual Status LaunchProcess()=0
Launch a process with the current launch settings.
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::Handle_QEnvironment
PacketResult Handle_QEnvironment(StringExtractorGDBRemote &packet)
Definition: GDBRemoteCommunicationServerCommon.cpp:977
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::Handle_QEnvironmentHexEncoded
PacketResult Handle_QEnvironmentHexEncoded(StringExtractorGDBRemote &packet)
Definition: GDBRemoteCommunicationServerCommon.cpp:989
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon
Definition: GDBRemoteCommunicationServerCommon.h:26
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::Handle_vFile_Open
PacketResult Handle_vFile_Open(StringExtractorGDBRemote &packet)
Definition: GDBRemoteCommunicationServerCommon.cpp:501
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::Handle_vFile_Size
PacketResult Handle_vFile_Size(StringExtractorGDBRemote &packet)
Definition: GDBRemoteCommunicationServerCommon.cpp:643
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::Handle_vFile_Close
PacketResult Handle_vFile_Close(StringExtractorGDBRemote &packet)
Definition: GDBRemoteCommunicationServerCommon.cpp:550
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::Handle_qLaunchSuccess
PacketResult Handle_qLaunchSuccess(StringExtractorGDBRemote &packet)
Definition: GDBRemoteCommunicationServerCommon.cpp:966
lldb_private::FileSpec
Definition: FileSpec.h:56
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
lldb-private-forward.h
lldb_private::ProcessLaunchInfo
Definition: ProcessLaunchInfo.h:31
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::m_proc_infos
ProcessInstanceInfoList m_proc_infos
Definition: GDBRemoteCommunicationServerCommon.h:36
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::Handle_vFile_Stat
PacketResult Handle_vFile_Stat(StringExtractorGDBRemote &packet)
Definition: GDBRemoteCommunicationServerCommon.cpp:822
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::Handle_qProcessInfoPID
PacketResult Handle_qProcessInfoPID(StringExtractorGDBRemote &packet)
Definition: GDBRemoteCommunicationServerCommon.cpp:315
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::Handle_QSetDetachOnError
PacketResult Handle_QSetDetachOnError(StringExtractorGDBRemote &packet)
Definition: GDBRemoteCommunicationServerCommon.cpp:898
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::m_process_launch_error
Status m_process_launch_error
Definition: GDBRemoteCommunicationServerCommon.h:35
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::RegisterMemberFunctionHandler
void RegisterMemberFunctionHandler(StringExtractorGDBRemote::ServerPacketType packet_type, PacketResult(T::*handler)(StringExtractorGDBRemote &packet))
Definition: GDBRemoteCommunicationServerCommon.h:118
GDBRemoteCommunicationServer.h
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::Handle_qModuleInfo
PacketResult Handle_qModuleInfo(StringExtractorGDBRemote &packet)
Definition: GDBRemoteCommunicationServerCommon.cpp:1097
lldb_private::StreamString
Definition: StreamString.h:23
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::Handle_qPlatform_mkdir
PacketResult Handle_qPlatform_mkdir(StringExtractorGDBRemote &packet)
Definition: GDBRemoteCommunicationServerCommon.cpp:851
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:40
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::Handle_qUserName
PacketResult Handle_qUserName(StringExtractorGDBRemote &packet)
Definition: GDBRemoteCommunicationServerCommon.cpp:427
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::Handle_qfProcessInfo
PacketResult Handle_qfProcessInfo(StringExtractorGDBRemote &packet)
Definition: GDBRemoteCommunicationServerCommon.cpp:332
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::~GDBRemoteCommunicationServerCommon
~GDBRemoteCommunicationServerCommon() override
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::Handle_QSetSTDOUT
PacketResult Handle_QSetSTDOUT(StringExtractorGDBRemote &packet)
Definition: GDBRemoteCommunicationServerCommon.cpp:934
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::Handle_vFile_pWrite
PacketResult Handle_vFile_pWrite(StringExtractorGDBRemote &packet)
Definition: GDBRemoteCommunicationServerCommon.cpp:608
StringExtractorGDBRemote::ServerPacketType
ServerPacketType
Definition: StringExtractorGDBRemote.h:46
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::Handle_vFile_MD5
PacketResult Handle_vFile_MD5(StringExtractorGDBRemote &packet)
Definition: GDBRemoteCommunicationServerCommon.cpp:829
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::Handle_vFile_unlink
PacketResult Handle_vFile_unlink(StringExtractorGDBRemote &packet)
Definition: GDBRemoteCommunicationServerCommon.cpp:724
lldb_private::ModuleSpec
Definition: ModuleSpec.h:27
lldb_private::Status
Definition: Status.h:44
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::Handle_QStartNoAckMode
PacketResult Handle_QStartNoAckMode(StringExtractorGDBRemote &packet)
Definition: GDBRemoteCommunicationServerCommon.cpp:909
uint32_t
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::FindModuleFile
virtual FileSpec FindModuleFile(const std::string &module_path, const ArchSpec &arch)
Definition: GDBRemoteCommunicationServerCommon.cpp:1308
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::GDBRemoteCommunicationServerCommon
GDBRemoteCommunicationServerCommon(const char *comm_name, const char *listener_name)
Definition: GDBRemoteCommunicationServerCommon.cpp:60
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::HandleFeatures
virtual std::vector< std::string > HandleFeatures(llvm::ArrayRef< llvm::StringRef > client_features)
Definition: GDBRemoteCommunicationServerCommon.cpp:1343
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::Handle_jModulesInfo
PacketResult Handle_jModulesInfo(StringExtractorGDBRemote &packet)
Definition: GDBRemoteCommunicationServerCommon.cpp:1154
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::Handle_qSupported
PacketResult Handle_qSupported(StringExtractorGDBRemote &packet)
Definition: GDBRemoteCommunicationServerCommon.cpp:889
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::Handle_qPlatform_chmod
PacketResult Handle_qPlatform_chmod(StringExtractorGDBRemote &packet)
Definition: GDBRemoteCommunicationServerCommon.cpp:869
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::Handle_QSetSTDERR
PacketResult Handle_QSetSTDERR(StringExtractorGDBRemote &packet)
Definition: GDBRemoteCommunicationServerCommon.cpp:950
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::CreateProcessInfoResponse_DebugServerStyle
static void CreateProcessInfoResponse_DebugServerStyle(const ProcessInstanceInfo &proc_info, StreamString &response)
Definition: GDBRemoteCommunicationServerCommon.cpp:1237
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::Handle_QSetSTDIN
PacketResult Handle_QSetSTDIN(StringExtractorGDBRemote &packet)
Definition: GDBRemoteCommunicationServerCommon.cpp:918
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::m_proc_infos_index
uint32_t m_proc_infos_index
Definition: GDBRemoteCommunicationServerCommon.h:37
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::m_process_launch_info
ProcessLaunchInfo m_process_launch_info
Definition: GDBRemoteCommunicationServerCommon.h:34
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::Handle_A
PacketResult Handle_A(StringExtractorGDBRemote &packet)
Definition: GDBRemoteCommunicationServerCommon.cpp:1017
StringExtractorGDBRemote
Definition: StringExtractorGDBRemote.h:21
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::Handle_vFile_FStat
PacketResult Handle_vFile_FStat(StringExtractorGDBRemote &packet)
Definition: GDBRemoteCommunicationServerCommon.cpp:783
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::Handle_vFile_symlink
PacketResult Handle_vFile_symlink(StringExtractorGDBRemote &packet)
Definition: GDBRemoteCommunicationServerCommon.cpp:706
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::Handle_qHostInfo
PacketResult Handle_qHostInfo(StringExtractorGDBRemote &packet)
Definition: GDBRemoteCommunicationServerCommon.cpp:179
lldb_private::ProcessInstanceInfoList
std::vector< ProcessInstanceInfo > ProcessInstanceInfoList
Definition: Host.h:31
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::Handle_qEcho
PacketResult Handle_qEcho(StringExtractorGDBRemote &packet)
Definition: GDBRemoteCommunicationServerCommon.cpp:1090
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::Handle_QLaunchArch
PacketResult Handle_QLaunchArch(StringExtractorGDBRemote &packet)
Definition: GDBRemoteCommunicationServerCommon.cpp:1003
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::CreateProcessInfoResponse
static void CreateProcessInfoResponse(const ProcessInstanceInfo &proc_info, StreamString &response)
Definition: GDBRemoteCommunicationServerCommon.cpp:1208