]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.h
Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / 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 #include <string>
14
15 #include "lldb/Target/Process.h"
16 #include "lldb/lldb-private-forward.h"
17
18 #include "GDBRemoteCommunicationServer.h"
19 #include "GDBRemoteCommunicationServerCommon.h"
20
21 class StringExtractorGDBRemote;
22
23 namespace lldb_private {
24 namespace process_gdb_remote {
25
26 class ProcessGDBRemote;
27
28 class GDBRemoteCommunicationServerCommon : public GDBRemoteCommunicationServer {
29 public:
30   GDBRemoteCommunicationServerCommon(const char *comm_name,
31                                      const char *listener_name);
32
33   ~GDBRemoteCommunicationServerCommon() override;
34
35 protected:
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;
42
43   PacketResult Handle_A(StringExtractorGDBRemote &packet);
44
45   PacketResult Handle_qHostInfo(StringExtractorGDBRemote &packet);
46
47   PacketResult Handle_qProcessInfoPID(StringExtractorGDBRemote &packet);
48
49   PacketResult Handle_qfProcessInfo(StringExtractorGDBRemote &packet);
50
51   PacketResult Handle_qsProcessInfo(StringExtractorGDBRemote &packet);
52
53   PacketResult Handle_qUserName(StringExtractorGDBRemote &packet);
54
55   PacketResult Handle_qGroupName(StringExtractorGDBRemote &packet);
56
57   PacketResult Handle_qSpeedTest(StringExtractorGDBRemote &packet);
58
59   PacketResult Handle_vFile_Open(StringExtractorGDBRemote &packet);
60
61   PacketResult Handle_vFile_Close(StringExtractorGDBRemote &packet);
62
63   PacketResult Handle_vFile_pRead(StringExtractorGDBRemote &packet);
64
65   PacketResult Handle_vFile_pWrite(StringExtractorGDBRemote &packet);
66
67   PacketResult Handle_vFile_Size(StringExtractorGDBRemote &packet);
68
69   PacketResult Handle_vFile_Mode(StringExtractorGDBRemote &packet);
70
71   PacketResult Handle_vFile_Exists(StringExtractorGDBRemote &packet);
72
73   PacketResult Handle_vFile_symlink(StringExtractorGDBRemote &packet);
74
75   PacketResult Handle_vFile_unlink(StringExtractorGDBRemote &packet);
76
77   PacketResult Handle_vFile_Stat(StringExtractorGDBRemote &packet);
78
79   PacketResult Handle_vFile_MD5(StringExtractorGDBRemote &packet);
80
81   PacketResult Handle_qEcho(StringExtractorGDBRemote &packet);
82
83   PacketResult Handle_qModuleInfo(StringExtractorGDBRemote &packet);
84
85   PacketResult Handle_jModulesInfo(StringExtractorGDBRemote &packet);
86
87   PacketResult Handle_qPlatform_shell(StringExtractorGDBRemote &packet);
88
89   PacketResult Handle_qPlatform_mkdir(StringExtractorGDBRemote &packet);
90
91   PacketResult Handle_qPlatform_chmod(StringExtractorGDBRemote &packet);
92
93   PacketResult Handle_qSupported(StringExtractorGDBRemote &packet);
94
95   PacketResult Handle_QThreadSuffixSupported(StringExtractorGDBRemote &packet);
96
97   PacketResult Handle_QListThreadsInStopReply(StringExtractorGDBRemote &packet);
98
99   PacketResult Handle_QSetDetachOnError(StringExtractorGDBRemote &packet);
100
101   PacketResult Handle_QStartNoAckMode(StringExtractorGDBRemote &packet);
102
103   PacketResult Handle_QSetSTDIN(StringExtractorGDBRemote &packet);
104
105   PacketResult Handle_QSetSTDOUT(StringExtractorGDBRemote &packet);
106
107   PacketResult Handle_QSetSTDERR(StringExtractorGDBRemote &packet);
108
109   PacketResult Handle_qLaunchSuccess(StringExtractorGDBRemote &packet);
110
111   PacketResult Handle_QEnvironment(StringExtractorGDBRemote &packet);
112
113   PacketResult Handle_QEnvironmentHexEncoded(StringExtractorGDBRemote &packet);
114
115   PacketResult Handle_QLaunchArch(StringExtractorGDBRemote &packet);
116
117   static void CreateProcessInfoResponse(const ProcessInstanceInfo &proc_info,
118                                         StreamString &response);
119
120   static void CreateProcessInfoResponse_DebugServerStyle(
121       const ProcessInstanceInfo &proc_info, StreamString &response);
122
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,
130                                           bool &quit) {
131                             return (static_cast<T *>(this)->*handler)(packet);
132                           });
133   }
134
135   //------------------------------------------------------------------
136   /// Launch a process with the current launch settings.
137   ///
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.
141   ///
142   /// @return
143   ///     An Status object indicating the success or failure of the
144   ///     launch.
145   //------------------------------------------------------------------
146   virtual Status LaunchProcess() = 0;
147
148   virtual FileSpec FindModuleFile(const std::string &module_path,
149                                   const ArchSpec &arch);
150
151 private:
152   ModuleSpec GetModuleInfo(llvm::StringRef module_path, llvm::StringRef triple);
153 };
154
155 } // namespace process_gdb_remote
156 } // namespace lldb_private
157
158 #endif // liblldb_GDBRemoteCommunicationServerCommon_h_