1 //===-- GDBRemoteCommunicationServerCommon.h --------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_GDBRemoteCommunicationServerCommon_h_
11 #define liblldb_GDBRemoteCommunicationServerCommon_h_
15 #include "lldb/Target/Process.h"
16 #include "lldb/lldb-private-forward.h"
18 #include "GDBRemoteCommunicationServer.h"
19 #include "GDBRemoteCommunicationServerCommon.h"
21 class StringExtractorGDBRemote;
23 namespace lldb_private {
24 namespace process_gdb_remote {
26 class ProcessGDBRemote;
28 class GDBRemoteCommunicationServerCommon : public GDBRemoteCommunicationServer {
30 GDBRemoteCommunicationServerCommon(const char *comm_name,
31 const char *listener_name);
33 ~GDBRemoteCommunicationServerCommon() override;
36 ProcessLaunchInfo m_process_launch_info;
37 Status m_process_launch_error;
38 ProcessInstanceInfoList m_proc_infos;
39 uint32_t m_proc_infos_index;
40 bool m_thread_suffix_supported;
41 bool m_list_threads_in_stop_reply;
43 PacketResult Handle_A(StringExtractorGDBRemote &packet);
45 PacketResult Handle_qHostInfo(StringExtractorGDBRemote &packet);
47 PacketResult Handle_qProcessInfoPID(StringExtractorGDBRemote &packet);
49 PacketResult Handle_qfProcessInfo(StringExtractorGDBRemote &packet);
51 PacketResult Handle_qsProcessInfo(StringExtractorGDBRemote &packet);
53 PacketResult Handle_qUserName(StringExtractorGDBRemote &packet);
55 PacketResult Handle_qGroupName(StringExtractorGDBRemote &packet);
57 PacketResult Handle_qSpeedTest(StringExtractorGDBRemote &packet);
59 PacketResult Handle_vFile_Open(StringExtractorGDBRemote &packet);
61 PacketResult Handle_vFile_Close(StringExtractorGDBRemote &packet);
63 PacketResult Handle_vFile_pRead(StringExtractorGDBRemote &packet);
65 PacketResult Handle_vFile_pWrite(StringExtractorGDBRemote &packet);
67 PacketResult Handle_vFile_Size(StringExtractorGDBRemote &packet);
69 PacketResult Handle_vFile_Mode(StringExtractorGDBRemote &packet);
71 PacketResult Handle_vFile_Exists(StringExtractorGDBRemote &packet);
73 PacketResult Handle_vFile_symlink(StringExtractorGDBRemote &packet);
75 PacketResult Handle_vFile_unlink(StringExtractorGDBRemote &packet);
77 PacketResult Handle_vFile_Stat(StringExtractorGDBRemote &packet);
79 PacketResult Handle_vFile_MD5(StringExtractorGDBRemote &packet);
81 PacketResult Handle_qEcho(StringExtractorGDBRemote &packet);
83 PacketResult Handle_qModuleInfo(StringExtractorGDBRemote &packet);
85 PacketResult Handle_jModulesInfo(StringExtractorGDBRemote &packet);
87 PacketResult Handle_qPlatform_shell(StringExtractorGDBRemote &packet);
89 PacketResult Handle_qPlatform_mkdir(StringExtractorGDBRemote &packet);
91 PacketResult Handle_qPlatform_chmod(StringExtractorGDBRemote &packet);
93 PacketResult Handle_qSupported(StringExtractorGDBRemote &packet);
95 PacketResult Handle_QThreadSuffixSupported(StringExtractorGDBRemote &packet);
97 PacketResult Handle_QListThreadsInStopReply(StringExtractorGDBRemote &packet);
99 PacketResult Handle_QSetDetachOnError(StringExtractorGDBRemote &packet);
101 PacketResult Handle_QStartNoAckMode(StringExtractorGDBRemote &packet);
103 PacketResult Handle_QSetSTDIN(StringExtractorGDBRemote &packet);
105 PacketResult Handle_QSetSTDOUT(StringExtractorGDBRemote &packet);
107 PacketResult Handle_QSetSTDERR(StringExtractorGDBRemote &packet);
109 PacketResult Handle_qLaunchSuccess(StringExtractorGDBRemote &packet);
111 PacketResult Handle_QEnvironment(StringExtractorGDBRemote &packet);
113 PacketResult Handle_QEnvironmentHexEncoded(StringExtractorGDBRemote &packet);
115 PacketResult Handle_QLaunchArch(StringExtractorGDBRemote &packet);
117 static void CreateProcessInfoResponse(const ProcessInstanceInfo &proc_info,
118 StreamString &response);
120 static void CreateProcessInfoResponse_DebugServerStyle(
121 const ProcessInstanceInfo &proc_info, StreamString &response);
123 template <typename T>
124 void RegisterMemberFunctionHandler(
125 StringExtractorGDBRemote::ServerPacketType packet_type,
126 PacketResult (T::*handler)(StringExtractorGDBRemote &packet)) {
127 RegisterPacketHandler(packet_type,
128 [this, handler](StringExtractorGDBRemote packet,
129 Status &error, bool &interrupt,
131 return (static_cast<T *>(this)->*handler)(packet);
135 //------------------------------------------------------------------
136 /// Launch a process with the current launch settings.
138 /// This method supports running an lldb-gdbserver or similar
139 /// server in a situation where the startup code has been provided
140 /// with all the information for a child process to be launched.
143 /// An Status object indicating the success or failure of the
145 //------------------------------------------------------------------
146 virtual Status LaunchProcess() = 0;
148 virtual FileSpec FindModuleFile(const std::string &module_path,
149 const ArchSpec &arch);
152 ModuleSpec GetModuleInfo(llvm::StringRef module_path, llvm::StringRef triple);
155 } // namespace process_gdb_remote
156 } // namespace lldb_private
158 #endif // liblldb_GDBRemoteCommunicationServerCommon_h_