[Lldb-commits] [lldb] 2a21700 - In 92eaad2dd7adb5ee92f397cef85ab11f2612294e I made it possible to run
Jim Ingham via lldb-commits
lldb-commits at lists.llvm.org
Thu May 12 17:11:08 PDT 2022
Author: Jim Ingham
Date: 2022-05-12T17:11:01-07:00
New Revision: 2a21700bc5be24532952c2705fbbe784f8ec3164
URL: https://github.com/llvm/llvm-project/commit/2a21700bc5be24532952c2705fbbe784f8ec3164
DIFF: https://github.com/llvm/llvm-project/commit/2a21700bc5be24532952c2705fbbe784f8ec3164.diff
LOG: In 92eaad2dd7adb5ee92f397cef85ab11f2612294e I made it possible to run
a debug session with only a remote path to the file you are debugging
using the SB API's. This patch makes it possible to do this using
target create --remote-file <some_path> without supplying a local file
as well.
Prior to this change we errored out saying that we haven't implemented
copying the binary back from the remote. I didn't implement the copy
back (in the case I'm interested in - iOS debugging - we don't
actually have a way for lldb to do that). This patch doesn't impede
doing that, I just didn't need it. I think for some object file
formats debugging w/o the binary file is hard because of what doesn't
get mapped in. I didn't try to arbitrate that, I'm assuming anybody
who has to do this knows what they are going to get.
If there's a connected platform that can check that the remote file
exists, it will do so, otherwise we trust the user's input - if it
isn't there the process launch is going to fail with no-such-file so
it will be pretty clear what went wrong.
Differential Revision: https://reviews.llvm.org/D124947
Added:
Modified:
lldb/source/Commands/CommandObjectTarget.cpp
lldb/test/API/functionalities/gdb_remote_client/TestNoLocalFile.py
Removed:
################################################################################
diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp
index 5a36298121630..c3376d04854e1 100644
--- a/lldb/source/Commands/CommandObjectTarget.cpp
+++ b/lldb/source/Commands/CommandObjectTarget.cpp
@@ -358,10 +358,29 @@ class CommandObjectTargetCreate : public CommandObjectParsed {
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
index 8cc10133783f0..44873f39628c8 100644
--- a/lldb/test/API/functionalities/gdb_remote_client/TestNoLocalFile.py
+++ b/lldb/test/API/functionalities/gdb_remote_client/TestNoLocalFile.py
@@ -12,7 +12,13 @@ class TestNoLocalFile(GDBRemoteTestBase):
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 @@ def qProcessInfo(self):
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)
More information about the lldb-commits
mailing list