Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LLDB] Make 'process load' take remote os path delimiter into account #98690

Merged
merged 1 commit into from
Jul 16, 2024

Conversation

dzhidzhoev
Copy link
Member

@dzhidzhoev dzhidzhoev commented Jul 12, 2024

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.

@llvmbot
Copy link
Collaborator

llvmbot commented Jul 12, 2024

@llvm/pr-subscribers-lldb

Author: Vladislav Dzhidzhoev (dzhidzhoev)

Changes

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.

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.


Full diff: https://github.com/llvm/llvm-project/pull/98690.diff

2 Files Affected:

  • (modified) lldb/source/Commands/CommandObjectProcess.cpp (+2-1)
  • (modified) lldb/test/API/functionalities/load_unload/TestLoadUnload.py (+4-3)
diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp
index 3587a8f529e4a..bdcd58c0da785 100644
--- a/lldb/source/Commands/CommandObjectProcess.cpp
+++ b/lldb/source/Commands/CommandObjectProcess.cpp
@@ -950,11 +950,12 @@ class CommandObjectProcessLoad : public CommandObjectParsed {
                           ExecutionContext *execution_context) override {
       Status error;
       const int short_option = m_getopt_table[option_idx].val;
+      ArchSpec arch = execution_context->GetProcessPtr()->GetSystemArchitecture();
       switch (short_option) {
       case 'i':
         do_install = true;
         if (!option_arg.empty())
-          install_path.SetFile(option_arg, FileSpec::Style::native);
+          install_path.SetFile(option_arg, arch.GetTriple());
         break;
       default:
         llvm_unreachable("Unimplemented option");
diff --git a/lldb/test/API/functionalities/load_unload/TestLoadUnload.py b/lldb/test/API/functionalities/load_unload/TestLoadUnload.py
index e52fb8c87377f..cc4060d48cc86 100644
--- a/lldb/test/API/functionalities/load_unload/TestLoadUnload.py
+++ b/lldb/test/API/functionalities/load_unload/TestLoadUnload.py
@@ -62,7 +62,7 @@ def copy_shlibs_to_remote(self, hidden_dir=False):
             for f in shlibs:
                 err = lldb.remote_platform.Put(
                     lldb.SBFileSpec(self.getBuildArtifact(f)),
-                    lldb.SBFileSpec(os.path.join(wd, f)),
+                    lldb.SBFileSpec(lldbutil.join_remote_paths(wd, f)),
                 )
                 if err.Fail():
                     raise RuntimeError(
@@ -71,7 +71,7 @@ def copy_shlibs_to_remote(self, hidden_dir=False):
             if hidden_dir:
                 shlib = "libloadunload_d." + ext
                 hidden_dir = os.path.join(wd, "hidden")
-                hidden_file = os.path.join(hidden_dir, shlib)
+                hidden_file = lldbutil.join_remote_paths(hidden_dir, shlib)
                 err = lldb.remote_platform.MakeDirectory(hidden_dir)
                 if err.Fail():
                     raise RuntimeError(
@@ -405,8 +405,9 @@ def run_step_over_load(self):
 
     # We can't find a breakpoint location for d_init before launching because
     # executable dependencies are resolved relative to the debuggers PWD. Bug?
+    # The remote lldb server resolves the executable dependencies correctly.
     @expectedFailureAll(
-        oslist=["freebsd", "linux", "netbsd"], triple=no_match("aarch64-.*-android")
+        oslist=["freebsd", "linux", "netbsd"], triple=no_match("aarch64-.*-android"), remote=False
     )
     @expectedFailureAll(oslist=["windows"], archs=["aarch64"])
     def test_static_init_during_load(self):

@dzhidzhoev dzhidzhoev self-assigned this Jul 12, 2024
Copy link

github-actions bot commented Jul 12, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

Copy link

github-actions bot commented Jul 12, 2024

✅ With the latest revision this PR passed the Python code formatter.

@expectedFailureAll(
oslist=["freebsd", "linux", "netbsd"], triple=no_match("aarch64-.*-android")
oslist=["freebsd", "linux", "netbsd"],
triple=no_match("aarch64-.*-android"),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fairly certain you don't need this line. Android testing is always remote, so I expect that this bit was used as a proxy for "remote=False" (probably unknowingly, because it wasn't known that the remoteness of the config is the important aspect).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

Currently, if we execute 'process load' with remote debugging,
it uses host's path delimiter to lookup files on 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.

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.
@dzhidzhoev dzhidzhoev merged commit 139df36 into llvm:main Jul 16, 2024
6 checks passed
sayhaan pushed a commit to sayhaan/llvm-project that referenced this pull request Jul 16, 2024
…llvm#98690)

Summary:
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.

Test Plan: 

Reviewers: 

Subscribers: 

Tasks: 

Tags: 


Differential Revision: https://phabricator.intern.facebook.com/D59822448
yuxuanchen1997 pushed a commit that referenced this pull request Jul 25, 2024
…#98690)

Summary:
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.

Test Plan: 

Reviewers: 

Subscribers: 

Tasks: 

Tags: 


Differential Revision: https://phabricator.intern.facebook.com/D60251565
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants