[Lldb-commits] [lldb] r154943 - in /lldb/branches/lldb-platform-work: include/lldb/Target/ source/Commands/ source/Plugins/Platform/MacOSX/ source/Plugins/Platform/POSIX/ source/Plugins/Platform/gdb-server/ source/Plugins/Process/gdb-remote/ source/Target/
Enrico Granata
egranata at apple.com
Tue Apr 17 12:39:41 PDT 2012
Author: enrico
Date: Tue Apr 17 14:39:41 2012
New Revision: 154943
URL: http://llvm.org/viewvc/llvm-project?rev=154943&view=rev
Log:
Making it so that target create <path> deals with a local file at location <path> even if a remote platform is selected. In order to bind the local file to a remote one, the --platform-path <remote> option must be passed. One could also pass just the remote path to target create, but this is unimplemented at the moment. Untested yet so might break.
Modified:
lldb/branches/lldb-platform-work/include/lldb/Target/Platform.h
lldb/branches/lldb-platform-work/source/Commands/CommandObjectTarget.cpp
lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
lldb/branches/lldb-platform-work/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
lldb/branches/lldb-platform-work/source/Plugins/Platform/POSIX/PlatformPOSIX.h
lldb/branches/lldb-platform-work/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
lldb/branches/lldb-platform-work/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
lldb/branches/lldb-platform-work/source/Target/Platform.cpp
Modified: lldb/branches/lldb-platform-work/include/lldb/Target/Platform.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/include/lldb/Target/Platform.h?rev=154943&r1=154942&r2=154943&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/include/lldb/Target/Platform.h (original)
+++ lldb/branches/lldb-platform-work/include/lldb/Target/Platform.h Tue Apr 17 14:39:41 2012
@@ -514,6 +514,9 @@
const FileSpec& destination);
virtual bool
+ GetFileExists (const lldb_private::FileSpec& file_spec);
+
+ virtual bool
GetSupportsRSync ()
{
return m_supports_rsync;
Modified: lldb/branches/lldb-platform-work/source/Commands/CommandObjectTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Commands/CommandObjectTarget.cpp?rev=154943&r1=154942&r2=154943&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Commands/CommandObjectTarget.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Commands/CommandObjectTarget.cpp Tue Apr 17 14:39:41 2012
@@ -149,7 +149,8 @@
m_option_group (interpreter),
m_arch_option (),
m_platform_options(true), // Do include the "--platform" option in the platform settings by passing true
- m_core_file (LLDB_OPT_SET_1, false, "core-file", 'c', 0, eArgTypePath, "Fullpath to a core file to use for this target.")
+ m_core_file (LLDB_OPT_SET_1, false, "core-file", 'c', 0, eArgTypePath, "Fullpath to a core file to use for this target."),
+ m_platform_path (LLDB_OPT_SET_1, false, "platform-path", 'P', 0, eArgTypePath, "Path to the remote file to use for this target.")
{
CommandArgumentEntry arg;
CommandArgumentData file_arg;
@@ -167,6 +168,7 @@
m_option_group.Append (&m_arch_option, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
m_option_group.Append (&m_platform_options, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
m_option_group.Append (&m_core_file, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
+ m_option_group.Append (&m_platform_path, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
m_option_group.Finalize();
}
@@ -185,8 +187,9 @@
{
const int argc = command.GetArgumentCount();
FileSpec core_file (m_core_file.GetOptionValue().GetCurrentValue());
+ FileSpec remote_file (m_platform_path.GetOptionValue().GetCurrentValue());
- if (argc == 1 || core_file)
+ if (argc == 1 || core_file || remote_file)
{
const char *file_path = command.GetArgumentAtIndex(0);
Timer scoped_timer(__PRETTY_FUNCTION__, "(lldb) target create '%s'", file_path);
@@ -194,9 +197,54 @@
if (file_path)
file_spec.SetFile (file_path, true);
+
+ bool must_set_platform_path = false;
+
+ Debugger &debugger = m_interpreter.GetDebugger();
+
+ if (remote_file)
+ {
+ // I have a remote file.. two possible cases
+ if (file_spec && file_spec.Exists())
+ {
+ // local file also exists; create the target with local file then set its platform-path to the remote end
+ // and if the remote file does not exist, push it there
+ must_set_platform_path = true;
+ }
+ else
+ {
+ // there is no local file and we need one
+ // in order to make the remote ---> local transfer we need a platform
+ // TODO: if the user has passed in a --platform argument, use it to fetch the right platform
+ PlatformSP platform_sp(debugger.GetPlatformList().GetSelectedPlatform ());
+ if (!platform_sp)
+ {
+ result.AppendError("unable to perform remote debugging without a platform");
+ result.SetStatus (eReturnStatusFailed);
+ return false;
+ }
+ if (file_path)
+ {
+ // copy the remote file to the local file
+ Error err = platform_sp->GetFile(remote_file, file_spec);
+ if (err.Fail())
+ {
+ result.AppendError(err.AsCString());
+ result.SetStatus (eReturnStatusFailed);
+ return false;
+ }
+ }
+ else
+ {
+ // make up a local file
+ result.AppendError("remote --> local transfer without local path is not implemented yet");
+ result.SetStatus (eReturnStatusFailed);
+ return false;
+ }
+ }
+ }
TargetSP target_sp;
- Debugger &debugger = m_interpreter.GetDebugger();
const char *arch_cstr = m_arch_option.GetArchitectureName();
const bool get_dependent_files = true;
Error error (debugger.GetTargetList().CreateTarget (debugger,
@@ -209,6 +257,35 @@
if (target_sp)
{
debugger.GetTargetList().SetSelectedTarget(target_sp.get());
+ if (must_set_platform_path)
+ {
+ ModuleSpec main_module_spec(file_spec);
+ ModuleSP module_sp = target_sp->GetSharedModule(main_module_spec);
+ if (module_sp)
+ module_sp->SetPlatformFileSpec(remote_file);
+ // now check that the remote file also exists
+ PlatformSP platform_sp = target_sp->GetPlatform();
+ if (platform_sp)
+ {
+ if (!platform_sp->GetFileExists (remote_file))
+ {
+ Error err = platform_sp->PutFile(file_spec, remote_file);
+ if (err.Fail())
+ {
+ result.AppendError(err.AsCString());
+ result.SetStatus (eReturnStatusFailed);
+ return false;
+ }
+ }
+ }
+ else
+ {
+ debugger.GetTargetList().DeleteTarget(target_sp);
+ result.AppendError("unable to perform remote debugging without a platform");
+ result.SetStatus (eReturnStatusFailed);
+ return false;
+ }
+ }
if (core_file)
{
char core_path[PATH_MAX];
@@ -300,6 +377,7 @@
OptionGroupArchitecture m_arch_option;
OptionGroupPlatform m_platform_options;
OptionGroupFile m_core_file;
+ OptionGroupFile m_platform_path;
};
Modified: lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp?rev=154943&r1=154942&r2=154943&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp Tue Apr 17 14:39:41 2012
@@ -175,7 +175,8 @@
lldb::ModuleSP *old_module_sp_ptr,
bool *did_create_ptr)
{
- printf("Trying to find module %s/%s - platform path %s/%s symbol path %s/%s\n",
+ printf("[%s] Trying to find module %s/%s - platform path %s/%s symbol path %s/%s\n",
+ (IsHost() ? "host" : "remote"),
module_spec.GetFileSpec().GetDirectory().AsCString(),
module_spec.GetFileSpec().GetFilename().AsCString(),
module_spec.GetPlatformFileSpec().GetDirectory().AsCString(),
Modified: lldb/branches/lldb-platform-work/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp?rev=154943&r1=154942&r2=154943&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp Tue Apr 17 14:39:41 2012
@@ -349,6 +349,18 @@
return Platform::GetFileSize(file_spec);
}
+bool
+PlatformPOSIX::GetFileExists (const FileSpec& file_spec)
+{
+ if (IsHost())
+ {
+ return file_spec.Exists();
+ }
+ if (IsRemote() && m_remote_platform_sp)
+ return m_remote_platform_sp->GetFileExists(file_spec);
+ return Platform::GetFileExists(file_spec);
+}
+
lldb_private::Error
PlatformPOSIX::GetFile (const lldb_private::FileSpec& source /* remote file path */,
const lldb_private::FileSpec& destination /* local file path */)
Modified: lldb/branches/lldb-platform-work/source/Plugins/Platform/POSIX/PlatformPOSIX.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Plugins/Platform/POSIX/PlatformPOSIX.h?rev=154943&r1=154942&r2=154943&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Plugins/Platform/POSIX/PlatformPOSIX.h (original)
+++ lldb/branches/lldb-platform-work/source/Plugins/Platform/POSIX/PlatformPOSIX.h Tue Apr 17 14:39:41 2012
@@ -70,6 +70,9 @@
MakeDirectory (const std::string &path,
mode_t mode);
+ virtual bool
+ GetFileExists (const lldb_private::FileSpec& file_spec);
+
protected:
std::auto_ptr<lldb_private::Options> m_options;
Modified: lldb/branches/lldb-platform-work/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp?rev=154943&r1=154942&r2=154943&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp Tue Apr 17 14:39:41 2012
@@ -97,7 +97,7 @@
{
Error error;
//error.SetErrorString ("PlatformRemoteGDBServer::ResolveExecutable() is unimplemented");
- if (m_gdb_client.FileExists(exe_file))
+ if (m_gdb_client.GetFileExists(exe_file))
return error;
// TODO: get the remote end to somehow resolve this file
error.SetErrorString("file not found on remote end");
@@ -469,3 +469,9 @@
{
return Platform::PutFile(source,destination,uid,gid);
}
+
+bool
+PlatformRemoteGDBServer::GetFileExists (const lldb_private::FileSpec& file_spec)
+{
+ return m_gdb_client.GetFileExists (file_spec);
+}
Modified: lldb/branches/lldb-platform-work/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h?rev=154943&r1=154942&r2=154943&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h (original)
+++ lldb/branches/lldb-platform-work/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h Tue Apr 17 14:39:41 2012
@@ -172,6 +172,9 @@
const lldb_private::FileSpec& destination,
uint32_t uid = UINT32_MAX,
uint32_t gid = UINT32_MAX);
+
+ virtual bool
+ GetFileExists (const lldb_private::FileSpec& file_spec);
protected:
GDBRemoteCommunicationClient m_gdb_client;
Modified: lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp?rev=154943&r1=154942&r2=154943&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp Tue Apr 17 14:39:41 2012
@@ -2066,7 +2066,7 @@
// Extension of host I/O packets to get whether a file exists.
bool
-GDBRemoteCommunicationClient::FileExists (const lldb_private::FileSpec& file_spec)
+GDBRemoteCommunicationClient::GetFileExists (const lldb_private::FileSpec& file_spec)
{
lldb_private::StreamString stream;
stream.PutCString("vFile:exists:");
Modified: lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h?rev=154943&r1=154942&r2=154943&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h (original)
+++ lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h Tue Apr 17 14:39:41 2012
@@ -365,7 +365,7 @@
mode_t mode);
virtual bool
- FileExists (const lldb_private::FileSpec& file_spec);
+ GetFileExists (const lldb_private::FileSpec& file_spec);
protected:
Modified: lldb/branches/lldb-platform-work/source/Target/Platform.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Target/Platform.cpp?rev=154943&r1=154942&r2=154943&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Target/Platform.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Target/Platform.cpp Tue Apr 17 14:39:41 2012
@@ -707,3 +707,8 @@
return error;
}
+bool
+Platform::GetFileExists (const lldb_private::FileSpec& file_spec)
+{
+ return false;
+}
More information about the lldb-commits
mailing list