Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:42:42

0001 //===-- SBPlatform.h --------------------------------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef LLDB_API_SBPLATFORM_H
0010 #define LLDB_API_SBPLATFORM_H
0011 
0012 #include "lldb/API/SBDefines.h"
0013 #include "lldb/API/SBProcess.h"
0014 #include "lldb/API/SBProcessInfoList.h"
0015 
0016 #include <functional>
0017 
0018 struct PlatformConnectOptions;
0019 struct PlatformShellCommand;
0020 class ProcessInstanceInfoMatch;
0021 
0022 namespace lldb {
0023 
0024 class SBAttachInfo;
0025 class SBLaunchInfo;
0026 
0027 class LLDB_API SBPlatformConnectOptions {
0028 public:
0029   SBPlatformConnectOptions(const char *url);
0030 
0031   SBPlatformConnectOptions(const SBPlatformConnectOptions &rhs);
0032 
0033   ~SBPlatformConnectOptions();
0034 
0035   SBPlatformConnectOptions &operator=(const SBPlatformConnectOptions &rhs);
0036 
0037   const char *GetURL();
0038 
0039   void SetURL(const char *url);
0040 
0041   bool GetRsyncEnabled();
0042 
0043   void EnableRsync(const char *options, const char *remote_path_prefix,
0044                    bool omit_remote_hostname);
0045 
0046   void DisableRsync();
0047 
0048   const char *GetLocalCacheDirectory();
0049 
0050   void SetLocalCacheDirectory(const char *path);
0051 
0052 protected:
0053   PlatformConnectOptions *m_opaque_ptr;
0054 };
0055 
0056 class LLDB_API SBPlatformShellCommand {
0057 public:
0058   SBPlatformShellCommand(const char *shell, const char *shell_command);
0059   SBPlatformShellCommand(const char *shell_command);
0060 
0061   SBPlatformShellCommand(const SBPlatformShellCommand &rhs);
0062 
0063   SBPlatformShellCommand &operator=(const SBPlatformShellCommand &rhs);
0064 
0065   ~SBPlatformShellCommand();
0066 
0067   void Clear();
0068 
0069   const char *GetShell();
0070 
0071   void SetShell(const char *shell);
0072 
0073   const char *GetCommand();
0074 
0075   void SetCommand(const char *shell_command);
0076 
0077   const char *GetWorkingDirectory();
0078 
0079   void SetWorkingDirectory(const char *path);
0080 
0081   uint32_t GetTimeoutSeconds();
0082 
0083   void SetTimeoutSeconds(uint32_t sec);
0084 
0085   int GetSignal();
0086 
0087   int GetStatus();
0088 
0089   const char *GetOutput();
0090 
0091 protected:
0092   friend class SBPlatform;
0093 
0094   PlatformShellCommand *m_opaque_ptr;
0095 };
0096 
0097 class LLDB_API SBPlatform {
0098 public:
0099   SBPlatform();
0100 
0101   SBPlatform(const char *platform_name);
0102 
0103   SBPlatform(const SBPlatform &rhs);
0104 
0105   SBPlatform &operator=(const SBPlatform &rhs);
0106 
0107   ~SBPlatform();
0108 
0109   static SBPlatform GetHostPlatform();
0110 
0111   explicit operator bool() const;
0112 
0113   bool IsValid() const;
0114 
0115   void Clear();
0116 
0117   const char *GetWorkingDirectory();
0118 
0119   bool SetWorkingDirectory(const char *path);
0120 
0121   const char *GetName();
0122 
0123   SBError ConnectRemote(SBPlatformConnectOptions &connect_options);
0124 
0125   void DisconnectRemote();
0126 
0127   bool IsConnected();
0128 
0129   // The following functions will work if the platform is connected
0130   const char *GetTriple();
0131 
0132   const char *GetHostname();
0133 
0134   const char *GetOSBuild();
0135 
0136   const char *GetOSDescription();
0137 
0138   uint32_t GetOSMajorVersion();
0139 
0140   uint32_t GetOSMinorVersion();
0141 
0142   uint32_t GetOSUpdateVersion();
0143 
0144   void SetSDKRoot(const char *sysroot);
0145 
0146   SBError Put(SBFileSpec &src, SBFileSpec &dst);
0147 
0148   SBError Get(SBFileSpec &src, SBFileSpec &dst);
0149 
0150   SBError Install(SBFileSpec &src, SBFileSpec &dst);
0151 
0152   SBError Run(SBPlatformShellCommand &shell_command);
0153 
0154   SBError Launch(SBLaunchInfo &launch_info);
0155 
0156   SBProcess Attach(SBAttachInfo &attach_info, const SBDebugger &debugger,
0157                    SBTarget &target, SBError &error);
0158 
0159   SBProcessInfoList GetAllProcesses(SBError &error);
0160 
0161   SBError Kill(const lldb::pid_t pid);
0162 
0163   SBError
0164   MakeDirectory(const char *path,
0165                 uint32_t file_permissions = eFilePermissionsDirectoryDefault);
0166 
0167   uint32_t GetFilePermissions(const char *path);
0168 
0169   SBError SetFilePermissions(const char *path, uint32_t file_permissions);
0170 
0171   SBUnixSignals GetUnixSignals() const;
0172 
0173   /// Return the environment variables of the remote platform connection
0174   /// process.
0175   ///
0176   /// \return
0177   ///     An lldb::SBEnvironment object which is a copy of the platform's
0178   ///     environment.
0179   SBEnvironment GetEnvironment();
0180 
0181   /// Set a callback as an implementation for locating module in order to
0182   /// implement own module cache system. For example, to leverage distributed
0183   /// build system, to bypass pulling files from remote platform, or to search
0184   /// symbol files from symbol servers. The target will call this callback to
0185   /// get a module file and a symbol file, and it will fallback to the LLDB
0186   /// implementation when this callback failed or returned non-existent file.
0187   /// This callback can set either module_file_spec or symbol_file_spec, or both
0188   /// module_file_spec and symbol_file_spec. The callback will be cleared if
0189   /// nullptr or None is set.
0190   SBError SetLocateModuleCallback(lldb::SBPlatformLocateModuleCallback callback,
0191                                   void *callback_baton);
0192 
0193 protected:
0194   friend class SBDebugger;
0195   friend class SBTarget;
0196 
0197   lldb::PlatformSP GetSP() const;
0198 
0199   void SetSP(const lldb::PlatformSP &platform_sp);
0200 
0201   SBError ExecuteConnected(
0202       const std::function<lldb_private::Status(const lldb::PlatformSP &)>
0203           &func);
0204 
0205   lldb::PlatformSP m_opaque_sp;
0206 };
0207 
0208 } // namespace lldb
0209 
0210 #endif // LLDB_API_SBPLATFORM_H