xref: /llvm-project/lldb/include/lldb/Target/Platform.h (revision 01d8e0fc75a897a6a9c2ce634645457a895ed505)
1 //===-- Platform.h ----------------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLDB_TARGET_PLATFORM_H
10 #define LLDB_TARGET_PLATFORM_H
11 
12 #include <functional>
13 #include <map>
14 #include <memory>
15 #include <mutex>
16 #include <optional>
17 #include <string>
18 #include <vector>
19 
20 #include "lldb/Core/PluginInterface.h"
21 #include "lldb/Core/UserSettingsController.h"
22 #include "lldb/Host/File.h"
23 #include "lldb/Interpreter/Options.h"
24 #include "lldb/Utility/ArchSpec.h"
25 #include "lldb/Utility/ConstString.h"
26 #include "lldb/Utility/FileSpec.h"
27 #include "lldb/Utility/StructuredData.h"
28 #include "lldb/Utility/Timeout.h"
29 #include "lldb/Utility/UserIDResolver.h"
30 #include "lldb/Utility/XcodeSDK.h"
31 #include "lldb/lldb-private-forward.h"
32 #include "lldb/lldb-public.h"
33 
34 #include "llvm/Support/Compiler.h"
35 #include "llvm/Support/Error.h"
36 #include "llvm/Support/VersionTuple.h"
37 
38 namespace lldb_private {
39 
40 class ProcessInstanceInfo;
41 class ProcessInstanceInfoMatch;
42 typedef std::vector<ProcessInstanceInfo> ProcessInstanceInfoList;
43 
44 class ModuleCache;
45 enum MmapFlags { eMmapFlagsPrivate = 1, eMmapFlagsAnon = 2 };
46 
47 class PlatformProperties : public Properties {
48 public:
49   PlatformProperties();
50 
51   static llvm::StringRef GetSettingName();
52 
53   bool GetUseModuleCache() const;
54   bool SetUseModuleCache(bool use_module_cache);
55 
56   FileSpec GetModuleCacheDirectory() const;
57   bool SetModuleCacheDirectory(const FileSpec &dir_spec);
58 
59 private:
60   void SetDefaultModuleCacheDirectory(const FileSpec &dir_spec);
61 };
62 
63 typedef llvm::SmallVector<lldb::addr_t, 6> MmapArgList;
64 
65 /// \class Platform Platform.h "lldb/Target/Platform.h"
66 /// A plug-in interface definition class for debug platform that
67 /// includes many platform abilities such as:
68 ///     \li getting platform information such as supported architectures,
69 ///         supported binary file formats and more
70 ///     \li launching new processes
71 ///     \li attaching to existing processes
72 ///     \li download/upload files
73 ///     \li execute shell commands
74 ///     \li listing and getting info for existing processes
75 ///     \li attaching and possibly debugging the platform's kernel
76 class Platform : public PluginInterface {
77 public:
78   /// Default Constructor
79   Platform(bool is_host_platform);
80 
81   /// The destructor is virtual since this class is designed to be inherited
82   /// from by the plug-in instance.
83   ~Platform() override;
84 
85   static void Initialize();
86 
87   static void Terminate();
88 
89   static PlatformProperties &GetGlobalPlatformProperties();
90 
91   /// Get the native host platform plug-in.
92   ///
93   /// There should only be one of these for each host that LLDB runs upon that
94   /// should be statically compiled in and registered using preprocessor
95   /// macros or other similar build mechanisms in a
96   /// PlatformSubclass::Initialize() function.
97   ///
98   /// This platform will be used as the default platform when launching or
99   /// attaching to processes unless another platform is specified.
100   static lldb::PlatformSP GetHostPlatform();
101 
102   static const char *GetHostPlatformName();
103 
104   static void SetHostPlatform(const lldb::PlatformSP &platform_sp);
105 
106   static lldb::PlatformSP Create(llvm::StringRef name);
107 
108   /// Augments the triple either with information from platform or the host
109   /// system (if platform is null).
110   static ArchSpec GetAugmentedArchSpec(Platform *platform,
111                                        llvm::StringRef triple);
112 
113   /// Set the target's executable based off of the existing architecture
114   /// information in \a target given a path to an executable \a exe_file.
115   ///
116   /// Each platform knows the architectures that it supports and can select
117   /// the correct architecture slice within \a exe_file by inspecting the
118   /// architecture in \a target. If the target had an architecture specified,
119   /// then in can try and obey that request and optionally fail if the
120   /// architecture doesn't match up. If no architecture is specified, the
121   /// platform should select the default architecture from \a exe_file. Any
122   /// application bundles or executable wrappers can also be inspected for the
123   /// actual application binary within the bundle that should be used.
124   ///
125   /// \return
126   ///     Returns \b true if this Platform plug-in was able to find
127   ///     a suitable executable, \b false otherwise.
128   virtual Status ResolveExecutable(const ModuleSpec &module_spec,
129                                    lldb::ModuleSP &exe_module_sp,
130                                    const FileSpecList *module_search_paths_ptr);
131 
132   /// Find a symbol file given a symbol file module specification.
133   ///
134   /// Each platform might have tricks to find symbol files for an executable
135   /// given information in a symbol file ModuleSpec. Some platforms might also
136   /// support symbol files that are bundles and know how to extract the right
137   /// symbol file given a bundle.
138   ///
139   /// \param[in] target
140   ///     The target in which we are trying to resolve the symbol file.
141   ///     The target has a list of modules that we might be able to
142   ///     use in order to help find the right symbol file. If the
143   ///     "m_file" or "m_platform_file" entries in the \a sym_spec
144   ///     are filled in, then we might be able to locate a module in
145   ///     the target, extract its UUID and locate a symbol file.
146   ///     If just the "m_uuid" is specified, then we might be able
147   ///     to find the module in the target that matches that UUID
148   ///     and pair the symbol file along with it. If just "m_symbol_file"
149   ///     is specified, we can use a variety of tricks to locate the
150   ///     symbols in an SDK, PDK, or other development kit location.
151   ///
152   /// \param[in] sym_spec
153   ///     A module spec that describes some information about the
154   ///     symbol file we are trying to resolve. The ModuleSpec might
155   ///     contain the following:
156   ///     m_file - A full or partial path to an executable from the
157   ///              target (might be empty).
158   ///     m_platform_file - Another executable hint that contains
159   ///                       the path to the file as known on the
160   ///                       local/remote platform.
161   ///     m_symbol_file - A full or partial path to a symbol file
162   ///                     or symbol bundle that should be used when
163   ///                     trying to resolve the symbol file.
164   ///     m_arch - The architecture we are looking for when resolving
165   ///              the symbol file.
166   ///     m_uuid - The UUID of the executable and symbol file. This
167   ///              can often be used to match up an executable with
168   ///              a symbol file, or resolve an symbol file in a
169   ///              symbol file bundle.
170   ///
171   /// \param[out] sym_file
172   ///     The resolved symbol file spec if the returned error
173   ///     indicates success.
174   ///
175   /// \return
176   ///     Returns an error that describes success or failure.
177   virtual Status ResolveSymbolFile(Target &target, const ModuleSpec &sym_spec,
178                                    FileSpec &sym_file);
179 
180   /// Resolves the FileSpec to a (possibly) remote path. Remote platforms must
181   /// override this to resolve to a path on the remote side.
182   virtual bool ResolveRemotePath(const FileSpec &platform_path,
183                                  FileSpec &resolved_platform_path);
184 
185   /// Get the OS version from a connected platform.
186   ///
187   /// Some platforms might not be connected to a remote platform, but can
188   /// figure out the OS version for a process. This is common for simulator
189   /// platforms that will run native programs on the current host, but the
190   /// simulator might be simulating a different OS. The \a process parameter
191   /// might be specified to help to determine the OS version.
192   virtual llvm::VersionTuple GetOSVersion(Process *process = nullptr);
193 
194   bool SetOSVersion(llvm::VersionTuple os_version);
195 
196   std::optional<std::string> GetOSBuildString();
197 
198   std::optional<std::string> GetOSKernelDescription();
199 
200   // Returns the name of the platform
201   llvm::StringRef GetName() { return GetPluginName(); }
202 
203   virtual const char *GetHostname();
204 
205   virtual ConstString GetFullNameForDylib(ConstString basename);
206 
207   virtual llvm::StringRef GetDescription() = 0;
208 
209   /// Report the current status for this platform.
210   ///
211   /// The returned string usually involves returning the OS version (if
212   /// available), and any SDK directory that might be being used for local
213   /// file caching, and if connected a quick blurb about what this platform is
214   /// connected to.
215   virtual void GetStatus(Stream &strm);
216 
217   // Subclasses must be able to fetch the current OS version
218   //
219   // Remote classes must be connected for this to succeed. Local subclasses
220   // don't need to override this function as it will just call the
221   // HostInfo::GetOSVersion().
222   virtual bool GetRemoteOSVersion() { return false; }
223 
224   virtual std::optional<std::string> GetRemoteOSBuildString() {
225     return std::nullopt;
226   }
227 
228   virtual std::optional<std::string> GetRemoteOSKernelDescription() {
229     return std::nullopt;
230   }
231 
232   // Remote Platform subclasses need to override this function
233   virtual ArchSpec GetRemoteSystemArchitecture() {
234     return ArchSpec(); // Return an invalid architecture
235   }
236 
237   virtual FileSpec GetRemoteWorkingDirectory() { return m_working_dir; }
238 
239   virtual bool SetRemoteWorkingDirectory(const FileSpec &working_dir);
240 
241   virtual UserIDResolver &GetUserIDResolver();
242 
243   /// Locate a file for a platform.
244   ///
245   /// The default implementation of this function will return the same file
246   /// patch in \a local_file as was in \a platform_file.
247   ///
248   /// \param[in] platform_file
249   ///     The platform file path to locate and cache locally.
250   ///
251   /// \param[in] uuid_ptr
252   ///     If we know the exact UUID of the file we are looking for, it
253   ///     can be specified. If it is not specified, we might now know
254   ///     the exact file. The UUID is usually some sort of MD5 checksum
255   ///     for the file and is sometimes known by dynamic linkers/loaders.
256   ///     If the UUID is known, it is best to supply it to platform
257   ///     file queries to ensure we are finding the correct file, not
258   ///     just a file at the correct path.
259   ///
260   /// \param[out] local_file
261   ///     A locally cached version of the platform file. For platforms
262   ///     that describe the current host computer, this will just be
263   ///     the same file. For remote platforms, this file might come from
264   ///     and SDK directory, or might need to be sync'ed over to the
265   ///     current machine for efficient debugging access.
266   ///
267   /// \return
268   ///     An error object.
269   virtual Status GetFileWithUUID(const FileSpec &platform_file,
270                                  const UUID *uuid_ptr, FileSpec &local_file);
271 
272   // Locate the scripting resource given a module specification.
273   //
274   // Locating the file should happen only on the local computer or using the
275   // current computers global settings.
276   virtual FileSpecList
277   LocateExecutableScriptingResources(Target *target, Module &module,
278                                      Stream &feedback_stream);
279 
280   /// \param[in] module_spec
281   ///     The ModuleSpec of a binary to find.
282   ///
283   /// \param[in] process
284   ///     A Process.
285   ///
286   /// \param[out] module_sp
287   ///     A Module that matches the ModuleSpec, if one is found.
288   ///
289   /// \param[in] module_search_paths_ptr
290   ///     Locations to possibly look for a binary that matches the ModuleSpec.
291   ///
292   /// \param[out] old_modules
293   ///     Existing Modules in the Process' Target image list which match
294   ///     the FileSpec.
295   ///
296   /// \param[out] did_create_ptr
297   ///     Optional boolean, nullptr may be passed for this argument.
298   ///     If this method is returning a *new* ModuleSP, this
299   ///     will be set to true.
300   ///     If this method is returning a ModuleSP that is already in the
301   ///     Target's image list, it will be false.
302   ///
303   /// \return
304   ///     The Status object for any errors found while searching for
305   ///     the binary.
306   virtual Status GetSharedModule(
307       const ModuleSpec &module_spec, Process *process,
308       lldb::ModuleSP &module_sp, const FileSpecList *module_search_paths_ptr,
309       llvm::SmallVectorImpl<lldb::ModuleSP> *old_modules, bool *did_create_ptr);
310 
311   void CallLocateModuleCallbackIfSet(const ModuleSpec &module_spec,
312                                      lldb::ModuleSP &module_sp,
313                                      FileSpec &symbol_file_spec,
314                                      bool *did_create_ptr);
315 
316   virtual bool GetModuleSpec(const FileSpec &module_file_spec,
317                              const ArchSpec &arch, ModuleSpec &module_spec);
318 
319   virtual Status ConnectRemote(Args &args);
320 
321   virtual Status DisconnectRemote();
322 
323   /// Get the platform's supported architectures in the order in which they
324   /// should be searched.
325   ///
326   /// \param[in] process_host_arch
327   ///     The process host architecture if it's known. An invalid ArchSpec
328   ///     represents that the process host architecture is unknown.
329   virtual std::vector<ArchSpec>
330   GetSupportedArchitectures(const ArchSpec &process_host_arch) = 0;
331 
332   virtual size_t GetSoftwareBreakpointTrapOpcode(Target &target,
333                                                  BreakpointSite *bp_site);
334 
335   /// Launch a new process on a platform, not necessarily for debugging, it
336   /// could be just for running the process.
337   virtual Status LaunchProcess(ProcessLaunchInfo &launch_info);
338 
339   /// Perform expansion of the command-line for this launch info This can
340   /// potentially involve wildcard expansion
341   /// environment variable replacement, and whatever other
342   /// argument magic the platform defines as part of its typical
343   /// user experience
344   virtual Status ShellExpandArguments(ProcessLaunchInfo &launch_info);
345 
346   /// Kill process on a platform.
347   virtual Status KillProcess(const lldb::pid_t pid);
348 
349   /// Lets a platform answer if it is compatible with a given architecture and
350   /// the target triple contained within.
351   virtual bool IsCompatibleArchitecture(const ArchSpec &arch,
352                                         const ArchSpec &process_host_arch,
353                                         ArchSpec::MatchType match,
354                                         ArchSpec *compatible_arch_ptr);
355 
356   /// Not all platforms will support debugging a process by spawning somehow
357   /// halted for a debugger (specified using the "eLaunchFlagDebug" launch
358   /// flag) and then attaching. If your platform doesn't support this,
359   /// override this function and return false.
360   virtual bool CanDebugProcess() { return true; }
361 
362   /// Subclasses do not need to implement this function as it uses the
363   /// Platform::LaunchProcess() followed by Platform::Attach (). Remote
364   /// platforms will want to subclass this function in order to be able to
365   /// intercept STDIO and possibly launch a separate process that will debug
366   /// the debuggee.
367   virtual lldb::ProcessSP DebugProcess(ProcessLaunchInfo &launch_info,
368                                        Debugger &debugger, Target &target,
369                                        Status &error);
370 
371   virtual lldb::ProcessSP ConnectProcess(llvm::StringRef connect_url,
372                                          llvm::StringRef plugin_name,
373                                          Debugger &debugger, Target *target,
374                                          Status &error);
375 
376   virtual lldb::ProcessSP
377   ConnectProcessSynchronous(llvm::StringRef connect_url,
378                             llvm::StringRef plugin_name, Debugger &debugger,
379                             Stream &stream, Target *target, Status &error);
380 
381   /// Attach to an existing process using a process ID.
382   ///
383   /// Each platform subclass needs to implement this function and attempt to
384   /// attach to the process with the process ID of \a pid. The platform
385   /// subclass should return an appropriate ProcessSP subclass that is
386   /// attached to the process, or an empty shared pointer with an appropriate
387   /// error.
388   ///
389   /// \return
390   ///     An appropriate ProcessSP containing a valid shared pointer
391   ///     to the default Process subclass for the platform that is
392   ///     attached to the process, or an empty shared pointer with an
393   ///     appropriate error fill into the \a error object.
394   virtual lldb::ProcessSP Attach(ProcessAttachInfo &attach_info,
395                                  Debugger &debugger,
396                                  Target *target, // Can be nullptr, if nullptr
397                                                  // create a new target, else
398                                                  // use existing one
399                                  Status &error) = 0;
400 
401   /// Attach to an existing process by process name.
402   ///
403   /// This function is not meant to be overridden by Process subclasses. It
404   /// will first call Process::WillAttach (const char *) and if that returns
405   /// \b true, Process::DoAttach (const char *) will be called to actually do
406   /// the attach. If DoAttach returns \b true, then Process::DidAttach() will
407   /// be called.
408   ///
409   /// \param[in] process_name
410   ///     A process name to match against the current process list.
411   ///
412   /// \return
413   ///     Returns \a pid if attaching was successful, or
414   ///     LLDB_INVALID_PROCESS_ID if attaching fails.
415   //        virtual lldb::ProcessSP
416   //        Attach (const char *process_name,
417   //                bool wait_for_launch,
418   //                Status &error) = 0;
419 
420   // The base class Platform will take care of the host platform. Subclasses
421   // will need to fill in the remote case.
422   virtual uint32_t FindProcesses(const ProcessInstanceInfoMatch &match_info,
423                                  ProcessInstanceInfoList &proc_infos);
424 
425   ProcessInstanceInfoList GetAllProcesses();
426 
427   virtual bool GetProcessInfo(lldb::pid_t pid, ProcessInstanceInfo &proc_info);
428 
429   // Set a breakpoint on all functions that can end up creating a thread for
430   // this platform. This is needed when running expressions and also for
431   // process control.
432   virtual lldb::BreakpointSP SetThreadCreationBreakpoint(Target &target);
433 
434   // Given a target, find the local SDK directory if one exists on the current
435   // host.
436   virtual lldb_private::ConstString
437   GetSDKDirectory(lldb_private::Target &target) {
438     return lldb_private::ConstString();
439   }
440 
441   /// Search each CU associated with the specified 'module' for
442   /// the SDK paths the CUs were compiled against. In the presence
443   /// of different SDKs, we try to pick the most appropriate one
444   /// using \ref XcodeSDK::Merge.
445   ///
446   /// \param[in] module Module whose debug-info CUs to parse for
447   ///                   which SDK they were compiled against.
448   ///
449   /// \returns If successful, returns a pair of a parsed XcodeSDK
450   ///          object and a boolean that is 'true' if we encountered
451   ///          a conflicting combination of SDKs when parsing the CUs
452   ///          (e.g., a public and internal SDK).
453   virtual llvm::Expected<std::pair<XcodeSDK, bool>>
454   GetSDKPathFromDebugInfo(Module &module) {
455     return llvm::createStringError(
456         llvm::formatv("{0} not implemented for '{1}' platform.",
457                       LLVM_PRETTY_FUNCTION, GetName()));
458   }
459 
460   /// Returns the full path of the most appropriate SDK for the
461   /// specified 'module'. This function gets this path by parsing
462   /// debug-info (see \ref `GetSDKPathFromDebugInfo`).
463   ///
464   /// \param[in] module Module whose debug-info to parse for
465   ///                   which SDK it was compiled against.
466   ///
467   /// \returns If successful, returns the full path to an
468   ///          Xcode SDK.
469   virtual llvm::Expected<std::string>
470   ResolveSDKPathFromDebugInfo(Module &module) {
471     return llvm::createStringError(
472         llvm::formatv("{0} not implemented for '{1}' platform.",
473                       LLVM_PRETTY_FUNCTION, GetName()));
474   }
475 
476   /// Search CU for the SDK path the CUs was compiled against.
477   ///
478   /// \param[in] unit The CU
479   ///
480   /// \returns A parsed XcodeSDK object if successful, an Error otherwise.
481   virtual llvm::Expected<XcodeSDK> GetSDKPathFromDebugInfo(CompileUnit &unit) {
482     return llvm::createStringError(
483         llvm::formatv("{0} not implemented for '{1}' platform.",
484                       LLVM_PRETTY_FUNCTION, GetName()));
485   }
486 
487   /// Returns the full path of the most appropriate SDK for the
488   /// specified compile unit. This function gets this path by parsing
489   /// debug-info (see \ref `GetSDKPathFromDebugInfo`).
490   ///
491   /// \param[in] unit The CU to scan.
492   ///
493   /// \returns If successful, returns the full path to an
494   ///          Xcode SDK.
495   virtual llvm::Expected<std::string>
496   ResolveSDKPathFromDebugInfo(CompileUnit &unit) {
497     return llvm::createStringError(
498         llvm::formatv("{0} not implemented for '{1}' platform.",
499                       LLVM_PRETTY_FUNCTION, GetName()));
500   }
501 
502   bool IsHost() const {
503     return m_is_host; // Is this the default host platform?
504   }
505 
506   bool IsRemote() const { return !m_is_host; }
507 
508   virtual bool IsConnected() const {
509     // Remote subclasses should override this function
510     return IsHost();
511   }
512 
513   const ArchSpec &GetSystemArchitecture();
514 
515   void SetSystemArchitecture(const ArchSpec &arch) {
516     m_system_arch = arch;
517     if (IsHost())
518       m_os_version_set_while_connected = m_system_arch.IsValid();
519   }
520 
521   /// If the triple contains not specify the vendor, os, and environment
522   /// parts, we "augment" these using information from the platform and return
523   /// the resulting ArchSpec object.
524   ArchSpec GetAugmentedArchSpec(llvm::StringRef triple);
525 
526   // Used for column widths
527   size_t GetMaxUserIDNameLength() const { return m_max_uid_name_len; }
528 
529   // Used for column widths
530   size_t GetMaxGroupIDNameLength() const { return m_max_gid_name_len; }
531 
532   const std::string &GetSDKRootDirectory() const { return m_sdk_sysroot; }
533 
534   void SetSDKRootDirectory(std::string dir) { m_sdk_sysroot = std::move(dir); }
535 
536   const std::string &GetSDKBuild() const { return m_sdk_build; }
537 
538   void SetSDKBuild(std::string sdk_build) {
539     m_sdk_build = std::move(sdk_build);
540   }
541 
542   // Override this to return true if your platform supports Clang modules. You
543   // may also need to override AddClangModuleCompilationOptions to pass the
544   // right Clang flags for your platform.
545   virtual bool SupportsModules() { return false; }
546 
547   // Appends the platform-specific options required to find the modules for the
548   // current platform.
549   virtual void
550   AddClangModuleCompilationOptions(Target *target,
551                                    std::vector<std::string> &options);
552 
553   FileSpec GetWorkingDirectory();
554 
555   bool SetWorkingDirectory(const FileSpec &working_dir);
556 
557   // There may be modules that we don't want to find by default for operations
558   // like "setting breakpoint by name". The platform will return "true" from
559   // this call if the passed in module happens to be one of these.
560 
561   virtual bool
562   ModuleIsExcludedForUnconstrainedSearches(Target &target,
563                                            const lldb::ModuleSP &module_sp) {
564     return false;
565   }
566 
567   virtual Status MakeDirectory(const FileSpec &file_spec, uint32_t permissions);
568 
569   virtual Status GetFilePermissions(const FileSpec &file_spec,
570                                     uint32_t &file_permissions);
571 
572   virtual Status SetFilePermissions(const FileSpec &file_spec,
573                                     uint32_t file_permissions);
574 
575   virtual lldb::user_id_t OpenFile(const FileSpec &file_spec,
576                                    File::OpenOptions flags, uint32_t mode,
577                                    Status &error);
578 
579   virtual bool CloseFile(lldb::user_id_t fd, Status &error);
580 
581   virtual lldb::user_id_t GetFileSize(const FileSpec &file_spec);
582 
583   virtual void AutoCompleteDiskFileOrDirectory(CompletionRequest &request,
584                                                bool only_dir) {}
585 
586   virtual uint64_t ReadFile(lldb::user_id_t fd, uint64_t offset, void *dst,
587                             uint64_t dst_len, Status &error);
588 
589   virtual uint64_t WriteFile(lldb::user_id_t fd, uint64_t offset,
590                              const void *src, uint64_t src_len, Status &error);
591 
592   virtual Status GetFile(const FileSpec &source, const FileSpec &destination);
593 
594   virtual Status PutFile(const FileSpec &source, const FileSpec &destination,
595                          uint32_t uid = UINT32_MAX, uint32_t gid = UINT32_MAX);
596 
597   virtual Status
598   CreateSymlink(const FileSpec &src,  // The name of the link is in src
599                 const FileSpec &dst); // The symlink points to dst
600 
601   /// Install a file or directory to the remote system.
602   ///
603   /// Install is similar to Platform::PutFile(), but it differs in that if an
604   /// application/framework/shared library is installed on a remote platform
605   /// and the remote platform requires something to be done to register the
606   /// application/framework/shared library, then this extra registration can
607   /// be done.
608   ///
609   /// \param[in] src
610   ///     The source file/directory to install on the remote system.
611   ///
612   /// \param[in] dst
613   ///     The destination file/directory where \a src will be installed.
614   ///     If \a dst has no filename specified, then its filename will
615   ///     be set from \a src. It \a dst has no directory specified, it
616   ///     will use the platform working directory. If \a dst has a
617   ///     directory specified, but the directory path is relative, the
618   ///     platform working directory will be prepended to the relative
619   ///     directory.
620   ///
621   /// \return
622   ///     An error object that describes anything that went wrong.
623   virtual Status Install(const FileSpec &src, const FileSpec &dst);
624 
625   virtual Environment GetEnvironment();
626 
627   virtual bool GetFileExists(const lldb_private::FileSpec &file_spec);
628 
629   virtual Status Unlink(const FileSpec &file_spec);
630 
631   virtual MmapArgList GetMmapArgumentList(const ArchSpec &arch,
632                                           lldb::addr_t addr,
633                                           lldb::addr_t length,
634                                           unsigned prot, unsigned flags,
635                                           lldb::addr_t fd, lldb::addr_t offset);
636 
637   virtual bool GetSupportsRSync() { return m_supports_rsync; }
638 
639   virtual void SetSupportsRSync(bool flag) { m_supports_rsync = flag; }
640 
641   virtual const char *GetRSyncOpts() { return m_rsync_opts.c_str(); }
642 
643   virtual void SetRSyncOpts(const char *opts) { m_rsync_opts.assign(opts); }
644 
645   virtual const char *GetRSyncPrefix() { return m_rsync_prefix.c_str(); }
646 
647   virtual void SetRSyncPrefix(const char *prefix) {
648     m_rsync_prefix.assign(prefix);
649   }
650 
651   virtual bool GetSupportsSSH() { return m_supports_ssh; }
652 
653   virtual void SetSupportsSSH(bool flag) { m_supports_ssh = flag; }
654 
655   virtual const char *GetSSHOpts() { return m_ssh_opts.c_str(); }
656 
657   virtual void SetSSHOpts(const char *opts) { m_ssh_opts.assign(opts); }
658 
659   virtual bool GetIgnoresRemoteHostname() { return m_ignores_remote_hostname; }
660 
661   virtual void SetIgnoresRemoteHostname(bool flag) {
662     m_ignores_remote_hostname = flag;
663   }
664 
665   virtual lldb_private::OptionGroupOptions *
666   GetConnectionOptions(CommandInterpreter &interpreter) {
667     return nullptr;
668   }
669 
670   virtual lldb_private::Status RunShellCommand(
671       llvm::StringRef command,
672       const FileSpec &working_dir, // Pass empty FileSpec to use the current
673                                    // working directory
674       int *status_ptr, // Pass nullptr if you don't want the process exit status
675       int *signo_ptr,  // Pass nullptr if you don't want the signal that caused
676                        // the process to exit
677       std::string
678           *command_output, // Pass nullptr if you don't want the command output
679       const Timeout<std::micro> &timeout);
680 
681   virtual lldb_private::Status RunShellCommand(
682       llvm::StringRef shell, llvm::StringRef command,
683       const FileSpec &working_dir, // Pass empty FileSpec to use the current
684                                    // working directory
685       int *status_ptr, // Pass nullptr if you don't want the process exit status
686       int *signo_ptr,  // Pass nullptr if you don't want the signal that caused
687                        // the process to exit
688       std::string
689           *command_output, // Pass nullptr if you don't want the command output
690       const Timeout<std::micro> &timeout);
691 
692   virtual void SetLocalCacheDirectory(const char *local);
693 
694   virtual const char *GetLocalCacheDirectory();
695 
696   virtual std::string GetPlatformSpecificConnectionInformation() { return ""; }
697 
698   virtual llvm::ErrorOr<llvm::MD5::MD5Result>
699   CalculateMD5(const FileSpec &file_spec);
700 
701   virtual uint32_t GetResumeCountForLaunchInfo(ProcessLaunchInfo &launch_info) {
702     return 1;
703   }
704 
705   virtual const lldb::UnixSignalsSP &GetRemoteUnixSignals();
706 
707   lldb::UnixSignalsSP GetUnixSignals();
708 
709   /// Locate a queue name given a thread's qaddr
710   ///
711   /// On a system using libdispatch ("Grand Central Dispatch") style queues, a
712   /// thread may be associated with a GCD queue or not, and a queue may be
713   /// associated with multiple threads. The process/thread must provide a way
714   /// to find the "dispatch_qaddr" for each thread, and from that
715   /// dispatch_qaddr this Platform method will locate the queue name and
716   /// provide that.
717   ///
718   /// \param[in] process
719   ///     A process is required for reading memory.
720   ///
721   /// \param[in] dispatch_qaddr
722   ///     The dispatch_qaddr for this thread.
723   ///
724   /// \return
725   ///     The name of the queue, if there is one.  An empty string
726   ///     means that this thread is not associated with a dispatch
727   ///     queue.
728   virtual std::string
729   GetQueueNameForThreadQAddress(Process *process, lldb::addr_t dispatch_qaddr) {
730     return "";
731   }
732 
733   /// Locate a queue ID given a thread's qaddr
734   ///
735   /// On a system using libdispatch ("Grand Central Dispatch") style queues, a
736   /// thread may be associated with a GCD queue or not, and a queue may be
737   /// associated with multiple threads. The process/thread must provide a way
738   /// to find the "dispatch_qaddr" for each thread, and from that
739   /// dispatch_qaddr this Platform method will locate the queue ID and provide
740   /// that.
741   ///
742   /// \param[in] process
743   ///     A process is required for reading memory.
744   ///
745   /// \param[in] dispatch_qaddr
746   ///     The dispatch_qaddr for this thread.
747   ///
748   /// \return
749   ///     The queue_id for this thread, if this thread is associated
750   ///     with a dispatch queue.  Else LLDB_INVALID_QUEUE_ID is returned.
751   virtual lldb::queue_id_t
752   GetQueueIDForThreadQAddress(Process *process, lldb::addr_t dispatch_qaddr) {
753     return LLDB_INVALID_QUEUE_ID;
754   }
755 
756   /// Provide a list of trap handler function names for this platform
757   ///
758   /// The unwinder needs to treat trap handlers specially -- the stack frame
759   /// may not be aligned correctly for a trap handler (the kernel often won't
760   /// perturb the stack pointer, or won't re-align it properly, in the process
761   /// of calling the handler) and the frame above the handler needs to be
762   /// treated by the unwinder's "frame 0" rules instead of its "middle of the
763   /// stack frame" rules.
764   ///
765   /// In a user process debugging scenario, the list of trap handlers is
766   /// typically just "_sigtramp".
767   ///
768   /// The Platform base class provides the m_trap_handlers ivar but it does
769   /// not populate it.  Subclasses should add the names of the asynchronous
770   /// signal handler routines as needed.  For most Unix platforms, add
771   /// _sigtramp.
772   ///
773   /// \return
774   ///     A list of symbol names.  The list may be empty.
775   virtual const std::vector<ConstString> &GetTrapHandlerSymbolNames();
776 
777   /// Try to get a specific unwind plan for a named trap handler.
778   /// The default is not to have specific unwind plans for trap handlers.
779   ///
780   /// \param[in] triple
781   ///     Triple of the current target.
782   ///
783   /// \param[in] name
784   ///     Name of the trap handler function.
785   ///
786   /// \return
787   ///     A specific unwind plan for that trap handler, or an empty
788   ///     shared pointer. The latter means there is no specific plan,
789   ///     unwind as normal.
790   virtual lldb::UnwindPlanSP
791   GetTrapHandlerUnwindPlan(const llvm::Triple &triple, ConstString name) {
792     return {};
793   }
794 
795   /// Find a support executable that may not live within in the standard
796   /// locations related to LLDB.
797   ///
798   /// Executable might exist within the Platform SDK directories, or in
799   /// standard tool directories within the current IDE that is running LLDB.
800   ///
801   /// \param[in] basename
802   ///     The basename of the executable to locate in the current
803   ///     platform.
804   ///
805   /// \return
806   ///     A FileSpec pointing to the executable on disk, or an invalid
807   ///     FileSpec if the executable cannot be found.
808   virtual FileSpec LocateExecutable(const char *basename) { return FileSpec(); }
809 
810   /// Allow the platform to set preferred memory cache line size. If non-zero
811   /// (and the user has not set cache line size explicitly), this value will
812   /// be used as the cache line size for memory reads.
813   virtual uint32_t GetDefaultMemoryCacheLineSize() { return 0; }
814 
815   /// Load a shared library into this process.
816   ///
817   /// Try and load a shared library into the current process. This call might
818   /// fail in the dynamic loader plug-in says it isn't safe to try and load
819   /// shared libraries at the moment.
820   ///
821   /// \param[in] process
822   ///     The process to load the image.
823   ///
824   /// \param[in] local_file
825   ///     The file spec that points to the shared library that you want
826   ///     to load if the library is located on the host. The library will
827   ///     be copied over to the location specified by remote_file or into
828   ///     the current working directory with the same filename if the
829   ///     remote_file isn't specified.
830   ///
831   /// \param[in] remote_file
832   ///     If local_file is specified then the location where the library
833   ///     should be copied over from the host. If local_file isn't
834   ///     specified, then the path for the shared library on the target
835   ///     what you want to load.
836   ///
837   /// \param[out] error
838   ///     An error object that gets filled in with any errors that
839   ///     might occur when trying to load the shared library.
840   ///
841   /// \return
842   ///     A token that represents the shared library that can be
843   ///     later used to unload the shared library. A value of
844   ///     LLDB_INVALID_IMAGE_TOKEN will be returned if the shared
845   ///     library can't be opened.
846   uint32_t LoadImage(lldb_private::Process *process,
847                      const lldb_private::FileSpec &local_file,
848                      const lldb_private::FileSpec &remote_file,
849                      lldb_private::Status &error);
850 
851   /// Load a shared library specified by base name into this process,
852   /// looking by hand along a set of paths.
853   ///
854   /// \param[in] process
855   ///     The process to load the image.
856   ///
857   /// \param[in] library_name
858   ///     The name of the library to look for.  If library_name is an
859   ///     absolute path, the basename will be extracted and searched for
860   ///     along the paths.  This emulates the behavior of the loader when
861   ///     given an install name and a set (e.g. DYLD_LIBRARY_PATH provided) of
862   ///     alternate paths.
863   ///
864   /// \param[in] paths
865   ///     The list of paths to use to search for the library.  First
866   ///     match wins.
867   ///
868   /// \param[out] error
869   ///     An error object that gets filled in with any errors that
870   ///     might occur when trying to load the shared library.
871   ///
872   /// \param[out] loaded_path
873   ///      If non-null, the path to the dylib that was successfully loaded
874   ///      is stored in this path.
875   ///
876   /// \return
877   ///     A token that represents the shared library which can be
878   ///     passed to UnloadImage. A value of
879   ///     LLDB_INVALID_IMAGE_TOKEN will be returned if the shared
880   ///     library can't be opened.
881   uint32_t LoadImageUsingPaths(lldb_private::Process *process,
882                                const lldb_private::FileSpec &library_name,
883                                const std::vector<std::string> &paths,
884                                lldb_private::Status &error,
885                                lldb_private::FileSpec *loaded_path);
886 
887   virtual uint32_t DoLoadImage(lldb_private::Process *process,
888                                const lldb_private::FileSpec &remote_file,
889                                const std::vector<std::string> *paths,
890                                lldb_private::Status &error,
891                                lldb_private::FileSpec *loaded_path = nullptr);
892 
893   virtual Status UnloadImage(lldb_private::Process *process,
894                              uint32_t image_token);
895 
896   /// Connect to all processes waiting for a debugger to attach
897   ///
898   /// If the platform have a list of processes waiting for a debugger to
899   /// connect to them then connect to all of these pending processes.
900   ///
901   /// \param[in] debugger
902   ///     The debugger used for the connect.
903   ///
904   /// \param[out] error
905   ///     If an error occurred during the connect then this object will
906   ///     contain the error message.
907   ///
908   /// \return
909   ///     The number of processes we are successfully connected to.
910   virtual size_t ConnectToWaitingProcesses(lldb_private::Debugger &debugger,
911                                            lldb_private::Status &error);
912 
913   /// Gather all of crash informations into a structured data dictionary.
914   ///
915   /// If the platform have a crashed process with crash information entries,
916   /// gather all the entries into an structured data dictionary or return a
917   /// nullptr. This dictionary is generic and extensible, as it contains an
918   /// array for each different type of crash information.
919   ///
920   /// \param[in] process
921   ///     The crashed process.
922   ///
923   /// \return
924   ///     A structured data dictionary containing at each entry, the crash
925   ///     information type as the entry key and the matching  an array as the
926   ///     entry value. \b nullptr if not implemented or  if the process has no
927   ///     crash information entry. \b error if an error occured.
928   virtual llvm::Expected<StructuredData::DictionarySP>
929   FetchExtendedCrashInformation(lldb_private::Process &process) {
930     return nullptr;
931   }
932 
933   /// Detect a binary in memory that will determine which Platform and
934   /// DynamicLoader should be used in this target/process, and update
935   /// the Platform/DynamicLoader.
936   /// The binary will be loaded into the Target, or will be registered with
937   /// the DynamicLoader so that it will be loaded at a later stage.  Returns
938   /// true to indicate that this is a platform binary and has been
939   /// loaded/registered, no further action should be taken by the caller.
940   ///
941   /// \param[in] process
942   ///     Process read memory from, a Process must be provided.
943   ///
944   /// \param[in] addr
945   ///     Address of a binary in memory.
946   ///
947   /// \param[in] notify
948   ///     Whether ModulesDidLoad should be called, if a binary is loaded.
949   ///     Caller may prefer to call ModulesDidLoad for multiple binaries
950   ///     that were loaded at the same time.
951   ///
952   /// \return
953   ///     Returns true if the binary was loaded in the target (or will be
954   ///     via a DynamicLoader).  Returns false if the binary was not
955   ///     loaded/registered, and the caller must load it into the target.
956   virtual bool LoadPlatformBinaryAndSetup(Process *process, lldb::addr_t addr,
957                                           bool notify) {
958     return false;
959   }
960 
961   virtual CompilerType GetSiginfoType(const llvm::Triple &triple);
962 
963   virtual Args GetExtraStartupCommands();
964 
965   typedef std::function<Status(const ModuleSpec &module_spec,
966                                FileSpec &module_file_spec,
967                                FileSpec &symbol_file_spec)>
968       LocateModuleCallback;
969 
970   /// Set locate module callback. This allows users to implement their own
971   /// module cache system. For example, to leverage artifacts of build system,
972   /// to bypass pulling files from remote platform, or to search symbol files
973   /// from symbol servers.
974   void SetLocateModuleCallback(LocateModuleCallback callback);
975 
976   LocateModuleCallback GetLocateModuleCallback() const;
977 
978 protected:
979   /// Create a list of ArchSpecs with the given OS and a architectures. The
980   /// vendor field is left as an "unspecified unknown".
981   static std::vector<ArchSpec>
982   CreateArchList(llvm::ArrayRef<llvm::Triple::ArchType> archs,
983                  llvm::Triple::OSType os);
984 
985   /// Private implementation of connecting to a process. If the stream is set
986   /// we connect synchronously.
987   lldb::ProcessSP DoConnectProcess(llvm::StringRef connect_url,
988                                    llvm::StringRef plugin_name,
989                                    Debugger &debugger, Stream *stream,
990                                    Target *target, Status &error);
991   bool m_is_host;
992   // Set to true when we are able to actually set the OS version while being
993   // connected. For remote platforms, we might set the version ahead of time
994   // before we actually connect and this version might change when we actually
995   // connect to a remote platform. For the host platform this will be set to
996   // the once we call HostInfo::GetOSVersion().
997   bool m_os_version_set_while_connected;
998   bool m_system_arch_set_while_connected;
999   std::string
1000       m_sdk_sysroot; // the root location of where the SDK files are all located
1001   std::string m_sdk_build;
1002   FileSpec m_working_dir; // The working directory which is used when installing
1003                           // modules that have no install path set
1004   std::string m_hostname;
1005   llvm::VersionTuple m_os_version;
1006   ArchSpec
1007       m_system_arch; // The architecture of the kernel or the remote platform
1008   typedef std::map<uint32_t, ConstString> IDToNameMap;
1009   // Mutex for modifying Platform data structures that should only be used for
1010   // non-reentrant code
1011   std::mutex m_mutex;
1012   size_t m_max_uid_name_len;
1013   size_t m_max_gid_name_len;
1014   bool m_supports_rsync;
1015   std::string m_rsync_opts;
1016   std::string m_rsync_prefix;
1017   bool m_supports_ssh;
1018   std::string m_ssh_opts;
1019   bool m_ignores_remote_hostname;
1020   std::string m_local_cache_directory;
1021   std::vector<ConstString> m_trap_handlers;
1022   bool m_calculated_trap_handlers;
1023   const std::unique_ptr<ModuleCache> m_module_cache;
1024   LocateModuleCallback m_locate_module_callback;
1025 
1026   /// Ask the Platform subclass to fill in the list of trap handler names
1027   ///
1028   /// For most Unix user process environments, this will be a single function
1029   /// name, _sigtramp.  More specialized environments may have additional
1030   /// handler names.  The unwinder code needs to know when a trap handler is
1031   /// on the stack because the unwind rules for the frame that caused the trap
1032   /// are different.
1033   ///
1034   /// The base class Platform ivar m_trap_handlers should be updated by the
1035   /// Platform subclass when this method is called.  If there are no
1036   /// predefined trap handlers, this method may be a no-op.
1037   virtual void CalculateTrapHandlerSymbolNames() = 0;
1038 
1039   Status GetCachedExecutable(ModuleSpec &module_spec, lldb::ModuleSP &module_sp,
1040                              const FileSpecList *module_search_paths_ptr);
1041 
1042   virtual Status DownloadModuleSlice(const FileSpec &src_file_spec,
1043                                      const uint64_t src_offset,
1044                                      const uint64_t src_size,
1045                                      const FileSpec &dst_file_spec);
1046 
1047   virtual Status DownloadSymbolFile(const lldb::ModuleSP &module_sp,
1048                                     const FileSpec &dst_file_spec);
1049 
1050   virtual const char *GetCacheHostname();
1051 
1052 private:
1053   typedef std::function<Status(const ModuleSpec &)> ModuleResolver;
1054 
1055   Status GetRemoteSharedModule(const ModuleSpec &module_spec, Process *process,
1056                                lldb::ModuleSP &module_sp,
1057                                const ModuleResolver &module_resolver,
1058                                bool *did_create_ptr);
1059 
1060   bool GetCachedSharedModule(const ModuleSpec &module_spec,
1061                              lldb::ModuleSP &module_sp, bool *did_create_ptr);
1062 
1063   FileSpec GetModuleCacheRoot();
1064 };
1065 
1066 class PlatformList {
1067 public:
1068   PlatformList() = default;
1069 
1070   ~PlatformList() = default;
1071 
1072   void Append(const lldb::PlatformSP &platform_sp, bool set_selected) {
1073     std::lock_guard<std::recursive_mutex> guard(m_mutex);
1074     m_platforms.push_back(platform_sp);
1075     if (set_selected)
1076       m_selected_platform_sp = m_platforms.back();
1077   }
1078 
1079   size_t GetSize() {
1080     std::lock_guard<std::recursive_mutex> guard(m_mutex);
1081     return m_platforms.size();
1082   }
1083 
1084   lldb::PlatformSP GetAtIndex(uint32_t idx) {
1085     lldb::PlatformSP platform_sp;
1086     {
1087       std::lock_guard<std::recursive_mutex> guard(m_mutex);
1088       if (idx < m_platforms.size())
1089         platform_sp = m_platforms[idx];
1090     }
1091     return platform_sp;
1092   }
1093 
1094   /// Select the active platform.
1095   ///
1096   /// In order to debug remotely, other platform's can be remotely connected
1097   /// to and set as the selected platform for any subsequent debugging. This
1098   /// allows connection to remote targets and allows the ability to discover
1099   /// process info, launch and attach to remote processes.
1100   lldb::PlatformSP GetSelectedPlatform() {
1101     std::lock_guard<std::recursive_mutex> guard(m_mutex);
1102     if (!m_selected_platform_sp && !m_platforms.empty())
1103       m_selected_platform_sp = m_platforms.front();
1104 
1105     return m_selected_platform_sp;
1106   }
1107 
1108   void SetSelectedPlatform(const lldb::PlatformSP &platform_sp) {
1109     if (platform_sp) {
1110       std::lock_guard<std::recursive_mutex> guard(m_mutex);
1111       const size_t num_platforms = m_platforms.size();
1112       for (size_t idx = 0; idx < num_platforms; ++idx) {
1113         if (m_platforms[idx].get() == platform_sp.get()) {
1114           m_selected_platform_sp = m_platforms[idx];
1115           return;
1116         }
1117       }
1118       m_platforms.push_back(platform_sp);
1119       m_selected_platform_sp = m_platforms.back();
1120     }
1121   }
1122 
1123   lldb::PlatformSP GetOrCreate(llvm::StringRef name);
1124   lldb::PlatformSP GetOrCreate(const ArchSpec &arch,
1125                                const ArchSpec &process_host_arch,
1126                                ArchSpec *platform_arch_ptr, Status &error);
1127   lldb::PlatformSP GetOrCreate(const ArchSpec &arch,
1128                                const ArchSpec &process_host_arch,
1129                                ArchSpec *platform_arch_ptr);
1130 
1131   /// Get the platform for the given list of architectures.
1132   ///
1133   /// The algorithm works a follows:
1134   ///
1135   /// 1. Returns the selected platform if it matches any of the architectures.
1136   /// 2. Returns the host platform if it matches any of the architectures.
1137   /// 3. Returns the platform that matches all the architectures.
1138   ///
1139   /// If none of the above apply, this function returns a default platform. The
1140   /// candidates output argument differentiates between either no platforms
1141   /// supporting the given architecture or multiple platforms supporting the
1142   /// given architecture.
1143   lldb::PlatformSP GetOrCreate(llvm::ArrayRef<ArchSpec> archs,
1144                                const ArchSpec &process_host_arch,
1145                                std::vector<lldb::PlatformSP> &candidates);
1146 
1147   lldb::PlatformSP Create(llvm::StringRef name);
1148 
1149   /// Detect a binary in memory that will determine which Platform and
1150   /// DynamicLoader should be used in this target/process, and update
1151   /// the Platform/DynamicLoader.
1152   /// The binary will be loaded into the Target, or will be registered with
1153   /// the DynamicLoader so that it will be loaded at a later stage.  Returns
1154   /// true to indicate that this is a platform binary and has been
1155   /// loaded/registered, no further action should be taken by the caller.
1156   ///
1157   /// \param[in] process
1158   ///     Process read memory from, a Process must be provided.
1159   ///
1160   /// \param[in] addr
1161   ///     Address of a binary in memory.
1162   ///
1163   /// \param[in] notify
1164   ///     Whether ModulesDidLoad should be called, if a binary is loaded.
1165   ///     Caller may prefer to call ModulesDidLoad for multiple binaries
1166   ///     that were loaded at the same time.
1167   ///
1168   /// \return
1169   ///     Returns true if the binary was loaded in the target (or will be
1170   ///     via a DynamicLoader).  Returns false if the binary was not
1171   ///     loaded/registered, and the caller must load it into the target.
1172   bool LoadPlatformBinaryAndSetup(Process *process, lldb::addr_t addr,
1173                                   bool notify);
1174 
1175 protected:
1176   typedef std::vector<lldb::PlatformSP> collection;
1177   mutable std::recursive_mutex m_mutex;
1178   collection m_platforms;
1179   lldb::PlatformSP m_selected_platform_sp;
1180 
1181 private:
1182   PlatformList(const PlatformList &) = delete;
1183   const PlatformList &operator=(const PlatformList &) = delete;
1184 };
1185 
1186 class OptionGroupPlatformRSync : public lldb_private::OptionGroup {
1187 public:
1188   OptionGroupPlatformRSync() = default;
1189 
1190   ~OptionGroupPlatformRSync() override = default;
1191 
1192   lldb_private::Status
1193   SetOptionValue(uint32_t option_idx, llvm::StringRef option_value,
1194                  ExecutionContext *execution_context) override;
1195 
1196   void OptionParsingStarting(ExecutionContext *execution_context) override;
1197 
1198   llvm::ArrayRef<OptionDefinition> GetDefinitions() override;
1199 
1200   // Instance variables to hold the values for command options.
1201 
1202   bool m_rsync;
1203   std::string m_rsync_opts;
1204   std::string m_rsync_prefix;
1205   bool m_ignores_remote_hostname;
1206 
1207 private:
1208   OptionGroupPlatformRSync(const OptionGroupPlatformRSync &) = delete;
1209   const OptionGroupPlatformRSync &
1210   operator=(const OptionGroupPlatformRSync &) = delete;
1211 };
1212 
1213 class OptionGroupPlatformSSH : public lldb_private::OptionGroup {
1214 public:
1215   OptionGroupPlatformSSH() = default;
1216 
1217   ~OptionGroupPlatformSSH() override = default;
1218 
1219   lldb_private::Status
1220   SetOptionValue(uint32_t option_idx, llvm::StringRef option_value,
1221                  ExecutionContext *execution_context) override;
1222 
1223   void OptionParsingStarting(ExecutionContext *execution_context) override;
1224 
1225   llvm::ArrayRef<OptionDefinition> GetDefinitions() override;
1226 
1227   // Instance variables to hold the values for command options.
1228 
1229   bool m_ssh;
1230   std::string m_ssh_opts;
1231 
1232 private:
1233   OptionGroupPlatformSSH(const OptionGroupPlatformSSH &) = delete;
1234   const OptionGroupPlatformSSH &
1235   operator=(const OptionGroupPlatformSSH &) = delete;
1236 };
1237 
1238 class OptionGroupPlatformCaching : public lldb_private::OptionGroup {
1239 public:
1240   OptionGroupPlatformCaching() = default;
1241 
1242   ~OptionGroupPlatformCaching() override = default;
1243 
1244   lldb_private::Status
1245   SetOptionValue(uint32_t option_idx, llvm::StringRef option_value,
1246                  ExecutionContext *execution_context) override;
1247 
1248   void OptionParsingStarting(ExecutionContext *execution_context) override;
1249 
1250   llvm::ArrayRef<OptionDefinition> GetDefinitions() override;
1251 
1252   // Instance variables to hold the values for command options.
1253 
1254   std::string m_cache_dir;
1255 
1256 private:
1257   OptionGroupPlatformCaching(const OptionGroupPlatformCaching &) = delete;
1258   const OptionGroupPlatformCaching &
1259   operator=(const OptionGroupPlatformCaching &) = delete;
1260 };
1261 
1262 } // namespace lldb_private
1263 
1264 #endif // LLDB_TARGET_PLATFORM_H
1265