]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.h
Vendor import of lldb release_39 branch r276489:
[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/lldb-private-forward.h"
20 #include "lldb/Target/Process.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 :
33     public GDBRemoteCommunicationServer
34 {
35 public:
36     GDBRemoteCommunicationServerCommon(const char *comm_name, const char *listener_name);
37
38     ~GDBRemoteCommunicationServerCommon() override;
39
40 protected:
41     ProcessLaunchInfo m_process_launch_info;
42     Error m_process_launch_error;
43     ProcessInstanceInfoList m_proc_infos;
44     uint32_t m_proc_infos_index;
45     bool m_thread_suffix_supported;
46     bool m_list_threads_in_stop_reply;
47
48     PacketResult
49     Handle_A (StringExtractorGDBRemote &packet);
50
51     PacketResult
52     Handle_qHostInfo (StringExtractorGDBRemote &packet);
53
54     PacketResult
55     Handle_qProcessInfoPID (StringExtractorGDBRemote &packet);
56
57     PacketResult
58     Handle_qfProcessInfo (StringExtractorGDBRemote &packet);
59
60     PacketResult
61     Handle_qsProcessInfo (StringExtractorGDBRemote &packet);
62
63     PacketResult
64     Handle_qUserName (StringExtractorGDBRemote &packet);
65
66     PacketResult
67     Handle_qGroupName (StringExtractorGDBRemote &packet);
68
69     PacketResult
70     Handle_qSpeedTest (StringExtractorGDBRemote &packet);
71
72     PacketResult
73     Handle_vFile_Open (StringExtractorGDBRemote &packet);
74
75     PacketResult
76     Handle_vFile_Close (StringExtractorGDBRemote &packet);
77
78     PacketResult
79     Handle_vFile_pRead (StringExtractorGDBRemote &packet);
80
81     PacketResult
82     Handle_vFile_pWrite (StringExtractorGDBRemote &packet);
83
84     PacketResult
85     Handle_vFile_Size (StringExtractorGDBRemote &packet);
86
87     PacketResult
88     Handle_vFile_Mode (StringExtractorGDBRemote &packet);
89
90     PacketResult
91     Handle_vFile_Exists (StringExtractorGDBRemote &packet);
92
93     PacketResult
94     Handle_vFile_symlink (StringExtractorGDBRemote &packet);
95
96     PacketResult
97     Handle_vFile_unlink (StringExtractorGDBRemote &packet);
98
99     PacketResult
100     Handle_vFile_Stat (StringExtractorGDBRemote &packet);
101
102     PacketResult
103     Handle_vFile_MD5 (StringExtractorGDBRemote &packet);
104
105     PacketResult
106     Handle_qEcho (StringExtractorGDBRemote &packet);
107
108     PacketResult
109     Handle_qModuleInfo (StringExtractorGDBRemote &packet);
110
111     PacketResult
112     Handle_qPlatform_shell (StringExtractorGDBRemote &packet);
113
114     PacketResult
115     Handle_qPlatform_mkdir (StringExtractorGDBRemote &packet);
116
117     PacketResult
118     Handle_qPlatform_chmod (StringExtractorGDBRemote &packet);
119
120     PacketResult
121     Handle_qSupported (StringExtractorGDBRemote &packet);
122
123     PacketResult
124     Handle_QThreadSuffixSupported (StringExtractorGDBRemote &packet);
125
126     PacketResult
127     Handle_QListThreadsInStopReply (StringExtractorGDBRemote &packet);
128
129     PacketResult
130     Handle_QSetDetachOnError (StringExtractorGDBRemote &packet);
131
132     PacketResult
133     Handle_QStartNoAckMode (StringExtractorGDBRemote &packet);
134
135     PacketResult
136     Handle_QSetSTDIN (StringExtractorGDBRemote &packet);
137
138     PacketResult
139     Handle_QSetSTDOUT (StringExtractorGDBRemote &packet);
140
141     PacketResult
142     Handle_QSetSTDERR (StringExtractorGDBRemote &packet);
143
144     PacketResult
145     Handle_qLaunchSuccess (StringExtractorGDBRemote &packet);
146
147     PacketResult
148     Handle_QEnvironment (StringExtractorGDBRemote &packet);
149
150     PacketResult
151     Handle_QEnvironmentHexEncoded (StringExtractorGDBRemote &packet);
152
153     PacketResult
154     Handle_QLaunchArch (StringExtractorGDBRemote &packet);
155
156     static void
157     CreateProcessInfoResponse (const ProcessInstanceInfo &proc_info,
158                                StreamString &response);
159
160     static void
161     CreateProcessInfoResponse_DebugServerStyle (const ProcessInstanceInfo &proc_info,
162                                                 StreamString &response);
163
164     template <typename T>
165     void
166     RegisterMemberFunctionHandler (StringExtractorGDBRemote::ServerPacketType packet_type,
167                                    PacketResult (T::*handler) (StringExtractorGDBRemote& packet))
168     {
169         RegisterPacketHandler(packet_type,
170                               [this, handler] (StringExtractorGDBRemote packet,
171                                                Error &error,
172                                                bool &interrupt,
173                                                bool &quit)
174                               {
175                                   return (static_cast<T*>(this)->*handler) (packet);
176                               });
177     }
178
179     bool
180     GetThreadSuffixSupported () override
181     {
182         return true;
183     }
184
185     //------------------------------------------------------------------
186     /// Launch a process with the current launch settings.
187     ///
188     /// This method supports running an lldb-gdbserver or similar
189     /// server in a situation where the startup code has been provided
190     /// with all the information for a child process to be launched.
191     ///
192     /// @return
193     ///     An Error object indicating the success or failure of the
194     ///     launch.
195     //------------------------------------------------------------------
196     virtual Error
197     LaunchProcess () = 0;
198
199     virtual FileSpec
200     FindModuleFile (const std::string& module_path, const ArchSpec& arch);
201 };
202
203 } // namespace process_gdb_remote
204 } // namespace lldb_private
205
206 #endif // liblldb_GDBRemoteCommunicationServerCommon_h_