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_
17 // Other libraries and framework includes
19 #include "lldb/Target/Process.h"
20 #include "lldb/lldb-private-forward.h"
22 #include "GDBRemoteCommunicationServer.h"
23 #include "GDBRemoteCommunicationServerCommon.h"
25 class StringExtractorGDBRemote;
27 namespace lldb_private {
28 namespace process_gdb_remote {
30 class ProcessGDBRemote;
32 class GDBRemoteCommunicationServerCommon : public GDBRemoteCommunicationServer {
34 GDBRemoteCommunicationServerCommon(const char *comm_name,
35 const char *listener_name);
37 ~GDBRemoteCommunicationServerCommon() override;
40 ProcessLaunchInfo m_process_launch_info;
41 Status m_process_launch_error;
42 ProcessInstanceInfoList m_proc_infos;
43 uint32_t m_proc_infos_index;
44 bool m_thread_suffix_supported;
45 bool m_list_threads_in_stop_reply;
47 PacketResult Handle_A(StringExtractorGDBRemote &packet);
49 PacketResult Handle_qHostInfo(StringExtractorGDBRemote &packet);
51 PacketResult Handle_qProcessInfoPID(StringExtractorGDBRemote &packet);
53 PacketResult Handle_qfProcessInfo(StringExtractorGDBRemote &packet);
55 PacketResult Handle_qsProcessInfo(StringExtractorGDBRemote &packet);
57 PacketResult Handle_qUserName(StringExtractorGDBRemote &packet);
59 PacketResult Handle_qGroupName(StringExtractorGDBRemote &packet);
61 PacketResult Handle_qSpeedTest(StringExtractorGDBRemote &packet);
63 PacketResult Handle_vFile_Open(StringExtractorGDBRemote &packet);
65 PacketResult Handle_vFile_Close(StringExtractorGDBRemote &packet);
67 PacketResult Handle_vFile_pRead(StringExtractorGDBRemote &packet);
69 PacketResult Handle_vFile_pWrite(StringExtractorGDBRemote &packet);
71 PacketResult Handle_vFile_Size(StringExtractorGDBRemote &packet);
73 PacketResult Handle_vFile_Mode(StringExtractorGDBRemote &packet);
75 PacketResult Handle_vFile_Exists(StringExtractorGDBRemote &packet);
77 PacketResult Handle_vFile_symlink(StringExtractorGDBRemote &packet);
79 PacketResult Handle_vFile_unlink(StringExtractorGDBRemote &packet);
81 PacketResult Handle_vFile_Stat(StringExtractorGDBRemote &packet);
83 PacketResult Handle_vFile_MD5(StringExtractorGDBRemote &packet);
85 PacketResult Handle_qEcho(StringExtractorGDBRemote &packet);
87 PacketResult Handle_qModuleInfo(StringExtractorGDBRemote &packet);
89 PacketResult Handle_jModulesInfo(StringExtractorGDBRemote &packet);
91 PacketResult Handle_qPlatform_shell(StringExtractorGDBRemote &packet);
93 PacketResult Handle_qPlatform_mkdir(StringExtractorGDBRemote &packet);
95 PacketResult Handle_qPlatform_chmod(StringExtractorGDBRemote &packet);
97 PacketResult Handle_qSupported(StringExtractorGDBRemote &packet);
99 PacketResult Handle_QThreadSuffixSupported(StringExtractorGDBRemote &packet);
101 PacketResult Handle_QListThreadsInStopReply(StringExtractorGDBRemote &packet);
103 PacketResult Handle_QSetDetachOnError(StringExtractorGDBRemote &packet);
105 PacketResult Handle_QStartNoAckMode(StringExtractorGDBRemote &packet);
107 PacketResult Handle_QSetSTDIN(StringExtractorGDBRemote &packet);
109 PacketResult Handle_QSetSTDOUT(StringExtractorGDBRemote &packet);
111 PacketResult Handle_QSetSTDERR(StringExtractorGDBRemote &packet);
113 PacketResult Handle_qLaunchSuccess(StringExtractorGDBRemote &packet);
115 PacketResult Handle_QEnvironment(StringExtractorGDBRemote &packet);
117 PacketResult Handle_QEnvironmentHexEncoded(StringExtractorGDBRemote &packet);
119 PacketResult Handle_QLaunchArch(StringExtractorGDBRemote &packet);
121 static void CreateProcessInfoResponse(const ProcessInstanceInfo &proc_info,
122 StreamString &response);
124 static void CreateProcessInfoResponse_DebugServerStyle(
125 const ProcessInstanceInfo &proc_info, StreamString &response);
127 template <typename T>
128 void RegisterMemberFunctionHandler(
129 StringExtractorGDBRemote::ServerPacketType packet_type,
130 PacketResult (T::*handler)(StringExtractorGDBRemote &packet)) {
131 RegisterPacketHandler(packet_type,
132 [this, handler](StringExtractorGDBRemote packet,
133 Status &error, bool &interrupt,
135 return (static_cast<T *>(this)->*handler)(packet);
139 //------------------------------------------------------------------
140 /// Launch a process with the current launch settings.
142 /// This method supports running an lldb-gdbserver or similar
143 /// server in a situation where the startup code has been provided
144 /// with all the information for a child process to be launched.
147 /// An Status object indicating the success or failure of the
149 //------------------------------------------------------------------
150 virtual Status LaunchProcess() = 0;
152 virtual FileSpec FindModuleFile(const std::string &module_path,
153 const ArchSpec &arch);
156 ModuleSpec GetModuleInfo(llvm::StringRef module_path, llvm::StringRef triple);
159 } // namespace process_gdb_remote
160 } // namespace lldb_private
162 #endif // liblldb_GDBRemoteCommunicationServerCommon_h_