diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp --- a/lldb/source/Commands/CommandObjectTarget.cpp +++ b/lldb/source/Commands/CommandObjectTarget.cpp @@ -358,10 +358,29 @@ return false; } } else { - // make up a local file - result.AppendError("remote --> local transfer without local " + // If the remote file exists, we can debug reading that out of + // memory. If the platform is already connected to an lldb-server + // then we can at least check the file exists remotely. Otherwise + // we'll just have to trust that it will be there when we do + // process connect. + // I don't do this for the host platform because it seems odd to + // support supplying a remote file but no local file for a local + // debug session. + if (platform_sp->IsHost()) { + result.AppendError("Supply a local file, not a remote file, " + "when debugging on the host."); + return false; + } + if (platform_sp->IsConnected() && !platform_sp->GetFileExists(remote_file)) { + result.AppendError("remote --> local transfer without local " "path is not implemented yet"); - return false; + return false; + } + // Since there's only a remote file, we need to set the executable + // file spec to the remote one. + ProcessLaunchInfo launch_info = target_sp->GetProcessLaunchInfo(); + launch_info.SetExecutableFile(FileSpec(remote_file), true); + target_sp->SetProcessLaunchInfo(launch_info); } } } else { diff --git a/lldb/test/API/functionalities/gdb_remote_client/TestNoLocalFile.py b/lldb/test/API/functionalities/gdb_remote_client/TestNoLocalFile.py --- a/lldb/test/API/functionalities/gdb_remote_client/TestNoLocalFile.py +++ b/lldb/test/API/functionalities/gdb_remote_client/TestNoLocalFile.py @@ -12,7 +12,13 @@ mydir = TestBase.compute_mydir(__file__) @skipIfXmlSupportMissing - def test(self): + def test_with_python(self): + self.do_test(False) + @skipIfXmlSupportMissing + def test_with_target_ceate(self): + self.do_test(True) + + def do_test(self, use_target_create): self.absent_file = '/nosuch_dir/nosuch_subdir/nosuch_executable' self.a_packet_file = None class MyResponder(MockGDBServerResponder): @@ -67,10 +73,19 @@ error = lldb.SBError() self.server.responder = MyResponder(self) - target = self.dbg.CreateTarget(None, "x86_64-apple-macosx", "remote-macosx", False, error) - self.assertSuccess(error, "Made a valid target") + target = lldb.SBTarget() + if (use_target_create): + create_cmd = "target create --arch x86_64-apple-macosx --platform remote-macosx --remote-file {0}".format(self.absent_file) + self.runCmd(create_cmd) + target = self.dbg.GetSelectedTarget() + self.assertTrue(target.IsValid(), "Made a valid target") + else: + target = self.dbg.CreateTarget(None, "x86_64-apple-macosx", "remote-macosx", False, error) + self.assertSuccess(error, "Made a valid target") + launch_info = target.GetLaunchInfo() - launch_info.SetExecutableFile(lldb.SBFileSpec(self.absent_file), True) + if (not use_target_create): + launch_info.SetExecutableFile(lldb.SBFileSpec(self.absent_file), True) flags = launch_info.GetLaunchFlags() flags |= lldb.eLaunchFlagStopAtEntry launch_info.SetLaunchFlags(flags)