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