summaryrefslogtreecommitdiffstats
path: root/lldb/source/Target
diff options
context:
space:
mode:
authorDaniel Malea <daniel.malea@intel.com>2013-08-26 23:57:52 +0000
committerDaniel Malea <daniel.malea@intel.com>2013-08-26 23:57:52 +0000
commite0f8f574c7f41f5b61ec01aa290d52fc55a3f3c9 (patch)
treec519b347e7428c3b28956c9165b661b11b468470 /lldb/source/Target
parent6b16b43ef95d2ffbad889601f26786ecdbd914b4 (diff)
downloadbcm5719-llvm-e0f8f574c7f41f5b61ec01aa290d52fc55a3f3c9.tar.gz
bcm5719-llvm-e0f8f574c7f41f5b61ec01aa290d52fc55a3f3c9.zip
merge lldb-platform-work branch (and assorted fixes) into trunk
Summary: This merge brings in the improved 'platform' command that knows how to interface with remote machines; that is, query OS/kernel information, push and pull files, run shell commands, etc... and implementation for the new communication packets that back that interface, at least on Darwin based operating systems via the POSIXPlatform class. Linux support is coming soon. Verified the test suite runs cleanly on Linux (x86_64), build OK on Mac OS X Mountain Lion. Additional improvements (not in the source SVN branch 'lldb-platform-work'): - cmake build scripts for lldb-platform - cleanup test suite - documentation stub for qPlatform_RunCommand - use log class instead of printf() directly - reverted work-in-progress-looking changes from test/types/TestAbstract.py that work towards running the test suite remotely. - add new logging category 'platform' Reviewers: Matt Kopec, Greg Clayton Review: http://llvm-reviews.chandlerc.com/D1493 llvm-svn: 189295
Diffstat (limited to 'lldb/source/Target')
-rw-r--r--lldb/source/Target/Platform.cpp269
1 files changed, 267 insertions, 2 deletions
diff --git a/lldb/source/Target/Platform.cpp b/lldb/source/Target/Platform.cpp
index e6d3bc7a55d..eaedbffe6f1 100644
--- a/lldb/source/Target/Platform.cpp
+++ b/lldb/source/Target/Platform.cpp
@@ -22,6 +22,7 @@
#include "lldb/Host/Host.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/Utils.h"
using namespace lldb;
using namespace lldb_private;
@@ -247,7 +248,13 @@ Platform::Platform (bool is_host) :
m_uid_map(),
m_gid_map(),
m_max_uid_name_len (0),
- m_max_gid_name_len (0)
+ m_max_gid_name_len (0),
+ m_supports_rsync (false),
+ m_rsync_opts (),
+ m_rsync_prefix (),
+ m_supports_ssh (false),
+ m_ssh_opts (),
+ m_ignores_remote_hostname (false)
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
if (log)
@@ -311,6 +318,14 @@ Platform::GetStatus (Stream &strm)
strm.Printf(" Hostname: %s\n", GetHostname());
strm.Printf(" Connected: %s\n", is_connected ? "yes" : "no");
}
+
+ if (!IsConnected())
+ return;
+
+ std::string specific_info(GetPlatformSpecificConnectionInformation());
+
+ if (specific_info.empty() == false)
+ strm.Printf("Platform-specific connection: %s\n", specific_info.c_str());
}
@@ -760,9 +775,161 @@ Platform::IsCompatibleArchitecture (const ArchSpec &arch, bool exact_arch_match,
if (compatible_arch_ptr)
compatible_arch_ptr->Clear();
return false;
+}
+
+uint32_t
+Platform::MakeDirectory (const FileSpec &spec,
+ mode_t mode)
+{
+ std::string path(spec.GetPath());
+ return this->MakeDirectory(path,mode);
+}
+
+Error
+Platform::PutFile (const FileSpec& source,
+ const FileSpec& destination,
+ uint32_t uid,
+ uint32_t gid)
+{
+ Error error("unimplemented");
+ return error;
+}
+
+Error
+Platform::GetFile (const FileSpec& source,
+ const FileSpec& destination)
+{
+ Error error("unimplemented");
+ return error;
+}
+
+bool
+Platform::GetFileExists (const lldb_private::FileSpec& file_spec)
+{
+ return false;
+}
+
+lldb_private::Error
+Platform::RunShellCommand (const char *command, // Shouldn't be NULL
+ const char *working_dir, // Pass NULL to use the current working directory
+ int *status_ptr, // Pass NULL if you don't want the process exit status
+ int *signo_ptr, // Pass NULL if you don't want the signal that caused the process to exit
+ std::string *command_output, // Pass NULL if you don't want the command output
+ uint32_t timeout_sec) // Timeout in seconds to wait for shell program to finish
+{
+ if (IsHost())
+ return Host::RunShellCommand (command, working_dir, status_ptr, signo_ptr, command_output, timeout_sec);
+ else
+ return Error("unimplemented");
+}
+
+
+bool
+Platform::CalculateMD5 (const FileSpec& file_spec,
+ uint64_t &low,
+ uint64_t &high)
+{
+ if (IsHost())
+ return Host::CalculateMD5(file_spec, low, high);
+ else
+ return false;
+}
+
+void
+Platform::SetLocalCacheDirectory (const char* local)
+{
+ m_local_cache_directory.assign(local);
+}
+
+const char*
+Platform::GetLocalCacheDirectory ()
+{
+ return m_local_cache_directory.c_str();
+}
+
+static OptionDefinition
+g_rsync_option_table[] =
+{
+ { LLDB_OPT_SET_ALL, false, "rsync" , 'r', no_argument, NULL, 0, eArgTypeNone , "Enable rsync." },
+ { LLDB_OPT_SET_ALL, false, "rsync-opts" , 'R', required_argument, NULL, 0, eArgTypeCommandName , "Platform-specific options required for rsync to work." },
+ { LLDB_OPT_SET_ALL, false, "rsync-prefix" , 'P', required_argument, NULL, 0, eArgTypeCommandName , "Platform-specific rsync prefix put before the remote path." },
+ { LLDB_OPT_SET_ALL, false, "ignore-remote-hostname" , 'i', no_argument, NULL, 0, eArgTypeNone , "Do not automatically fill in the remote hostname when composing the rsync command." },
+};
+
+static OptionDefinition
+g_ssh_option_table[] =
+{
+ { LLDB_OPT_SET_ALL, false, "ssh" , 's', no_argument, NULL, 0, eArgTypeNone , "Enable SSH." },
+ { LLDB_OPT_SET_ALL, false, "ssh-opts" , 'S', required_argument, NULL, 0, eArgTypeCommandName , "Platform-specific options required for SSH to work." },
+};
+
+static OptionDefinition
+g_caching_option_table[] =
+{
+ { LLDB_OPT_SET_ALL, false, "local-cache-dir" , 'c', required_argument, NULL, 0, eArgTypePath , "Path in which to store local copies of files." },
+};
+
+OptionGroupPlatformRSync::OptionGroupPlatformRSync ()
+{
+}
+
+OptionGroupPlatformRSync::~OptionGroupPlatformRSync ()
+{
+}
+
+const lldb_private::OptionDefinition*
+OptionGroupPlatformRSync::GetDefinitions ()
+{
+ return g_rsync_option_table;
+}
+
+void
+OptionGroupPlatformRSync::OptionParsingStarting (CommandInterpreter &interpreter)
+{
+ m_rsync = false;
+ m_rsync_opts.clear();
+ m_rsync_prefix.clear();
+ m_ignores_remote_hostname = false;
+}
+
+lldb_private::Error
+OptionGroupPlatformRSync::SetOptionValue (CommandInterpreter &interpreter,
+ uint32_t option_idx,
+ const char *option_arg)
+{
+ Error error;
+ char short_option = (char) GetDefinitions()[option_idx].short_option;
+ switch (short_option)
+ {
+ case 'r':
+ m_rsync = true;
+ break;
+
+ case 'R':
+ m_rsync_opts.assign(option_arg);
+ break;
+
+ case 'P':
+ m_rsync_prefix.assign(option_arg);
+ break;
+
+ case 'i':
+ m_ignores_remote_hostname = true;
+ break;
+
+ default:
+ error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
+ break;
+ }
+ return error;
}
+uint32_t
+OptionGroupPlatformRSync::GetNumDefinitions ()
+{
+ return llvm::array_lengthof(g_rsync_option_table);
+}
lldb::BreakpointSP
Platform::SetThreadCreationBreakpoint (lldb_private::Target &target)
@@ -770,10 +937,108 @@ Platform::SetThreadCreationBreakpoint (lldb_private::Target &target)
return lldb::BreakpointSP();
}
+OptionGroupPlatformSSH::OptionGroupPlatformSSH ()
+{
+}
+
+OptionGroupPlatformSSH::~OptionGroupPlatformSSH ()
+{
+}
+
+const lldb_private::OptionDefinition*
+OptionGroupPlatformSSH::GetDefinitions ()
+{
+ return g_ssh_option_table;
+}
+
+void
+OptionGroupPlatformSSH::OptionParsingStarting (CommandInterpreter &interpreter)
+{
+ m_ssh = false;
+ m_ssh_opts.clear();
+}
+
+lldb_private::Error
+OptionGroupPlatformSSH::SetOptionValue (CommandInterpreter &interpreter,
+ uint32_t option_idx,
+ const char *option_arg)
+{
+ Error error;
+ char short_option = (char) GetDefinitions()[option_idx].short_option;
+ switch (short_option)
+ {
+ case 's':
+ m_ssh = true;
+ break;
+
+ case 'S':
+ m_ssh_opts.assign(option_arg);
+ break;
+
+ default:
+ error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
+ break;
+ }
+
+ return error;
+}
+
+uint32_t
+OptionGroupPlatformSSH::GetNumDefinitions ()
+{
+ return llvm::array_lengthof(g_ssh_option_table);
+}
+
+OptionGroupPlatformCaching::OptionGroupPlatformCaching ()
+{
+}
+
+OptionGroupPlatformCaching::~OptionGroupPlatformCaching ()
+{
+}
+
+const lldb_private::OptionDefinition*
+OptionGroupPlatformCaching::GetDefinitions ()
+{
+ return g_caching_option_table;
+}
+
+void
+OptionGroupPlatformCaching::OptionParsingStarting (CommandInterpreter &interpreter)
+{
+ m_cache_dir.clear();
+}
+
+lldb_private::Error
+OptionGroupPlatformCaching::SetOptionValue (CommandInterpreter &interpreter,
+ uint32_t option_idx,
+ const char *option_arg)
+{
+ Error error;
+ char short_option = (char) GetDefinitions()[option_idx].short_option;
+ switch (short_option)
+ {
+ case 'c':
+ m_cache_dir.assign(option_arg);
+ break;
+
+ default:
+ error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
+ break;
+ }
+
+ return error;
+}
+
+uint32_t
+OptionGroupPlatformCaching::GetNumDefinitions ()
+{
+ return llvm::array_lengthof(g_caching_option_table);
+}
+
size_t
Platform::GetEnvironment (StringList &environment)
{
environment.Clear();
return false;
}
-
OpenPOWER on IntegriCloud