Skip to content

Commit 139df36

Browse files
authored
[LLDB] Make 'process load' take remote os path delimiter into account (#98690)
Currently, if we execute 'process load' with remote debugging, it uses the host's path delimiter to look up files on a target machine. If we run remote debugging of Linux target on Windows and execute "process load C:\foo\a.so", lldb-server tries to load \foo\a.so instead of /foo/a.so on the remote. It affects several API tests. This commit fixes that error. Also, it contains minor fixes for TestLoadUnload.py for testing on Windows host and Linux target.
1 parent 522fd53 commit 139df36

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

lldb/source/Commands/CommandObjectProcess.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -950,11 +950,13 @@ class CommandObjectProcessLoad : public CommandObjectParsed {
950950
ExecutionContext *execution_context) override {
951951
Status error;
952952
const int short_option = m_getopt_table[option_idx].val;
953+
ArchSpec arch =
954+
execution_context->GetProcessPtr()->GetSystemArchitecture();
953955
switch (short_option) {
954956
case 'i':
955957
do_install = true;
956958
if (!option_arg.empty())
957-
install_path.SetFile(option_arg, FileSpec::Style::native);
959+
install_path.SetFile(option_arg, arch.GetTriple());
958960
break;
959961
default:
960962
llvm_unreachable("Unimplemented option");

lldb/test/API/functionalities/load_unload/TestLoadUnload.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def copy_shlibs_to_remote(self, hidden_dir=False):
6262
for f in shlibs:
6363
err = lldb.remote_platform.Put(
6464
lldb.SBFileSpec(self.getBuildArtifact(f)),
65-
lldb.SBFileSpec(os.path.join(wd, f)),
65+
lldb.SBFileSpec(lldbutil.join_remote_paths(wd, f)),
6666
)
6767
if err.Fail():
6868
raise RuntimeError(
@@ -71,7 +71,7 @@ def copy_shlibs_to_remote(self, hidden_dir=False):
7171
if hidden_dir:
7272
shlib = "libloadunload_d." + ext
7373
hidden_dir = os.path.join(wd, "hidden")
74-
hidden_file = os.path.join(hidden_dir, shlib)
74+
hidden_file = lldbutil.join_remote_paths(hidden_dir, shlib)
7575
err = lldb.remote_platform.MakeDirectory(hidden_dir)
7676
if err.Fail():
7777
raise RuntimeError(
@@ -405,8 +405,10 @@ def run_step_over_load(self):
405405

406406
# We can't find a breakpoint location for d_init before launching because
407407
# executable dependencies are resolved relative to the debuggers PWD. Bug?
408+
# The remote lldb server resolves the executable dependencies correctly.
408409
@expectedFailureAll(
409-
oslist=["freebsd", "linux", "netbsd"], triple=no_match("aarch64-.*-android")
410+
oslist=["freebsd", "linux", "netbsd"],
411+
remote=False,
410412
)
411413
@expectedFailureAll(oslist=["windows"], archs=["aarch64"])
412414
def test_static_init_during_load(self):

0 commit comments

Comments
 (0)