summaryrefslogtreecommitdiffstats
path: root/contrib/llvm/tools/lldb/source/API/SBPlatform.cpp
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2017-04-02 17:24:58 +0000
committerdim <dim@FreeBSD.org>2017-04-02 17:24:58 +0000
commit60b571e49a90d38697b3aca23020d9da42fc7d7f (patch)
tree99351324c24d6cb146b6285b6caffa4d26fce188 /contrib/llvm/tools/lldb/source/API/SBPlatform.cpp
parentbea1b22c7a9bce1dfdd73e6e5b65bc4752215180 (diff)
downloadFreeBSD-src-60b571e49a90d38697b3aca23020d9da42fc7d7f.zip
FreeBSD-src-60b571e49a90d38697b3aca23020d9da42fc7d7f.tar.gz
Update clang, llvm, lld, lldb, compiler-rt and libc++ to 4.0.0 release:
MFC r309142 (by emaste): Add WITH_LLD_AS_LD build knob If set it installs LLD as /usr/bin/ld. LLD (as of version 3.9) is not capable of linking the world and kernel, but can self-host and link many substantial applications. GNU ld continues to be used for the world and kernel build, regardless of how this knob is set. It is on by default for arm64, and off for all other CPU architectures. Sponsored by: The FreeBSD Foundation MFC r310840: Reapply 310775, now it also builds correctly if lldb is disabled: Move llvm-objdump from CLANG_EXTRAS to installed by default We currently install three tools from binutils 2.17.50: as, ld, and objdump. Work is underway to migrate to a permissively-licensed tool-chain, with one goal being the retirement of binutils 2.17.50. LLVM's llvm-objdump is intended to be compatible with GNU objdump although it is currently missing some options and may have formatting differences. Enable it by default for testing and further investigation. It may later be changed to install as /usr/bin/objdump, it becomes a fully viable replacement. Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D8879 MFC r312855 (by emaste): Rename LLD_AS_LD to LLD_IS_LD, for consistency with CLANG_IS_CC Reported by: Dan McGregor <dan.mcgregor usask.ca> MFC r313559 | glebius | 2017-02-10 18:34:48 +0100 (Fri, 10 Feb 2017) | 5 lines Don't check struct rtentry on FreeBSD, it is an internal kernel structure. On other systems it may be API structure for SIOCADDRT/SIOCDELRT. Reviewed by: emaste, dim MFC r314152 (by jkim): Remove an assembler flag, which is redundant since r309124. The upstream took care of it by introducing a macro NO_EXEC_STACK_DIRECTIVE. http://llvm.org/viewvc/llvm-project?rev=273500&view=rev Reviewed by: dim MFC r314564: Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to 4.0.0 (branches/release_40 296509). The release will follow soon. Please note that from 3.5.0 onwards, clang, llvm and lldb require C++11 support to build; see UPDATING for more information. Also note that as of 4.0.0, lld should be able to link the base system on amd64 and aarch64. See the WITH_LLD_IS_LLD setting in src.conf(5). Though please be aware that this is work in progress. Release notes for llvm, clang and lld will be available here: <http://releases.llvm.org/4.0.0/docs/ReleaseNotes.html> <http://releases.llvm.org/4.0.0/tools/clang/docs/ReleaseNotes.html> <http://releases.llvm.org/4.0.0/tools/lld/docs/ReleaseNotes.html> Thanks to Ed Maste, Jan Beich, Antoine Brodin and Eric Fiselier for their help. Relnotes: yes Exp-run: antoine PR: 215969, 216008 MFC r314708: For now, revert r287232 from upstream llvm trunk (by Daniil Fukalov): [SCEV] limit recursion depth of CompareSCEVComplexity Summary: CompareSCEVComplexity goes too deep (50+ on a quite a big unrolled loop) and runs almost infinite time. Added cache of "equal" SCEV pairs to earlier cutoff of further estimation. Recursion depth limit was also introduced as a parameter. Reviewers: sanjoy Subscribers: mzolotukhin, tstellarAMD, llvm-commits Differential Revision: https://reviews.llvm.org/D26389 This commit is the cause of excessive compile times on skein_block.c (and possibly other files) during kernel builds on amd64. We never saw the problematic behavior described in this upstream commit, so for now it is better to revert it. An upstream bug has been filed here: https://bugs.llvm.org/show_bug.cgi?id=32142 Reported by: mjg MFC r314795: Reapply r287232 from upstream llvm trunk (by Daniil Fukalov): [SCEV] limit recursion depth of CompareSCEVComplexity Summary: CompareSCEVComplexity goes too deep (50+ on a quite a big unrolled loop) and runs almost infinite time. Added cache of "equal" SCEV pairs to earlier cutoff of further estimation. Recursion depth limit was also introduced as a parameter. Reviewers: sanjoy Subscribers: mzolotukhin, tstellarAMD, llvm-commits Differential Revision: https://reviews.llvm.org/D26389 Pull in r296992 from upstream llvm trunk (by Sanjoy Das): [SCEV] Decrease the recursion threshold for CompareValueComplexity Fixes PR32142. r287232 accidentally increased the recursion threshold for CompareValueComplexity from 2 to 32. This change reverses that change by introducing a separate flag for CompareValueComplexity's threshold. The latter revision fixes the excessive compile times for skein_block.c. MFC r314907 | mmel | 2017-03-08 12:40:27 +0100 (Wed, 08 Mar 2017) | 7 lines Unbreak ARMv6 world. The new compiler_rt library imported with clang 4.0.0 have several fatal issues (non-functional __udivsi3 for example) with ARM specific instrict functions. As temporary workaround, until upstream solve these problems, disable all thumb[1][2] related feature. MFC r315016: Update clang, llvm, lld, lldb, compiler-rt and libc++ to 4.0.0 release. We were already very close to the last release candidate, so this is a pretty minor update. Relnotes: yes MFC r316005: Revert r314907, and pull in r298713 from upstream compiler-rt trunk (by Weiming Zhao): builtins: Select correct code fragments when compiling for Thumb1/Thum2/ARM ISA. Summary: Value of __ARM_ARCH_ISA_THUMB isn't based on the actual compilation mode (-mthumb, -marm), it reflect's capability of given CPU. Due to this: - use __tbumb__ and __thumb2__ insteand of __ARM_ARCH_ISA_THUMB - use '.thumb' directive consistently in all affected files - decorate all thumb functions using DEFINE_COMPILERRT_THUMB_FUNCTION() --------- Note: This patch doesn't fix broken Thumb1 variant of __udivsi3 ! Reviewers: weimingz, rengolin, compnerd Subscribers: aemerson, dim Differential Revision: https://reviews.llvm.org/D30938 Discussed with: mmel
Diffstat (limited to 'contrib/llvm/tools/lldb/source/API/SBPlatform.cpp')
-rw-r--r--contrib/llvm/tools/lldb/source/API/SBPlatform.cpp887
1 files changed, 360 insertions, 527 deletions
diff --git a/contrib/llvm/tools/lldb/source/API/SBPlatform.cpp b/contrib/llvm/tools/lldb/source/API/SBPlatform.cpp
index b8dc01b..6085cef 100644
--- a/contrib/llvm/tools/lldb/source/API/SBPlatform.cpp
+++ b/contrib/llvm/tools/lldb/source/API/SBPlatform.cpp
@@ -16,8 +16,8 @@
#include "lldb/Core/Error.h"
#include "lldb/Host/File.h"
#include "lldb/Interpreter/Args.h"
-#include "lldb/Target/Target.h"
#include "lldb/Target/Platform.h"
+#include "lldb/Target/Target.h"
#include <functional>
@@ -28,622 +28,455 @@ using namespace lldb_private;
// PlatformConnectOptions
//----------------------------------------------------------------------
struct PlatformConnectOptions {
- PlatformConnectOptions(const char *url = NULL) :
- m_url(),
- m_rsync_options(),
- m_rsync_remote_path_prefix(),
- m_rsync_enabled(false),
- m_rsync_omit_hostname_from_remote_path(false),
- m_local_cache_directory ()
- {
- if (url && url[0])
- m_url = url;
- }
-
- ~PlatformConnectOptions()
- {
- }
+ PlatformConnectOptions(const char *url = NULL)
+ : m_url(), m_rsync_options(), m_rsync_remote_path_prefix(),
+ m_rsync_enabled(false), m_rsync_omit_hostname_from_remote_path(false),
+ m_local_cache_directory() {
+ if (url && url[0])
+ m_url = url;
+ }
- std::string m_url;
- std::string m_rsync_options;
- std::string m_rsync_remote_path_prefix;
- bool m_rsync_enabled;
- bool m_rsync_omit_hostname_from_remote_path;
- ConstString m_local_cache_directory;
+ ~PlatformConnectOptions() {}
+
+ std::string m_url;
+ std::string m_rsync_options;
+ std::string m_rsync_remote_path_prefix;
+ bool m_rsync_enabled;
+ bool m_rsync_omit_hostname_from_remote_path;
+ ConstString m_local_cache_directory;
};
//----------------------------------------------------------------------
// PlatformShellCommand
//----------------------------------------------------------------------
struct PlatformShellCommand {
- PlatformShellCommand(const char *shell_command = NULL) :
- m_command(),
- m_working_dir(),
- m_status(0),
- m_signo(0),
- m_timeout_sec(UINT32_MAX)
- {
- if (shell_command && shell_command[0])
- m_command = shell_command;
- }
-
- ~PlatformShellCommand()
- {
- }
-
- std::string m_command;
- std::string m_working_dir;
- std::string m_output;
- int m_status;
- int m_signo;
- uint32_t m_timeout_sec;
+ PlatformShellCommand(const char *shell_command = NULL)
+ : m_command(), m_working_dir(), m_status(0), m_signo(0),
+ m_timeout_sec(UINT32_MAX) {
+ if (shell_command && shell_command[0])
+ m_command = shell_command;
+ }
+
+ ~PlatformShellCommand() {}
+
+ std::string m_command;
+ std::string m_working_dir;
+ std::string m_output;
+ int m_status;
+ int m_signo;
+ uint32_t m_timeout_sec;
};
//----------------------------------------------------------------------
// SBPlatformConnectOptions
//----------------------------------------------------------------------
-SBPlatformConnectOptions::SBPlatformConnectOptions (const char *url) :
- m_opaque_ptr(new PlatformConnectOptions(url))
-{
-
+SBPlatformConnectOptions::SBPlatformConnectOptions(const char *url)
+ : m_opaque_ptr(new PlatformConnectOptions(url)) {}
+
+SBPlatformConnectOptions::SBPlatformConnectOptions(
+ const SBPlatformConnectOptions &rhs)
+ : m_opaque_ptr(new PlatformConnectOptions()) {
+ *m_opaque_ptr = *rhs.m_opaque_ptr;
}
-SBPlatformConnectOptions::SBPlatformConnectOptions(const SBPlatformConnectOptions &rhs) :
- m_opaque_ptr(new PlatformConnectOptions())
-{
- *m_opaque_ptr = *rhs.m_opaque_ptr;
+SBPlatformConnectOptions::~SBPlatformConnectOptions() { delete m_opaque_ptr; }
+
+void SBPlatformConnectOptions::operator=(const SBPlatformConnectOptions &rhs) {
+ *m_opaque_ptr = *rhs.m_opaque_ptr;
}
-
-SBPlatformConnectOptions::~SBPlatformConnectOptions ()
-{
- delete m_opaque_ptr;
+
+const char *SBPlatformConnectOptions::GetURL() {
+ if (m_opaque_ptr->m_url.empty())
+ return NULL;
+ return m_opaque_ptr->m_url.c_str();
}
-void
-SBPlatformConnectOptions::operator=(const SBPlatformConnectOptions &rhs)
-{
- *m_opaque_ptr = *rhs.m_opaque_ptr;
+void SBPlatformConnectOptions::SetURL(const char *url) {
+ if (url && url[0])
+ m_opaque_ptr->m_url = url;
+ else
+ m_opaque_ptr->m_url.clear();
}
-const char *
-SBPlatformConnectOptions::GetURL()
-{
- if (m_opaque_ptr->m_url.empty())
- return NULL;
- return m_opaque_ptr->m_url.c_str();
+bool SBPlatformConnectOptions::GetRsyncEnabled() {
+ return m_opaque_ptr->m_rsync_enabled;
}
-
-void
-SBPlatformConnectOptions::SetURL(const char *url)
-{
- if (url && url[0])
- m_opaque_ptr->m_url = url;
- else
- m_opaque_ptr->m_url.clear();
-}
-
-bool
-SBPlatformConnectOptions::GetRsyncEnabled()
-{
- return m_opaque_ptr->m_rsync_enabled;
-}
-
-void
-SBPlatformConnectOptions::EnableRsync (const char *options,
- const char *remote_path_prefix,
- bool omit_hostname_from_remote_path)
-{
- m_opaque_ptr->m_rsync_enabled = true;
- m_opaque_ptr->m_rsync_omit_hostname_from_remote_path = omit_hostname_from_remote_path;
- if (remote_path_prefix && remote_path_prefix[0])
- m_opaque_ptr->m_rsync_remote_path_prefix = remote_path_prefix;
- else
- m_opaque_ptr->m_rsync_remote_path_prefix.clear();
- if (options && options[0])
- m_opaque_ptr->m_rsync_options = options;
- else
- m_opaque_ptr->m_rsync_options.clear();
+void SBPlatformConnectOptions::EnableRsync(
+ const char *options, const char *remote_path_prefix,
+ bool omit_hostname_from_remote_path) {
+ m_opaque_ptr->m_rsync_enabled = true;
+ m_opaque_ptr->m_rsync_omit_hostname_from_remote_path =
+ omit_hostname_from_remote_path;
+ if (remote_path_prefix && remote_path_prefix[0])
+ m_opaque_ptr->m_rsync_remote_path_prefix = remote_path_prefix;
+ else
+ m_opaque_ptr->m_rsync_remote_path_prefix.clear();
+ if (options && options[0])
+ m_opaque_ptr->m_rsync_options = options;
+ else
+ m_opaque_ptr->m_rsync_options.clear();
}
-void
-SBPlatformConnectOptions::DisableRsync ()
-{
- m_opaque_ptr->m_rsync_enabled = false;
+void SBPlatformConnectOptions::DisableRsync() {
+ m_opaque_ptr->m_rsync_enabled = false;
}
-
-const char *
-SBPlatformConnectOptions::GetLocalCacheDirectory()
-{
- return m_opaque_ptr->m_local_cache_directory.GetCString();
+
+const char *SBPlatformConnectOptions::GetLocalCacheDirectory() {
+ return m_opaque_ptr->m_local_cache_directory.GetCString();
}
-
-void
-SBPlatformConnectOptions::SetLocalCacheDirectory(const char *path)
-{
- if (path && path[0])
- m_opaque_ptr->m_local_cache_directory.SetCString(path);
- else
- m_opaque_ptr->m_local_cache_directory = ConstString();
+
+void SBPlatformConnectOptions::SetLocalCacheDirectory(const char *path) {
+ if (path && path[0])
+ m_opaque_ptr->m_local_cache_directory.SetCString(path);
+ else
+ m_opaque_ptr->m_local_cache_directory = ConstString();
}
//----------------------------------------------------------------------
// SBPlatformShellCommand
//----------------------------------------------------------------------
-SBPlatformShellCommand::SBPlatformShellCommand (const char *shell_command) :
- m_opaque_ptr(new PlatformShellCommand(shell_command))
-{
-}
+SBPlatformShellCommand::SBPlatformShellCommand(const char *shell_command)
+ : m_opaque_ptr(new PlatformShellCommand(shell_command)) {}
-SBPlatformShellCommand::SBPlatformShellCommand (const SBPlatformShellCommand &rhs) :
- m_opaque_ptr(new PlatformShellCommand())
-{
- *m_opaque_ptr = *rhs.m_opaque_ptr;
+SBPlatformShellCommand::SBPlatformShellCommand(
+ const SBPlatformShellCommand &rhs)
+ : m_opaque_ptr(new PlatformShellCommand()) {
+ *m_opaque_ptr = *rhs.m_opaque_ptr;
}
-SBPlatformShellCommand::~SBPlatformShellCommand()
-{
- delete m_opaque_ptr;
-}
+SBPlatformShellCommand::~SBPlatformShellCommand() { delete m_opaque_ptr; }
-void
-SBPlatformShellCommand::Clear()
-{
- m_opaque_ptr->m_output = std::string();
- m_opaque_ptr->m_status = 0;
- m_opaque_ptr->m_signo = 0;
+void SBPlatformShellCommand::Clear() {
+ m_opaque_ptr->m_output = std::string();
+ m_opaque_ptr->m_status = 0;
+ m_opaque_ptr->m_signo = 0;
}
-const char *
-SBPlatformShellCommand::GetCommand()
-{
- if (m_opaque_ptr->m_command.empty())
- return NULL;
- return m_opaque_ptr->m_command.c_str();
+const char *SBPlatformShellCommand::GetCommand() {
+ if (m_opaque_ptr->m_command.empty())
+ return NULL;
+ return m_opaque_ptr->m_command.c_str();
}
-void
-SBPlatformShellCommand::SetCommand(const char *shell_command)
-{
- if (shell_command && shell_command[0])
- m_opaque_ptr->m_command = shell_command;
- else
- m_opaque_ptr->m_command.clear();
+void SBPlatformShellCommand::SetCommand(const char *shell_command) {
+ if (shell_command && shell_command[0])
+ m_opaque_ptr->m_command = shell_command;
+ else
+ m_opaque_ptr->m_command.clear();
}
-const char *
-SBPlatformShellCommand::GetWorkingDirectory ()
-{
- if (m_opaque_ptr->m_working_dir.empty())
- return NULL;
- return m_opaque_ptr->m_working_dir.c_str();
+const char *SBPlatformShellCommand::GetWorkingDirectory() {
+ if (m_opaque_ptr->m_working_dir.empty())
+ return NULL;
+ return m_opaque_ptr->m_working_dir.c_str();
}
-void
-SBPlatformShellCommand::SetWorkingDirectory (const char *path)
-{
- if (path && path[0])
- m_opaque_ptr->m_working_dir = path;
- else
- m_opaque_ptr->m_working_dir.clear();
+void SBPlatformShellCommand::SetWorkingDirectory(const char *path) {
+ if (path && path[0])
+ m_opaque_ptr->m_working_dir = path;
+ else
+ m_opaque_ptr->m_working_dir.clear();
}
-uint32_t
-SBPlatformShellCommand::GetTimeoutSeconds ()
-{
- return m_opaque_ptr->m_timeout_sec;
+uint32_t SBPlatformShellCommand::GetTimeoutSeconds() {
+ return m_opaque_ptr->m_timeout_sec;
}
-void
-SBPlatformShellCommand::SetTimeoutSeconds (uint32_t sec)
-{
- m_opaque_ptr->m_timeout_sec = sec;
+void SBPlatformShellCommand::SetTimeoutSeconds(uint32_t sec) {
+ m_opaque_ptr->m_timeout_sec = sec;
}
-int
-SBPlatformShellCommand::GetSignal ()
-{
- return m_opaque_ptr->m_signo;
-}
+int SBPlatformShellCommand::GetSignal() { return m_opaque_ptr->m_signo; }
-int
-SBPlatformShellCommand::GetStatus ()
-{
- return m_opaque_ptr->m_status;
-}
+int SBPlatformShellCommand::GetStatus() { return m_opaque_ptr->m_status; }
-const char *
-SBPlatformShellCommand::GetOutput ()
-{
- if (m_opaque_ptr->m_output.empty())
- return NULL;
- return m_opaque_ptr->m_output.c_str();
+const char *SBPlatformShellCommand::GetOutput() {
+ if (m_opaque_ptr->m_output.empty())
+ return NULL;
+ return m_opaque_ptr->m_output.c_str();
}
//----------------------------------------------------------------------
// SBPlatform
//----------------------------------------------------------------------
-SBPlatform::SBPlatform () :
- m_opaque_sp ()
-{
-
-}
+SBPlatform::SBPlatform() : m_opaque_sp() {}
-SBPlatform::SBPlatform (const char *platform_name) :
- m_opaque_sp ()
-{
- Error error;
- if (platform_name && platform_name[0])
- m_opaque_sp = Platform::Create (ConstString(platform_name), error);
+SBPlatform::SBPlatform(const char *platform_name) : m_opaque_sp() {
+ Error error;
+ if (platform_name && platform_name[0])
+ m_opaque_sp = Platform::Create(ConstString(platform_name), error);
}
-SBPlatform::~SBPlatform()
-{
-}
+SBPlatform::~SBPlatform() {}
-bool
-SBPlatform::IsValid () const
-{
- return m_opaque_sp.get() != NULL;
+bool SBPlatform::IsValid() const { return m_opaque_sp.get() != NULL; }
+
+void SBPlatform::Clear() { m_opaque_sp.reset(); }
+
+const char *SBPlatform::GetName() {
+ PlatformSP platform_sp(GetSP());
+ if (platform_sp)
+ return platform_sp->GetName().GetCString();
+ return NULL;
}
-void
-SBPlatform::Clear ()
-{
- m_opaque_sp.reset();
+lldb::PlatformSP SBPlatform::GetSP() const { return m_opaque_sp; }
+
+void SBPlatform::SetSP(const lldb::PlatformSP &platform_sp) {
+ m_opaque_sp = platform_sp;
}
-const char *
-SBPlatform::GetName ()
-{
- PlatformSP platform_sp(GetSP());
- if (platform_sp)
- return platform_sp->GetName().GetCString();
- return NULL;
+const char *SBPlatform::GetWorkingDirectory() {
+ PlatformSP platform_sp(GetSP());
+ if (platform_sp)
+ return platform_sp->GetWorkingDirectory().GetCString();
+ return NULL;
}
-lldb::PlatformSP
-SBPlatform::GetSP () const
-{
- return m_opaque_sp;
+bool SBPlatform::SetWorkingDirectory(const char *path) {
+ PlatformSP platform_sp(GetSP());
+ if (platform_sp) {
+ if (path)
+ platform_sp->SetWorkingDirectory(FileSpec{path, false});
+ else
+ platform_sp->SetWorkingDirectory(FileSpec{});
+ return true;
+ }
+ return false;
+}
+
+SBError SBPlatform::ConnectRemote(SBPlatformConnectOptions &connect_options) {
+ SBError sb_error;
+ PlatformSP platform_sp(GetSP());
+ if (platform_sp && connect_options.GetURL()) {
+ Args args;
+ args.AppendArgument(
+ llvm::StringRef::withNullAsEmpty(connect_options.GetURL()));
+ sb_error.ref() = platform_sp->ConnectRemote(args);
+ } else {
+ sb_error.SetErrorString("invalid platform");
+ }
+ return sb_error;
}
-void
-SBPlatform::SetSP (const lldb::PlatformSP& platform_sp)
-{
- m_opaque_sp = platform_sp;
+void SBPlatform::DisconnectRemote() {
+ PlatformSP platform_sp(GetSP());
+ if (platform_sp)
+ platform_sp->DisconnectRemote();
}
-const char *
-SBPlatform::GetWorkingDirectory()
-{
- PlatformSP platform_sp(GetSP());
- if (platform_sp)
- return platform_sp->GetWorkingDirectory().GetCString();
- return NULL;
+bool SBPlatform::IsConnected() {
+ PlatformSP platform_sp(GetSP());
+ if (platform_sp)
+ platform_sp->IsConnected();
+ return false;
}
-bool
-SBPlatform::SetWorkingDirectory(const char *path)
-{
- PlatformSP platform_sp(GetSP());
- if (platform_sp)
- {
- if (path)
- platform_sp->SetWorkingDirectory(FileSpec{path, false});
- else
- platform_sp->SetWorkingDirectory(FileSpec{});
- return true;
- }
- return false;
-}
-
-SBError
-SBPlatform::ConnectRemote (SBPlatformConnectOptions &connect_options)
-{
- SBError sb_error;
- PlatformSP platform_sp(GetSP());
- if (platform_sp && connect_options.GetURL())
- {
- Args args;
- args.AppendArgument(connect_options.GetURL());
- sb_error.ref() = platform_sp->ConnectRemote(args);
+const char *SBPlatform::GetTriple() {
+ PlatformSP platform_sp(GetSP());
+ if (platform_sp) {
+ ArchSpec arch(platform_sp->GetSystemArchitecture());
+ if (arch.IsValid()) {
+ // Const-ify the string so we don't need to worry about the lifetime of
+ // the string
+ return ConstString(arch.GetTriple().getTriple().c_str()).GetCString();
}
- else
- {
- sb_error.SetErrorString("invalid platform");
+ }
+ return NULL;
+}
+
+const char *SBPlatform::GetOSBuild() {
+ PlatformSP platform_sp(GetSP());
+ if (platform_sp) {
+ std::string s;
+ if (platform_sp->GetOSBuildString(s)) {
+ if (!s.empty()) {
+ // Const-ify the string so we don't need to worry about the lifetime of
+ // the string
+ return ConstString(s.c_str()).GetCString();
+ }
}
- return sb_error;
-}
-
-void
-SBPlatform::DisconnectRemote ()
-{
- PlatformSP platform_sp(GetSP());
- if (platform_sp)
- platform_sp->DisconnectRemote();
-}
-
-bool
-SBPlatform::IsConnected()
-{
- PlatformSP platform_sp(GetSP());
- if (platform_sp)
- platform_sp->IsConnected();
- return false;
-}
-
-const char *
-SBPlatform::GetTriple()
-{
- PlatformSP platform_sp(GetSP());
- if (platform_sp)
- {
- ArchSpec arch(platform_sp->GetSystemArchitecture());
- if (arch.IsValid())
- {
- // Const-ify the string so we don't need to worry about the lifetime of the string
- return ConstString(arch.GetTriple().getTriple().c_str()).GetCString();
- }
+ }
+ return NULL;
+}
+
+const char *SBPlatform::GetOSDescription() {
+ PlatformSP platform_sp(GetSP());
+ if (platform_sp) {
+ std::string s;
+ if (platform_sp->GetOSKernelDescription(s)) {
+ if (!s.empty()) {
+ // Const-ify the string so we don't need to worry about the lifetime of
+ // the string
+ return ConstString(s.c_str()).GetCString();
+ }
}
- return NULL;
+ }
+ return NULL;
}
-const char *
-SBPlatform::GetOSBuild()
-{
- PlatformSP platform_sp(GetSP());
- if (platform_sp)
- {
- std::string s;
- if (platform_sp->GetOSBuildString(s))
- {
- if (!s.empty())
- {
- // Const-ify the string so we don't need to worry about the lifetime of the string
- return ConstString(s.c_str()).GetCString();
- }
- }
- }
- return NULL;
+const char *SBPlatform::GetHostname() {
+ PlatformSP platform_sp(GetSP());
+ if (platform_sp)
+ return platform_sp->GetHostname();
+ return NULL;
}
-const char *
-SBPlatform::GetOSDescription()
-{
- PlatformSP platform_sp(GetSP());
- if (platform_sp)
- {
- std::string s;
- if (platform_sp->GetOSKernelDescription(s))
- {
- if (!s.empty())
- {
- // Const-ify the string so we don't need to worry about the lifetime of the string
- return ConstString(s.c_str()).GetCString();
- }
- }
- }
- return NULL;
+uint32_t SBPlatform::GetOSMajorVersion() {
+ uint32_t major, minor, update;
+ PlatformSP platform_sp(GetSP());
+ if (platform_sp && platform_sp->GetOSVersion(major, minor, update))
+ return major;
+ return UINT32_MAX;
}
-const char *
-SBPlatform::GetHostname ()
-{
- PlatformSP platform_sp(GetSP());
- if (platform_sp)
- return platform_sp->GetHostname();
- return NULL;
+uint32_t SBPlatform::GetOSMinorVersion() {
+ uint32_t major, minor, update;
+ PlatformSP platform_sp(GetSP());
+ if (platform_sp && platform_sp->GetOSVersion(major, minor, update))
+ return minor;
+ return UINT32_MAX;
}
-uint32_t
-SBPlatform::GetOSMajorVersion ()
-{
- uint32_t major, minor, update;
- PlatformSP platform_sp(GetSP());
- if (platform_sp && platform_sp->GetOSVersion(major, minor, update))
- return major;
- return UINT32_MAX;
-
-}
-
-uint32_t
-SBPlatform::GetOSMinorVersion ()
-{
- uint32_t major, minor, update;
- PlatformSP platform_sp(GetSP());
- if (platform_sp && platform_sp->GetOSVersion(major, minor, update))
- return minor;
- return UINT32_MAX;
-}
-
-uint32_t
-SBPlatform::GetOSUpdateVersion ()
-{
- uint32_t major, minor, update;
- PlatformSP platform_sp(GetSP());
- if (platform_sp && platform_sp->GetOSVersion(major, minor, update))
- return update;
- return UINT32_MAX;
-}
-
-SBError
-SBPlatform::Get (SBFileSpec &src,
- SBFileSpec &dst)
-{
- SBError sb_error;
- PlatformSP platform_sp(GetSP());
- if (platform_sp)
- {
- sb_error.ref() = platform_sp->GetFile(src.ref(), dst.ref());
- }
- else
- {
- sb_error.SetErrorString("invalid platform");
- }
- return sb_error;
-}
-
-SBError
-SBPlatform::Put (SBFileSpec &src,
- SBFileSpec &dst)
-{
- return ExecuteConnected(
- [&](const lldb::PlatformSP& platform_sp)
- {
- if (src.Exists())
- {
- uint32_t permissions = src.ref().GetPermissions();
- if (permissions == 0)
- {
- if (src.ref().GetFileType() == FileSpec::eFileTypeDirectory)
- permissions = eFilePermissionsDirectoryDefault;
- else
- permissions = eFilePermissionsFileDefault;
- }
-
- return platform_sp->PutFile(src.ref(), dst.ref(), permissions);
- }
-
- Error error;
- error.SetErrorStringWithFormat("'src' argument doesn't exist: '%s'", src.ref().GetPath().c_str());
- return error;
- });
-}
-
-SBError
-SBPlatform::Install (SBFileSpec &src,
- SBFileSpec &dst)
-{
- return ExecuteConnected(
- [&](const lldb::PlatformSP& platform_sp)
- {
- if (src.Exists())
- return platform_sp->Install(src.ref(), dst.ref());
-
- Error error;
- error.SetErrorStringWithFormat("'src' argument doesn't exist: '%s'", src.ref().GetPath().c_str());
- return error;
- });
-}
-
-
-SBError
-SBPlatform::Run (SBPlatformShellCommand &shell_command)
-{
- return ExecuteConnected(
- [&](const lldb::PlatformSP& platform_sp)
- {
- const char *command = shell_command.GetCommand();
- if (!command)
- return Error("invalid shell command (empty)");
-
- const char *working_dir = shell_command.GetWorkingDirectory();
- if (working_dir == NULL)
- {
- working_dir = platform_sp->GetWorkingDirectory().GetCString();
- if (working_dir)
- shell_command.SetWorkingDirectory(working_dir);
- }
- return platform_sp->RunShellCommand(command,
- FileSpec{working_dir, false},
- &shell_command.m_opaque_ptr->m_status,
- &shell_command.m_opaque_ptr->m_signo,
- &shell_command.m_opaque_ptr->m_output,
- shell_command.m_opaque_ptr->m_timeout_sec);
- });
-}
-
-SBError
-SBPlatform::Launch (SBLaunchInfo &launch_info)
-{
- return ExecuteConnected(
- [&](const lldb::PlatformSP& platform_sp)
- {
- return platform_sp->LaunchProcess(launch_info.ref());
- });
-}
-
-SBError
-SBPlatform::Kill (const lldb::pid_t pid)
-{
- return ExecuteConnected(
- [&](const lldb::PlatformSP& platform_sp)
- {
- return platform_sp->KillProcess(pid);
- });
-}
-
-SBError
-SBPlatform::ExecuteConnected (const std::function<Error(const lldb::PlatformSP&)>& func)
-{
- SBError sb_error;
- const auto platform_sp(GetSP());
- if (platform_sp)
- {
- if (platform_sp->IsConnected())
- sb_error.ref() = func(platform_sp);
- else
- sb_error.SetErrorString("not connected");
- }
- else
- sb_error.SetErrorString("invalid platform");
+uint32_t SBPlatform::GetOSUpdateVersion() {
+ uint32_t major, minor, update;
+ PlatformSP platform_sp(GetSP());
+ if (platform_sp && platform_sp->GetOSVersion(major, minor, update))
+ return update;
+ return UINT32_MAX;
+}
+SBError SBPlatform::Get(SBFileSpec &src, SBFileSpec &dst) {
+ SBError sb_error;
+ PlatformSP platform_sp(GetSP());
+ if (platform_sp) {
+ sb_error.ref() = platform_sp->GetFile(src.ref(), dst.ref());
+ } else {
+ sb_error.SetErrorString("invalid platform");
+ }
return sb_error;
}
-SBError
-SBPlatform::MakeDirectory (const char *path, uint32_t file_permissions)
-{
- SBError sb_error;
- PlatformSP platform_sp(GetSP());
- if (platform_sp)
- {
- sb_error.ref() = platform_sp->MakeDirectory(FileSpec{path, false}, file_permissions);
- }
- else
- {
- sb_error.SetErrorString("invalid platform");
- }
- return sb_error;
-}
-
-uint32_t
-SBPlatform::GetFilePermissions (const char *path)
-{
- PlatformSP platform_sp(GetSP());
- if (platform_sp)
- {
- uint32_t file_permissions = 0;
- platform_sp->GetFilePermissions(FileSpec{path, false}, file_permissions);
- return file_permissions;
+SBError SBPlatform::Put(SBFileSpec &src, SBFileSpec &dst) {
+ return ExecuteConnected([&](const lldb::PlatformSP &platform_sp) {
+ if (src.Exists()) {
+ uint32_t permissions = src.ref().GetPermissions();
+ if (permissions == 0) {
+ if (src.ref().GetFileType() == FileSpec::eFileTypeDirectory)
+ permissions = eFilePermissionsDirectoryDefault;
+ else
+ permissions = eFilePermissionsFileDefault;
+ }
+
+ return platform_sp->PutFile(src.ref(), dst.ref(), permissions);
}
- return 0;
-
-}
-
-SBError
-SBPlatform::SetFilePermissions (const char *path, uint32_t file_permissions)
-{
- SBError sb_error;
- PlatformSP platform_sp(GetSP());
- if (platform_sp)
- {
- sb_error.ref() = platform_sp->SetFilePermissions(FileSpec{path, false}, file_permissions);
+
+ Error error;
+ error.SetErrorStringWithFormat("'src' argument doesn't exist: '%s'",
+ src.ref().GetPath().c_str());
+ return error;
+ });
+}
+
+SBError SBPlatform::Install(SBFileSpec &src, SBFileSpec &dst) {
+ return ExecuteConnected([&](const lldb::PlatformSP &platform_sp) {
+ if (src.Exists())
+ return platform_sp->Install(src.ref(), dst.ref());
+
+ Error error;
+ error.SetErrorStringWithFormat("'src' argument doesn't exist: '%s'",
+ src.ref().GetPath().c_str());
+ return error;
+ });
+}
+
+SBError SBPlatform::Run(SBPlatformShellCommand &shell_command) {
+ return ExecuteConnected([&](const lldb::PlatformSP &platform_sp) {
+ const char *command = shell_command.GetCommand();
+ if (!command)
+ return Error("invalid shell command (empty)");
+
+ const char *working_dir = shell_command.GetWorkingDirectory();
+ if (working_dir == NULL) {
+ working_dir = platform_sp->GetWorkingDirectory().GetCString();
+ if (working_dir)
+ shell_command.SetWorkingDirectory(working_dir);
}
+ return platform_sp->RunShellCommand(
+ command, FileSpec{working_dir, false},
+ &shell_command.m_opaque_ptr->m_status,
+ &shell_command.m_opaque_ptr->m_signo,
+ &shell_command.m_opaque_ptr->m_output,
+ shell_command.m_opaque_ptr->m_timeout_sec);
+ });
+}
+
+SBError SBPlatform::Launch(SBLaunchInfo &launch_info) {
+ return ExecuteConnected([&](const lldb::PlatformSP &platform_sp) {
+ return platform_sp->LaunchProcess(launch_info.ref());
+ });
+}
+
+SBError SBPlatform::Kill(const lldb::pid_t pid) {
+ return ExecuteConnected([&](const lldb::PlatformSP &platform_sp) {
+ return platform_sp->KillProcess(pid);
+ });
+}
+
+SBError SBPlatform::ExecuteConnected(
+ const std::function<Error(const lldb::PlatformSP &)> &func) {
+ SBError sb_error;
+ const auto platform_sp(GetSP());
+ if (platform_sp) {
+ if (platform_sp->IsConnected())
+ sb_error.ref() = func(platform_sp);
else
- {
- sb_error.SetErrorString("invalid platform");
- }
- return sb_error;
-
+ sb_error.SetErrorString("not connected");
+ } else
+ sb_error.SetErrorString("invalid platform");
+
+ return sb_error;
+}
+
+SBError SBPlatform::MakeDirectory(const char *path, uint32_t file_permissions) {
+ SBError sb_error;
+ PlatformSP platform_sp(GetSP());
+ if (platform_sp) {
+ sb_error.ref() =
+ platform_sp->MakeDirectory(FileSpec{path, false}, file_permissions);
+ } else {
+ sb_error.SetErrorString("invalid platform");
+ }
+ return sb_error;
+}
+
+uint32_t SBPlatform::GetFilePermissions(const char *path) {
+ PlatformSP platform_sp(GetSP());
+ if (platform_sp) {
+ uint32_t file_permissions = 0;
+ platform_sp->GetFilePermissions(FileSpec{path, false}, file_permissions);
+ return file_permissions;
+ }
+ return 0;
+}
+
+SBError SBPlatform::SetFilePermissions(const char *path,
+ uint32_t file_permissions) {
+ SBError sb_error;
+ PlatformSP platform_sp(GetSP());
+ if (platform_sp) {
+ sb_error.ref() = platform_sp->SetFilePermissions(FileSpec{path, false},
+ file_permissions);
+ } else {
+ sb_error.SetErrorString("invalid platform");
+ }
+ return sb_error;
}
-SBUnixSignals
-SBPlatform::GetUnixSignals() const
-{
- if (auto platform_sp = GetSP())
- return SBUnixSignals{platform_sp};
+SBUnixSignals SBPlatform::GetUnixSignals() const {
+ if (auto platform_sp = GetSP())
+ return SBUnixSignals{platform_sp};
- return {};
+ return {};
}
OpenPOWER on IntegriCloud