diff --git a/lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp b/lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp --- a/lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp +++ b/lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp @@ -523,9 +523,13 @@ // directories that contain executables that can be searched for matches. ModuleSpec basename_module_spec(module_spec); basename_module_spec.GetUUID().Clear(); - basename_module_spec.GetFileSpec().GetDirectory().Clear(); module_sp = GetTarget().GetOrCreateModule(basename_module_spec, true /* notify */, &error); + if (!module_sp) { + basename_module_spec.GetFileSpec().GetDirectory().Clear(); + module_sp = GetTarget().GetOrCreateModule(basename_module_spec, + true /* notify */, &error); + } if (module_sp) { // We consider the module to be a match if the minidump UUID is a // prefix of the actual UUID, or if either of the UUIDs are empty. diff --git a/lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py b/lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py --- a/lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py +++ b/lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py @@ -22,11 +22,14 @@ def verify_module(self, module, verify_path, verify_uuid): # Compare the filename and the directory separately. We are avoiding # SBFileSpec.fullpath because it causes a slash/backslash confusion - # on Windows. + # on Windows. Similarly, we compare the directories using normcase + # because they may contain a Linux-style relative path from the + # minidump appended to a Windows-style root path from the host. self.assertEqual( os.path.basename(verify_path), module.GetFileSpec().basename) self.assertEqual( - os.path.dirname(verify_path), module.GetFileSpec().dirname or "") + os.path.normcase(os.path.dirname(verify_path)), + os.path.normcase(module.GetFileSpec().dirname or "")) self.assertEqual(verify_uuid, module.GetUUIDString()) def get_minidump_modules(self, yaml_file): @@ -201,6 +204,25 @@ # will check that this matches. self.verify_module(modules[0], so_path, "D9C480E8") + def test_breakpad_hash_match_sysroot(self): + """ + Check that we can match the breakpad .text section hash when the + module is located under a user-provided sysroot. + """ + sysroot_path = os.path.join(self.getBuildDir(), "mock_sysroot") + # Create the directory under the sysroot where the minidump reports + # the module. + so_dir = os.path.join(sysroot_path, "invalid", "path", "on", "current", "system") + so_path = os.path.join(so_dir, "libbreakpad.so") + lldbutil.mkdir_p(so_dir) + self.yaml2obj("libbreakpad.yaml", so_path) + self.runCmd("platform select remote-linux --sysroot '%s'" % sysroot_path) + modules = self.get_minidump_modules("linux-arm-breakpad-uuid-match.yaml") + self.assertEqual(1, len(modules)) + # LLDB makes up its own UUID as well when there is no build ID so we + # will check that this matches. + self.verify_module(modules[0], so_path, "D9C480E8") + def test_breakpad_overflow_hash_match(self): """ This is a similar to test_breakpad_hash_match, but it verifies that