]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.h
Merge llvm trunk r366426, resolve conflicts, and update FREEBSD-Xlist.
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / source / Plugins / Platform / POSIX / PlatformPOSIX.h
1 //===-- PlatformPOSIX.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_PlatformPOSIX_h_
11 #define liblldb_PlatformPOSIX_h_
12
13 #include <map>
14 #include <memory>
15
16 #include "lldb/Interpreter/Options.h"
17 #include "lldb/Target/Platform.h"
18
19 class PlatformPOSIX : public lldb_private::Platform {
20 public:
21   PlatformPOSIX(bool is_host);
22
23   ~PlatformPOSIX() override;
24
25   //------------------------------------------------------------
26   // lldb_private::Platform functions
27   //------------------------------------------------------------
28
29   bool GetModuleSpec(const lldb_private::FileSpec &module_file_spec,
30                      const lldb_private::ArchSpec &arch,
31                      lldb_private::ModuleSpec &module_spec) override;
32
33   lldb_private::OptionGroupOptions *
34   GetConnectionOptions(lldb_private::CommandInterpreter &interpreter) override;
35
36   const char *GetHostname() override;
37
38   const char *GetUserName(uint32_t uid) override;
39
40   const char *GetGroupName(uint32_t gid) override;
41
42   lldb_private::Status PutFile(const lldb_private::FileSpec &source,
43                                const lldb_private::FileSpec &destination,
44                                uint32_t uid = UINT32_MAX,
45                                uint32_t gid = UINT32_MAX) override;
46
47   lldb::user_id_t OpenFile(const lldb_private::FileSpec &file_spec,
48                            uint32_t flags, uint32_t mode,
49                            lldb_private::Status &error) override;
50
51   bool CloseFile(lldb::user_id_t fd, lldb_private::Status &error) override;
52
53   uint64_t ReadFile(lldb::user_id_t fd, uint64_t offset, void *dst,
54                     uint64_t dst_len, lldb_private::Status &error) override;
55
56   uint64_t WriteFile(lldb::user_id_t fd, uint64_t offset, const void *src,
57                      uint64_t src_len, lldb_private::Status &error) override;
58
59   lldb::user_id_t GetFileSize(const lldb_private::FileSpec &file_spec) override;
60
61   lldb_private::Status
62   CreateSymlink(const lldb_private::FileSpec &src,
63                 const lldb_private::FileSpec &dst) override;
64
65   lldb_private::Status
66   GetFile(const lldb_private::FileSpec &source,
67           const lldb_private::FileSpec &destination) override;
68
69   lldb_private::FileSpec GetRemoteWorkingDirectory() override;
70
71   bool
72   SetRemoteWorkingDirectory(const lldb_private::FileSpec &working_dir) override;
73
74   bool GetRemoteOSVersion() override;
75
76   bool GetRemoteOSBuildString(std::string &s) override;
77
78   bool GetRemoteOSKernelDescription(std::string &s) override;
79
80   lldb_private::ArchSpec GetRemoteSystemArchitecture() override;
81
82   const lldb::UnixSignalsSP &GetRemoteUnixSignals() override;
83
84   lldb_private::Environment GetEnvironment() override;
85
86   bool IsConnected() const override;
87
88   lldb_private::Status RunShellCommand(
89       const char *command,                       // Shouldn't be nullptr
90       const lldb_private::FileSpec &working_dir, // Pass empty FileSpec to use
91                                                  // the current working
92                                                  // directory
93       int *status_ptr, // Pass nullptr if you don't want the process exit status
94       int *signo_ptr,  // Pass nullptr if you don't want the signal that caused
95                        // the process to exit
96       std::string
97           *command_output, // Pass nullptr if you don't want the command output
98       const lldb_private::Timeout<std::micro> &timeout) override;
99
100   lldb_private::Status ResolveExecutable(
101       const lldb_private::ModuleSpec &module_spec, lldb::ModuleSP &module_sp,
102       const lldb_private::FileSpecList *module_search_paths_ptr) override;
103
104   lldb_private::Status
105   GetFileWithUUID(const lldb_private::FileSpec &platform_file,
106                   const lldb_private::UUID *uuid,
107                   lldb_private::FileSpec &local_file) override;
108
109   bool GetProcessInfo(lldb::pid_t pid, lldb_private::ProcessInstanceInfo &proc_info) override;
110
111   uint32_t FindProcesses(const lldb_private::ProcessInstanceInfoMatch &match_info,
112                          lldb_private::ProcessInstanceInfoList &process_infos) override;
113
114   lldb_private::Status MakeDirectory(const lldb_private::FileSpec &file_spec,
115                                      uint32_t mode) override;
116
117   lldb_private::Status
118   GetFilePermissions(const lldb_private::FileSpec &file_spec,
119                      uint32_t &file_permissions) override;
120
121   lldb_private::Status
122   SetFilePermissions(const lldb_private::FileSpec &file_spec,
123                      uint32_t file_permissions) override;
124
125   bool GetFileExists(const lldb_private::FileSpec &file_spec) override;
126
127   lldb_private::Status Unlink(const lldb_private::FileSpec &file_spec) override;
128
129   lldb_private::Status
130   LaunchProcess(lldb_private::ProcessLaunchInfo &launch_info) override;
131
132   lldb_private::Status KillProcess(const lldb::pid_t pid) override;
133
134   lldb::ProcessSP Attach(lldb_private::ProcessAttachInfo &attach_info,
135                          lldb_private::Debugger &debugger,
136                          lldb_private::Target *target, // Can be nullptr, if
137                                                        // nullptr create a new
138                                                        // target, else use
139                                                        // existing one
140                          lldb_private::Status &error) override;
141
142   lldb::ProcessSP DebugProcess(lldb_private::ProcessLaunchInfo &launch_info,
143                                lldb_private::Debugger &debugger,
144                                lldb_private::Target *target, // Can be nullptr,
145                                                              // if nullptr
146                                                              // create a new
147                                                              // target, else use
148                                                              // existing one
149                                lldb_private::Status &error) override;
150
151   std::string GetPlatformSpecificConnectionInformation() override;
152
153   bool CalculateMD5(const lldb_private::FileSpec &file_spec, uint64_t &low,
154                     uint64_t &high) override;
155
156   void CalculateTrapHandlerSymbolNames() override;
157
158   lldb_private::Status ConnectRemote(lldb_private::Args &args) override;
159
160   lldb_private::Status DisconnectRemote() override;
161
162   uint32_t DoLoadImage(lldb_private::Process *process,
163                        const lldb_private::FileSpec &remote_file,
164                        const std::vector<std::string> *paths,
165                        lldb_private::Status &error,
166                        lldb_private::FileSpec *loaded_image) override;
167
168   lldb_private::Status UnloadImage(lldb_private::Process *process,
169                                    uint32_t image_token) override;
170
171   lldb::ProcessSP ConnectProcess(llvm::StringRef connect_url,
172                                  llvm::StringRef plugin_name,
173                                  lldb_private::Debugger &debugger,
174                                  lldb_private::Target *target,
175                                  lldb_private::Status &error) override;
176
177   size_t ConnectToWaitingProcesses(lldb_private::Debugger &debugger,
178                                    lldb_private::Status &error) override;
179
180   lldb_private::ConstString GetFullNameForDylib(lldb_private::ConstString basename) override;
181
182 protected:
183   std::unique_ptr<lldb_private::OptionGroupPlatformRSync>
184       m_option_group_platform_rsync;
185   std::unique_ptr<lldb_private::OptionGroupPlatformSSH>
186       m_option_group_platform_ssh;
187   std::unique_ptr<lldb_private::OptionGroupPlatformCaching>
188       m_option_group_platform_caching;
189
190   std::map<lldb_private::CommandInterpreter *,
191            std::unique_ptr<lldb_private::OptionGroupOptions>>
192       m_options;
193   lldb::PlatformSP m_remote_platform_sp; // Allow multiple ways to connect to a
194                                          // remote POSIX-compliant OS
195
196   lldb_private::Status
197   EvaluateLibdlExpression(lldb_private::Process *process, const char *expr_cstr,
198                           llvm::StringRef expr_prefix,
199                           lldb::ValueObjectSP &result_valobj_sp);
200
201   std::unique_ptr<lldb_private::UtilityFunction>
202   MakeLoadImageUtilityFunction(lldb_private::ExecutionContext &exe_ctx,
203                                lldb_private::Status &error);
204
205   virtual
206   llvm::StringRef GetLibdlFunctionDeclarations(lldb_private::Process *process);
207
208 private:
209   DISALLOW_COPY_AND_ASSIGN(PlatformPOSIX);
210 };
211
212 #endif // liblldb_PlatformPOSIX_h_