yuri created this revision. yuri added reviewers: labath, clayborg, EugeneBi. yuri added a project: LLDB. Herald added a subscriber: lldb-commits.
In D49685 <https://reviews.llvm.org/D49685> sysroot behaviour was partially fixed. But files from local filesystem with same path still has priority over files from sysroot. This patch fixes it by removing fallback to local filesystem from RemoteAwarePlatform::GetModuleSpec(). It is not actually required because higher level code do such fallback itself. See, for example, resolver in Platform::GetSharedModule(). Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D77529 Files: lldb/source/Target/RemoteAwarePlatform.cpp lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py lldb/test/API/functionalities/postmortem/elf-core/linux-x86_64-bin_sh.core Index: lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py =================================================================== --- lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py +++ lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py @@ -209,6 +209,33 @@ self.dbg.DeleteTarget(target) + @skipIf(triple='^mips') + @skipIfLLVMTargetMissing("X86") + def test_x86_64_sysroot(self): + """Test that sysroot has more priority then local filesystem.""" + + # linux-x86_64-bin_sh.core is a copy of linux-x86_64.core with executable file path patched to /bin/sh: + # sed 's/\/home\/labath\/test\/a\.out/\/bin\/sh\c@\c@\c@\c@\c@\c@\c@\c@\c@\c@\c@\c@\c@\c@\c@\c@/g;s/a\.out/sh\c@\c@\c@/g' < linux-x86_64.core > linux-x86_64-bin_sh.core + + # Copy linux-x86_64.out to tmp_sysroot/bin/sh + tmp_sysroot = os.path.join(self.getBuildDir(), "lldb_x86_64_mock_sysroot") + executable = os.path.join(tmp_sysroot, "bin", "sh") + lldbutil.mkdir_p(os.path.dirname(executable)) + shutil.copyfile("linux-x86_64.out", executable) + + # Set sysroot and load core + self.runCmd("platform select remote-linux --sysroot '%s'" % tmp_sysroot) + target = self.dbg.CreateTarget(None) + self.assertTrue(target, VALID_TARGET) + process = target.LoadCore("linux-x86_64-bin_sh.core") + + # Check that we found executable from the sysroot + mod_path = str(target.GetModuleAtIndex(0).GetFileSpec()) + self.assertEqual(mod_path, executable) + self.check_all(process, self._x86_64_pid, self._x86_64_regions, "sh") + + self.dbg.DeleteTarget(target) + @skipIf(triple='^mips') @skipIfLLVMTargetMissing("ARM") def test_arm_core(self): Index: lldb/source/Target/RemoteAwarePlatform.cpp =================================================================== --- lldb/source/Target/RemoteAwarePlatform.cpp +++ lldb/source/Target/RemoteAwarePlatform.cpp @@ -21,7 +21,7 @@ return m_remote_platform_sp->GetModuleSpec(module_file_spec, arch, module_spec); - return Platform::GetModuleSpec(module_file_spec, arch, module_spec); + return false; } Status RemoteAwarePlatform::RunShellCommand(
Index: lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py =================================================================== --- lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py +++ lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py @@ -209,6 +209,33 @@ self.dbg.DeleteTarget(target) + @skipIf(triple='^mips') + @skipIfLLVMTargetMissing("X86") + def test_x86_64_sysroot(self): + """Test that sysroot has more priority then local filesystem.""" + + # linux-x86_64-bin_sh.core is a copy of linux-x86_64.core with executable file path patched to /bin/sh: + # sed 's/\/home\/labath\/test\/a\.out/\/bin\/sh\c@\c@\c@\c@\c@\c@\c@\c@\c@\c@\c@\c@\c@\c@\c@\c@/g;s/a\.out/sh\c@\c@\c@/g' < linux-x86_64.core > linux-x86_64-bin_sh.core + + # Copy linux-x86_64.out to tmp_sysroot/bin/sh + tmp_sysroot = os.path.join(self.getBuildDir(), "lldb_x86_64_mock_sysroot") + executable = os.path.join(tmp_sysroot, "bin", "sh") + lldbutil.mkdir_p(os.path.dirname(executable)) + shutil.copyfile("linux-x86_64.out", executable) + + # Set sysroot and load core + self.runCmd("platform select remote-linux --sysroot '%s'" % tmp_sysroot) + target = self.dbg.CreateTarget(None) + self.assertTrue(target, VALID_TARGET) + process = target.LoadCore("linux-x86_64-bin_sh.core") + + # Check that we found executable from the sysroot + mod_path = str(target.GetModuleAtIndex(0).GetFileSpec()) + self.assertEqual(mod_path, executable) + self.check_all(process, self._x86_64_pid, self._x86_64_regions, "sh") + + self.dbg.DeleteTarget(target) + @skipIf(triple='^mips') @skipIfLLVMTargetMissing("ARM") def test_arm_core(self): Index: lldb/source/Target/RemoteAwarePlatform.cpp =================================================================== --- lldb/source/Target/RemoteAwarePlatform.cpp +++ lldb/source/Target/RemoteAwarePlatform.cpp @@ -21,7 +21,7 @@ return m_remote_platform_sp->GetModuleSpec(module_file_spec, arch, module_spec); - return Platform::GetModuleSpec(module_file_spec, arch, module_spec); + return false; } Status RemoteAwarePlatform::RunShellCommand(
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits