]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.h
Vendor import of lldb trunk r290819:
[FreeBSD/FreeBSD.git] / source / Plugins / Process / gdb-remote / GDBRemoteCommunicationServerCommon.h
1 //===-- GDBRemoteCommunicationServerCommon.h --------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef liblldb_GDBRemoteCommunicationServerCommon_h_
11 #define liblldb_GDBRemoteCommunicationServerCommon_h_
12
13 // C Includes
14 // C++ Includes
15 #include <string>
16
17 // Other libraries and framework includes
18 // Project includes
19 #include "lldb/Target/Process.h"
20 #include "lldb/lldb-private-forward.h"
21
22 #include "GDBRemoteCommunicationServer.h"
23 #include "GDBRemoteCommunicationServerCommon.h"
24
25 class StringExtractorGDBRemote;
26
27 namespace lldb_private {
28 namespace process_gdb_remote {
29
30 class ProcessGDBRemote;
31
32 class GDBRemoteCommunicationServerCommon : public GDBRemoteCommunicationServer {
33 public:
34   GDBRemoteCommunicationServerCommon(const char *comm_name,
35                                      const char *listener_name);
36
37   ~GDBRemoteCommunicationServerCommon() override;
38
39 protected:
40   ProcessLaunchInfo m_process_launch_info;
41   Error 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;
46
47   PacketResult Handle_A(StringExtractorGDBRemote &packet);
48
49   PacketResult Handle_qHostInfo(StringExtractorGDBRemote &packet);
50
51   PacketResult Handle_qProcessInfoPID(StringExtractorGDBRemote &packet);
52
53   PacketResult Handle_qfProcessInfo(StringExtractorGDBRemote &packet);
54
55   PacketResult Handle_qsProcessInfo(StringExtractorGDBRemote &packet);
56
57   PacketResult Handle_qUserName(StringExtractorGDBRemote &packet);
58
59   PacketResult Handle_qGroupName(StringExtractorGDBRemote &packet);
60
61   PacketResult Handle_qSpeedTest(StringExtractorGDBRemote &packet);
62
63   PacketResult Handle_vFile_Open(StringExtractorGDBRemote &packet);
64
65   PacketResult Handle_vFile_Close(StringExtractorGDBRemote &packet);
66
67   PacketResult Handle_vFile_pRead(StringExtractorGDBRemote &packet);
68
69   PacketResult Handle_vFile_pWrite(StringExtractorGDBRemote &packet);
70
71   PacketResult Handle_vFile_Size(StringExtractorGDBRemote &packet);
72
73   PacketResult Handle_vFile_Mode(StringExtractorGDBRemote &packet);
74
75   PacketResult Handle_vFile_Exists(StringExtractorGDBRemote &packet);
76
77   PacketResult Handle_vFile_symlink(StringExtractorGDBRemote &packet);
78
79   PacketResult Handle_vFile_unlink(StringExtractorGDBRemote &packet);
80
81   PacketResult Handle_vFile_Stat(StringExtractorGDBRemote &packet);
82
83   PacketResult Handle_vFile_MD5(StringExtractorGDBRemote &packet);
84
85   PacketResult Handle_qEcho(StringExtractorGDBRemote &packet);
86
87   PacketResult Handle_qModuleInfo(StringExtractorGDBRemote &packet);
88
89   PacketResult Handle_jModulesInfo(StringExtractorGDBRemote &packet);
90
91   PacketResult Handle_qPlatform_shell(StringExtractorGDBRemote &packet);
92
93   PacketResult Handle_qPlatform_mkdir(StringExtractorGDBRemote &packet);
94
95   PacketResult Handle_qPlatform_chmod(StringExtractorGDBRemote &packet);
96
97   PacketResult Handle_qSupported(StringExtractorGDBRemote &packet);
98
99   PacketResult Handle_QThreadSuffixSupported(StringExtractorGDBRemote &packet);
100
101   PacketResult Handle_QListThreadsInStopReply(StringExtractorGDBRemote &packet);
102
103   PacketResult Handle_QSetDetachOnError(StringExtractorGDBRemote &packet);
104
105   PacketResult Handle_QStartNoAckMode(StringExtractorGDBRemote &packet);
106
107   PacketResult Handle_QSetSTDIN(StringExtractorGDBRemote &packet);
108
109   PacketResult Handle_QSetSTDOUT(StringExtractorGDBRemote &packet);
110
111   PacketResult Handle_QSetSTDERR(StringExtractorGDBRemote &packet);
112
113   PacketResult Handle_qLaunchSuccess(StringExtractorGDBRemote &packet);
114
115   PacketResult Handle_QEnvironment(StringExtractorGDBRemote &packet);
116
117   PacketResult Handle_QEnvironmentHexEncoded(StringExtractorGDBRemote &packet);
118
119   PacketResult Handle_QLaunchArch(StringExtractorGDBRemote &packet);
120
121   static void CreateProcessInfoResponse(const ProcessInstanceInfo &proc_info,
122                                         StreamString &response);
123
124   static void CreateProcessInfoResponse_DebugServerStyle(
125       const ProcessInstanceInfo &proc_info, StreamString &response);
126
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                                           Error &error, bool &interrupt,
134                                           bool &quit) {
135                             return (static_cast<T *>(this)->*handler)(packet);
136                           });
137   }
138
139   //------------------------------------------------------------------
140   /// Launch a process with the current launch settings.
141   ///
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.
145   ///
146   /// @return
147   ///     An Error object indicating the success or failure of the
148   ///     launch.
149   //------------------------------------------------------------------
150   virtual Error LaunchProcess() = 0;
151
152   virtual FileSpec FindModuleFile(const std::string &module_path,
153                                   const ArchSpec &arch);
154
155 private:
156   ModuleSpec GetModuleInfo(const std::string &module_path,
157                            const std::string &triple);
158 };
159
160 } // namespace process_gdb_remote
161 } // namespace lldb_private
162
163 #endif // liblldb_GDBRemoteCommunicationServerCommon_h_