blob: b3270ab740d02f059c6cc34c564fffd885b5231b [file] [log] [blame]
Tamas Berghammere13c2732015-02-11 10:29:30 +00001//===-- 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 <set>
16
17// Other libraries and framework includes
18#include "lldb/lldb-private-forward.h"
19#include "lldb/Host/Mutex.h"
20#include "lldb/Target/Process.h"
21
22// Project includes
23#include "GDBRemoteCommunicationServer.h"
24#include "GDBRemoteCommunicationServerCommon.h"
25
26class ProcessGDBRemote;
27class StringExtractorGDBRemote;
28
29class GDBRemoteCommunicationServerCommon :
30 public GDBRemoteCommunicationServer
31{
32public:
33 GDBRemoteCommunicationServerCommon(const char *comm_name, const char *listener_name);
34
35 virtual
36 ~GDBRemoteCommunicationServerCommon();
37
38 virtual bool
39 GetThreadSuffixSupported () override
40 {
41 return true;
42 }
43
44 //------------------------------------------------------------------
45 /// Launch a process with the current launch settings.
46 ///
47 /// This method supports running an lldb-gdbserver or similar
48 /// server in a situation where the startup code has been provided
49 /// with all the information for a child process to be launched.
50 ///
51 /// @return
52 /// An Error object indicating the success or failure of the
53 /// launch.
54 //------------------------------------------------------------------
55 virtual lldb_private::Error
56 LaunchProcess () = 0;
57
58protected:
59 std::set<lldb::pid_t> m_spawned_pids;
60 lldb_private::Mutex m_spawned_pids_mutex;
61 lldb_private::ProcessLaunchInfo m_process_launch_info;
62 lldb_private::Error m_process_launch_error;
63 lldb_private::ProcessInstanceInfoList m_proc_infos;
64 uint32_t m_proc_infos_index;
65 bool m_thread_suffix_supported;
66 bool m_list_threads_in_stop_reply;
67
68 PacketResult
69 Handle_A (StringExtractorGDBRemote &packet);
70
71 PacketResult
72 Handle_qHostInfo (StringExtractorGDBRemote &packet);
73
74 PacketResult
75 Handle_qProcessInfoPID (StringExtractorGDBRemote &packet);
76
77 PacketResult
78 Handle_qfProcessInfo (StringExtractorGDBRemote &packet);
79
80 PacketResult
81 Handle_qsProcessInfo (StringExtractorGDBRemote &packet);
82
83 PacketResult
84 Handle_qUserName (StringExtractorGDBRemote &packet);
85
86 PacketResult
87 Handle_qGroupName (StringExtractorGDBRemote &packet);
88
89 PacketResult
90 Handle_qSpeedTest (StringExtractorGDBRemote &packet);
91
92 PacketResult
93 Handle_qKillSpawnedProcess (StringExtractorGDBRemote &packet);
94
95 PacketResult
96 Handle_vFile_Open (StringExtractorGDBRemote &packet);
97
98 PacketResult
99 Handle_vFile_Close (StringExtractorGDBRemote &packet);
100
101 PacketResult
102 Handle_vFile_pRead (StringExtractorGDBRemote &packet);
103
104 PacketResult
105 Handle_vFile_pWrite (StringExtractorGDBRemote &packet);
106
107 PacketResult
108 Handle_vFile_Size (StringExtractorGDBRemote &packet);
109
110 PacketResult
111 Handle_vFile_Mode (StringExtractorGDBRemote &packet);
112
113 PacketResult
114 Handle_vFile_Exists (StringExtractorGDBRemote &packet);
115
116 PacketResult
117 Handle_vFile_symlink (StringExtractorGDBRemote &packet);
118
119 PacketResult
120 Handle_vFile_unlink (StringExtractorGDBRemote &packet);
121
122 PacketResult
123 Handle_vFile_Stat (StringExtractorGDBRemote &packet);
124
125 PacketResult
126 Handle_vFile_MD5 (StringExtractorGDBRemote &packet);
127
128 PacketResult
Oleksiy Vyalov6801be32015-02-25 22:15:44 +0000129 Handle_qModuleInfo (StringExtractorGDBRemote &packet);
130
131 PacketResult
Tamas Berghammere13c2732015-02-11 10:29:30 +0000132 Handle_qPlatform_shell (StringExtractorGDBRemote &packet);
133
134 PacketResult
135 Handle_qPlatform_mkdir (StringExtractorGDBRemote &packet);
136
137 PacketResult
138 Handle_qPlatform_chmod (StringExtractorGDBRemote &packet);
139
140 PacketResult
141 Handle_qSupported (StringExtractorGDBRemote &packet);
142
143 PacketResult
144 Handle_QThreadSuffixSupported (StringExtractorGDBRemote &packet);
145
146 PacketResult
147 Handle_QListThreadsInStopReply (StringExtractorGDBRemote &packet);
148
149 PacketResult
150 Handle_QSetDetachOnError (StringExtractorGDBRemote &packet);
151
152 PacketResult
153 Handle_QStartNoAckMode (StringExtractorGDBRemote &packet);
154
155 PacketResult
156 Handle_QSetSTDIN (StringExtractorGDBRemote &packet);
157
158 PacketResult
159 Handle_QSetSTDOUT (StringExtractorGDBRemote &packet);
160
161 PacketResult
162 Handle_QSetSTDERR (StringExtractorGDBRemote &packet);
163
164 PacketResult
165 Handle_qLaunchSuccess (StringExtractorGDBRemote &packet);
166
167 PacketResult
168 Handle_QEnvironment (StringExtractorGDBRemote &packet);
169
170 PacketResult
171 Handle_QLaunchArch (StringExtractorGDBRemote &packet);
172
173 bool
174 KillSpawnedProcess (lldb::pid_t pid);
175
176 static void
177 CreateProcessInfoResponse (const lldb_private::ProcessInstanceInfo &proc_info,
178 lldb_private::StreamString &response);
179
180 static void
181 CreateProcessInfoResponse_DebugServerStyle (const lldb_private::ProcessInstanceInfo &proc_info,
182 lldb_private::StreamString &response);
183
184 template <typename T>
Tamas Berghammere13c2732015-02-11 10:29:30 +0000185 void
Tamas Berghammer81e92392015-02-18 11:37:46 +0000186 RegisterMemberFunctionHandler (StringExtractorGDBRemote::ServerPacketType packet_type,
187 PacketResult (T::*handler) (StringExtractorGDBRemote& packet))
Tamas Berghammere13c2732015-02-11 10:29:30 +0000188 {
189 RegisterPacketHandler(packet_type,
190 [this, handler] (StringExtractorGDBRemote packet,
191 lldb_private::Error &error,
192 bool &interrupt,
193 bool &quit)
194 {
195 return (static_cast<T*>(this)->*handler) (packet);
196 });
197 }
198};
199
200#endif // liblldb_GDBRemoteCommunicationServerCommon_h_