SBPlatform.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. //===-- SBPlatform.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. #ifndef LLDB_API_SBPLATFORM_H
  9. #define LLDB_API_SBPLATFORM_H
  10. #include "lldb/API/SBDefines.h"
  11. #include <functional>
  12. struct PlatformConnectOptions;
  13. struct PlatformShellCommand;
  14. namespace lldb {
  15. class SBLaunchInfo;
  16. class LLDB_API SBPlatformConnectOptions {
  17. public:
  18. SBPlatformConnectOptions(const char *url);
  19. SBPlatformConnectOptions(const SBPlatformConnectOptions &rhs);
  20. ~SBPlatformConnectOptions();
  21. SBPlatformConnectOptions &operator=(const SBPlatformConnectOptions &rhs);
  22. const char *GetURL();
  23. void SetURL(const char *url);
  24. bool GetRsyncEnabled();
  25. void EnableRsync(const char *options, const char *remote_path_prefix,
  26. bool omit_remote_hostname);
  27. void DisableRsync();
  28. const char *GetLocalCacheDirectory();
  29. void SetLocalCacheDirectory(const char *path);
  30. protected:
  31. PlatformConnectOptions *m_opaque_ptr;
  32. };
  33. class LLDB_API SBPlatformShellCommand {
  34. public:
  35. SBPlatformShellCommand(const char *shell, const char *shell_command);
  36. SBPlatformShellCommand(const char *shell_command);
  37. SBPlatformShellCommand(const SBPlatformShellCommand &rhs);
  38. SBPlatformShellCommand &operator=(const SBPlatformShellCommand &rhs);
  39. ~SBPlatformShellCommand();
  40. void Clear();
  41. const char *GetShell();
  42. void SetShell(const char *shell);
  43. const char *GetCommand();
  44. void SetCommand(const char *shell_command);
  45. const char *GetWorkingDirectory();
  46. void SetWorkingDirectory(const char *path);
  47. uint32_t GetTimeoutSeconds();
  48. void SetTimeoutSeconds(uint32_t sec);
  49. int GetSignal();
  50. int GetStatus();
  51. const char *GetOutput();
  52. protected:
  53. friend class SBPlatform;
  54. PlatformShellCommand *m_opaque_ptr;
  55. };
  56. class LLDB_API SBPlatform {
  57. public:
  58. SBPlatform();
  59. SBPlatform(const char *platform_name);
  60. SBPlatform(const SBPlatform &rhs);
  61. SBPlatform &operator=(const SBPlatform &rhs);
  62. ~SBPlatform();
  63. static SBPlatform GetHostPlatform();
  64. explicit operator bool() const;
  65. bool IsValid() const;
  66. void Clear();
  67. const char *GetWorkingDirectory();
  68. bool SetWorkingDirectory(const char *path);
  69. const char *GetName();
  70. SBError ConnectRemote(SBPlatformConnectOptions &connect_options);
  71. void DisconnectRemote();
  72. bool IsConnected();
  73. // The following functions will work if the platform is connected
  74. const char *GetTriple();
  75. const char *GetHostname();
  76. const char *GetOSBuild();
  77. const char *GetOSDescription();
  78. uint32_t GetOSMajorVersion();
  79. uint32_t GetOSMinorVersion();
  80. uint32_t GetOSUpdateVersion();
  81. SBError Put(SBFileSpec &src, SBFileSpec &dst);
  82. SBError Get(SBFileSpec &src, SBFileSpec &dst);
  83. SBError Install(SBFileSpec &src, SBFileSpec &dst);
  84. SBError Run(SBPlatformShellCommand &shell_command);
  85. SBError Launch(SBLaunchInfo &launch_info);
  86. SBError Kill(const lldb::pid_t pid);
  87. SBError
  88. MakeDirectory(const char *path,
  89. uint32_t file_permissions = eFilePermissionsDirectoryDefault);
  90. uint32_t GetFilePermissions(const char *path);
  91. SBError SetFilePermissions(const char *path, uint32_t file_permissions);
  92. SBUnixSignals GetUnixSignals() const;
  93. /// Return the environment variables of the remote platform connection
  94. /// process.
  95. ///
  96. /// \return
  97. /// An lldb::SBEnvironment object which is a copy of the platform's
  98. /// environment.
  99. SBEnvironment GetEnvironment();
  100. protected:
  101. friend class SBDebugger;
  102. friend class SBTarget;
  103. lldb::PlatformSP GetSP() const;
  104. void SetSP(const lldb::PlatformSP &platform_sp);
  105. SBError ExecuteConnected(
  106. const std::function<lldb_private::Status(const lldb::PlatformSP &)>
  107. &func);
  108. lldb::PlatformSP m_opaque_sp;
  109. };
  110. } // namespace lldb
  111. #endif // LLDB_API_SBPLATFORM_H