@@ -1728,120 +1728,34 @@ SymbolFileDWARF::GetDwoSymbolFileForCompileUnit(
17281728 if (std::shared_ptr<SymbolFileDWARFDwo> dwp_sp = GetDwpSymbolFile ())
17291729 return dwp_sp;
17301730
1731+ const char *comp_dir = nullptr ;
17311732 FileSpec dwo_file (dwo_name);
17321733 FileSystem::Instance ().Resolve (dwo_file);
1733- bool found = false ;
1734-
1735- const FileSpecList &debug_file_search_paths =
1736- Target::GetDefaultDebugFileSearchPaths ();
1737- size_t num_search_paths = debug_file_search_paths.GetSize ();
1738-
1739- // It's relative, e.g. "foo.dwo", but we just to happen to be right next to
1740- // it. Or it's absolute.
1741- found = FileSystem::Instance ().Exists (dwo_file);
1742-
1743- if (!found) {
1744- // It could be a relative path that also uses DW_AT_COMP_DIR.
1745- const char *comp_dir =
1746- cu_die.GetAttributeValueAsString (dwarf_cu, DW_AT_comp_dir, nullptr );
1747-
1748- if (comp_dir) {
1749- dwo_file.SetFile (comp_dir, FileSpec::Style::native);
1750- if (!dwo_file.IsRelative ()) {
1751- FileSystem::Instance ().Resolve (dwo_file);
1752- dwo_file.AppendPathComponent (dwo_name);
1753- found = FileSystem::Instance ().Exists (dwo_file);
1754- } else {
1755- FileSpecList dwo_paths;
1756-
1757- // if DW_AT_comp_dir is relative, it should be relative to the location
1758- // of the executable, not to the location from which the debugger was
1759- // launched.
1760- FileSpec relative_to_binary = dwo_file;
1761- relative_to_binary.PrependPathComponent (
1762- m_objfile_sp->GetFileSpec ().GetDirectory ().GetStringRef ());
1763- FileSystem::Instance ().Resolve (relative_to_binary);
1764- relative_to_binary.AppendPathComponent (dwo_name);
1765- dwo_paths.Append (relative_to_binary);
1766-
1767- // Or it's relative to one of the user specified debug directories.
1768- for (size_t idx = 0 ; idx < num_search_paths; ++idx) {
1769- FileSpec dirspec = debug_file_search_paths.GetFileSpecAtIndex (idx);
1770- dirspec.AppendPathComponent (comp_dir);
1771- FileSystem::Instance ().Resolve (dirspec);
1772- if (!FileSystem::Instance ().IsDirectory (dirspec))
1773- continue ;
1774-
1775- dirspec.AppendPathComponent (dwo_name);
1776- dwo_paths.Append (dirspec);
1777- }
1778-
1779- size_t num_possible = dwo_paths.GetSize ();
1780- for (size_t idx = 0 ; idx < num_possible && !found; ++idx) {
1781- FileSpec dwo_spec = dwo_paths.GetFileSpecAtIndex (idx);
1782- if (FileSystem::Instance ().Exists (dwo_spec)) {
1783- dwo_file = dwo_spec;
1784- found = true ;
1785- }
1786- }
1787- }
1788- } else {
1789- Log *log = GetLog (LLDBLog::Symbols);
1790- LLDB_LOGF (log,
1791- " unable to locate relative .dwo debug file \" %s\" for "
1792- " skeleton DIE 0x%016" PRIx64 " without valid DW_AT_comp_dir "
1793- " attribute" ,
1794- dwo_name, cu_die.GetOffset ());
1734+ if (dwo_file.IsRelative ()) {
1735+ comp_dir = cu_die.GetAttributeValueAsString (dwarf_cu, DW_AT_comp_dir,
1736+ nullptr );
1737+ if (!comp_dir) {
1738+ unit.SetDwoError (Status::createWithFormat (
1739+ " unable to locate relative .dwo debug file \" {0}\" for "
1740+ " skeleton DIE {1:x16} without valid DW_AT_comp_dir "
1741+ " attribute" ,
1742+ dwo_name, cu_die.GetOffset ()));
1743+ return nullptr ;
17951744 }
1796- }
17971745
1798- if (!found) {
1799- // Try adding the DW_AT_dwo_name ( e.g. "c/d/main-main.dwo"), and just the
1800- // filename ("main-main.dwo") to binary dir and search paths.
1801- FileSpecList dwo_paths;
1802- FileSpec dwo_name_spec (dwo_name);
1803- llvm::StringRef filename_only = dwo_name_spec.GetFilename ();
1804-
1805- FileSpec binary_directory (
1806- m_objfile_sp->GetFileSpec ().GetDirectory ().GetStringRef ());
1807- FileSystem::Instance ().Resolve (binary_directory);
1808-
1809- if (dwo_name_spec.IsRelative ()) {
1810- FileSpec dwo_name_binary_directory (binary_directory);
1811- dwo_name_binary_directory.AppendPathComponent (dwo_name);
1812- dwo_paths.Append (dwo_name_binary_directory);
1813- }
1814-
1815- FileSpec filename_binary_directory (binary_directory);
1816- filename_binary_directory.AppendPathComponent (filename_only);
1817- dwo_paths.Append (filename_binary_directory);
1818-
1819- for (size_t idx = 0 ; idx < num_search_paths; ++idx) {
1820- FileSpec dirspec = debug_file_search_paths.GetFileSpecAtIndex (idx);
1821- FileSystem::Instance ().Resolve (dirspec);
1822- if (!FileSystem::Instance ().IsDirectory (dirspec))
1823- continue ;
1824-
1825- FileSpec dwo_name_dirspec (dirspec);
1826- dwo_name_dirspec.AppendPathComponent (dwo_name);
1827- dwo_paths.Append (dwo_name_dirspec);
1828-
1829- FileSpec filename_dirspec (dirspec);
1830- filename_dirspec.AppendPathComponent (filename_only);
1831- dwo_paths.Append (filename_dirspec);
1832- }
1833-
1834- size_t num_possible = dwo_paths.GetSize ();
1835- for (size_t idx = 0 ; idx < num_possible && !found; ++idx) {
1836- FileSpec dwo_spec = dwo_paths.GetFileSpecAtIndex (idx);
1837- if (FileSystem::Instance ().Exists (dwo_spec)) {
1838- dwo_file = dwo_spec;
1839- found = true ;
1840- }
1746+ dwo_file.SetFile (comp_dir, FileSpec::Style::native);
1747+ if (dwo_file.IsRelative ()) {
1748+ // if DW_AT_comp_dir is relative, it should be relative to the location
1749+ // of the executable, not to the location from which the debugger was
1750+ // launched.
1751+ dwo_file.PrependPathComponent (
1752+ m_objfile_sp->GetFileSpec ().GetDirectory ().GetStringRef ());
18411753 }
1754+ FileSystem::Instance ().Resolve (dwo_file);
1755+ dwo_file.AppendPathComponent (dwo_name);
18421756 }
18431757
1844- if (!found ) {
1758+ if (!FileSystem::Instance (). Exists (dwo_file) ) {
18451759 unit.SetDwoError (Status::createWithFormat (
18461760 " unable to locate .dwo debug file \" {0}\" for skeleton DIE "
18471761 " {1:x16}" ,
0 commit comments