yuri updated this revision to Diff 255260.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D77529/new/
https://reviews.llvm.org/D77529
Files:
lldb/source/Target/RemoteAwarePlatform.cpp
lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py
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,39 @@
self.dbg.DeleteTarget(target)
+ @skipIf(triple='^mips')
+ @skipIfLLVMTargetMissing("X86")
+ def test_x86_64_sysroot(self):
+ """Test that sysroot has more priority then local filesystem."""
+
+ # Prepare patched core file
+ core_file = os.path.join(self.getBuildDir(),
"lldb_x86_64_patched.core")
+ with open('linux-x86_64.core', 'rb') as f:
+ core = f.read()
+ core = core.replace(b'/home/labath/test/a.out',
b'/bin/sh\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0')
+ core = core.replace(b'a.out', b'sh\0\0\0')
+ with open(core_file, 'wb') as f:
+ f.write(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(core_file)
+
+ # 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,39 @@
self.dbg.DeleteTarget(target)
+ @skipIf(triple='^mips')
+ @skipIfLLVMTargetMissing("X86")
+ def test_x86_64_sysroot(self):
+ """Test that sysroot has more priority then local filesystem."""
+
+ # Prepare patched core file
+ core_file = os.path.join(self.getBuildDir(), "lldb_x86_64_patched.core")
+ with open('linux-x86_64.core', 'rb') as f:
+ core = f.read()
+ core = core.replace(b'/home/labath/test/a.out', b'/bin/sh\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0')
+ core = core.replace(b'a.out', b'sh\0\0\0')
+ with open(core_file, 'wb') as f:
+ f.write(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(core_file)
+
+ # 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
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits