Author: David Spickett Date: 2023-09-08T08:00:38Z New Revision: dc3f758ddc9b76b1a1d3e63147521e56906fd7a4
URL: https://github.com/llvm/llvm-project/commit/dc3f758ddc9b76b1a1d3e63147521e56906fd7a4 DIFF: https://github.com/llvm/llvm-project/commit/dc3f758ddc9b76b1a1d3e63147521e56906fd7a4.diff LOG: Revert "[lldb] Add more ways to find split DWARF files" This reverts commit a723694321b993f6f53fedf50e70e9cf5a206357. Tests are failing on x86_64 MacOS. Added: Modified: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Removed: lldb/test/Shell/SymbolFile/DWARF/dwo-debug-file-search-path-symlink-relative-compdir.c lldb/test/Shell/SymbolFile/DWARF/dwo-debug-file-search-paths-dwoname-absolute-compdir.c lldb/test/Shell/SymbolFile/DWARF/dwo-debug-file-search-paths-filename-only-absolute-compdir.c lldb/test/Shell/SymbolFile/DWARF/dwo-debug-file-search-paths-filename-only-relative-compdir.c lldb/test/Shell/SymbolFile/DWARF/dwo-debug-file-search-paths-relative-compdir.c lldb/test/Shell/SymbolFile/DWARF/dwo-relative-filename-only-binary-dir.c ################################################################################ diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index 04c729e333a9854..0ef4b6e72fa0769 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -1728,120 +1728,34 @@ SymbolFileDWARF::GetDwoSymbolFileForCompileUnit( if (std::shared_ptr<SymbolFileDWARFDwo> dwp_sp = GetDwpSymbolFile()) return dwp_sp; + const char *comp_dir = nullptr; FileSpec dwo_file(dwo_name); FileSystem::Instance().Resolve(dwo_file); - bool found = false; - - const FileSpecList &debug_file_search_paths = - Target::GetDefaultDebugFileSearchPaths(); - size_t num_search_paths = debug_file_search_paths.GetSize(); - - // It's relative, e.g. "foo.dwo", but we just to happen to be right next to - // it. Or it's absolute. - found = FileSystem::Instance().Exists(dwo_file); - - if (!found) { - // It could be a relative path that also uses DW_AT_COMP_DIR. - const char *comp_dir = - cu_die.GetAttributeValueAsString(dwarf_cu, DW_AT_comp_dir, nullptr); - - if (comp_dir) { - dwo_file.SetFile(comp_dir, FileSpec::Style::native); - if (!dwo_file.IsRelative()) { - FileSystem::Instance().Resolve(dwo_file); - dwo_file.AppendPathComponent(dwo_name); - found = FileSystem::Instance().Exists(dwo_file); - } else { - FileSpecList dwo_paths; - - // if DW_AT_comp_dir is relative, it should be relative to the location - // of the executable, not to the location from which the debugger was - // launched. - FileSpec relative_to_binary = dwo_file; - relative_to_binary.PrependPathComponent( - m_objfile_sp->GetFileSpec().GetDirectory().GetStringRef()); - FileSystem::Instance().Resolve(relative_to_binary); - relative_to_binary.AppendPathComponent(dwo_name); - dwo_paths.Append(relative_to_binary); - - // Or it's relative to one of the user specified debug directories. - for (size_t idx = 0; idx < num_search_paths; ++idx) { - FileSpec dirspec = debug_file_search_paths.GetFileSpecAtIndex(idx); - dirspec.AppendPathComponent(comp_dir); - FileSystem::Instance().Resolve(dirspec); - if (!FileSystem::Instance().IsDirectory(dirspec)) - continue; - - dirspec.AppendPathComponent(dwo_name); - dwo_paths.Append(dirspec); - } - - size_t num_possible = dwo_paths.GetSize(); - for (size_t idx = 0; idx < num_possible && !found; ++idx) { - FileSpec dwo_spec = dwo_paths.GetFileSpecAtIndex(idx); - if (FileSystem::Instance().Exists(dwo_spec)) { - dwo_file = dwo_spec; - found = true; - } - } - } - } else { - Log *log = GetLog(LLDBLog::Symbols); - LLDB_LOGF(log, - "unable to locate relative .dwo debug file \"%s\" for " - "skeleton DIE 0x%016" PRIx64 " without valid DW_AT_comp_dir " - "attribute", - dwo_name, cu_die.GetOffset()); + if (dwo_file.IsRelative()) { + comp_dir = cu_die.GetAttributeValueAsString(dwarf_cu, DW_AT_comp_dir, + nullptr); + if (!comp_dir) { + unit.SetDwoError(Status::createWithFormat( + "unable to locate relative .dwo debug file \"{0}\" for " + "skeleton DIE {1:x16} without valid DW_AT_comp_dir " + "attribute", + dwo_name, cu_die.GetOffset())); + return nullptr; } - } - if (!found) { - // Try adding the DW_AT_dwo_name ( e.g. "c/d/main-main.dwo"), and just the - // filename ("main-main.dwo") to binary dir and search paths. - FileSpecList dwo_paths; - FileSpec dwo_name_spec(dwo_name); - llvm::StringRef filename_only = dwo_name_spec.GetFilename(); - - FileSpec binary_directory( - m_objfile_sp->GetFileSpec().GetDirectory().GetStringRef()); - FileSystem::Instance().Resolve(binary_directory); - - if (dwo_name_spec.IsRelative()) { - FileSpec dwo_name_binary_directory(binary_directory); - dwo_name_binary_directory.AppendPathComponent(dwo_name); - dwo_paths.Append(dwo_name_binary_directory); - } - - FileSpec filename_binary_directory(binary_directory); - filename_binary_directory.AppendPathComponent(filename_only); - dwo_paths.Append(filename_binary_directory); - - for (size_t idx = 0; idx < num_search_paths; ++idx) { - FileSpec dirspec = debug_file_search_paths.GetFileSpecAtIndex(idx); - FileSystem::Instance().Resolve(dirspec); - if (!FileSystem::Instance().IsDirectory(dirspec)) - continue; - - FileSpec dwo_name_dirspec(dirspec); - dwo_name_dirspec.AppendPathComponent(dwo_name); - dwo_paths.Append(dwo_name_dirspec); - - FileSpec filename_dirspec(dirspec); - filename_dirspec.AppendPathComponent(filename_only); - dwo_paths.Append(filename_dirspec); - } - - size_t num_possible = dwo_paths.GetSize(); - for (size_t idx = 0; idx < num_possible && !found; ++idx) { - FileSpec dwo_spec = dwo_paths.GetFileSpecAtIndex(idx); - if (FileSystem::Instance().Exists(dwo_spec)) { - dwo_file = dwo_spec; - found = true; - } + dwo_file.SetFile(comp_dir, FileSpec::Style::native); + if (dwo_file.IsRelative()) { + // if DW_AT_comp_dir is relative, it should be relative to the location + // of the executable, not to the location from which the debugger was + // launched. + dwo_file.PrependPathComponent( + m_objfile_sp->GetFileSpec().GetDirectory().GetStringRef()); } + FileSystem::Instance().Resolve(dwo_file); + dwo_file.AppendPathComponent(dwo_name); } - if (!found) { + if (!FileSystem::Instance().Exists(dwo_file)) { unit.SetDwoError(Status::createWithFormat( "unable to locate .dwo debug file \"{0}\" for skeleton DIE " "{1:x16}", diff --git a/lldb/test/Shell/SymbolFile/DWARF/dwo-debug-file-search-path-symlink-relative-compdir.c b/lldb/test/Shell/SymbolFile/DWARF/dwo-debug-file-search-path-symlink-relative-compdir.c deleted file mode 100644 index e5d7c1f65fc4d4f..000000000000000 --- a/lldb/test/Shell/SymbolFile/DWARF/dwo-debug-file-search-path-symlink-relative-compdir.c +++ /dev/null @@ -1,30 +0,0 @@ -/// Check that LLDB uses the paths in target.debug-file-search-paths to find -/// split DWARF files with a relative DW_AT_comp_dir set, when the program file -/// has been moved and/or we're executing it from another directory. Even when -/// the provided search path is actually a symlink to the real location. -// UNSUPPORTED: system-windows -// RUN: rm -rf %t.compdir/ %t.e/ -// RUN: mkdir -p %t.compdir/a/b/c/d/ -// RUN: cp %s %t.compdir/a/b/c/d/main.c -// RUN: cd %t.compdir/a/b/ -/// The produced DWO is named c/d/main-main.dwo, with a DW_AT_comp_dir of a/b. -// RUN: %clang_host -g -gsplit-dwarf -fdebug-prefix-map=%t.compdir=. c/d/main.c -o c/d/main -// RUN: cd ../../.. -/// Move only the program, leaving the DWO file in place. -// RUN: mv %t.compdir/a/b/c/d/main %t.compdir/a/ -/// Create a symlink to the compliation dir, to use instead of the real path. -// RUN: ln -s %t.compdir %t.symlink_to_compdir -/// Debug it from yet another path. -// RUN: mkdir -p %t.e/ -// RUN: cd %t.e -/// DWO should be found by following using symlink + a/b/ + c/d/main-main.dwo. -// RUN: %lldb --no-lldbinit %t.compdir/a/main \ -// RUN: -O "settings append target.debug-file-search-paths %t.symlink_to_compdir" \ -// RUN: -o "b main" -o "run" -o "p num" --batch 2>&1 | FileCheck %s - -// CHECK-NOT: warning: {{.*}}main unable to locate separate debug file (dwo, dwp). Debugging will be degraded. -// CHECK: (int) 5 - -int num = 5; - -int main(void) { return 0; } diff --git a/lldb/test/Shell/SymbolFile/DWARF/dwo-debug-file-search-paths-dwoname-absolute-compdir.c b/lldb/test/Shell/SymbolFile/DWARF/dwo-debug-file-search-paths-dwoname-absolute-compdir.c deleted file mode 100644 index 01a8cdf461909e7..000000000000000 --- a/lldb/test/Shell/SymbolFile/DWARF/dwo-debug-file-search-paths-dwoname-absolute-compdir.c +++ /dev/null @@ -1,32 +0,0 @@ -/// Check that LLDB uses the paths in target.debug-file-search-paths to find -/// split DWARF files with DW_AT_comp_dir set to some absolute path, when -/// the program file and DWO have been moved and/or we're executing from -/// another directory. Specifically when the DWO has been moved to another -/// directory but is still at it's name. Here, %t.compdir/c/d/main-main.dwo. -// RUN: rm -rf %t.compdir/ %t.e/ -// RUN: mkdir -p %t.compdir/a/b/c/d/ -// RUN: cp %s %t.compdir/a/b/c/d/main.c -// RUN: cd %t.compdir/a/b/ -/// The produced DWO is named c/d/main-main.dwo, with a non-relative -/// DW_AT_comp_dir of <pathtobuild>/a/b -// RUN: %clang_host -g -gsplit-dwarf c/d/main.c -o c/d/main -// RUN: cd ../../.. -/// Move the program. -// RUN: mv %t.compdir/a/b/c/d/main %t.compdir/a/ -/// Move the DWO but keep it at the path in in its name. -// RUN: mkdir -p %t.compdir/c/d/ -// RUN: mv %t.compdir/a/b/c/d/*.dwo %t.compdir/c/d/ -/// Debug it from yet another path. -// RUN: mkdir -p %t.e/ -// RUN: cd %t.e -/// LLDB should find in %t.compdir. -// RUN: %lldb --no-lldbinit %t.compdir/a/main \ -// RUN: -O "settings append target.debug-file-search-paths %t.compdir" \ -// RUN: -o "b main" -o "run" -o "p num" --batch 2>&1 | FileCheck %s - -// CHECK-NOT: warning: {{.*}}main unable to locate separate debug file (dwo, dwp). Debugging will be degraded. -// CHECK: (int) 5 - -int num = 5; - -int main(void) { return 0; } \ No newline at end of file diff --git a/lldb/test/Shell/SymbolFile/DWARF/dwo-debug-file-search-paths-filename-only-absolute-compdir.c b/lldb/test/Shell/SymbolFile/DWARF/dwo-debug-file-search-paths-filename-only-absolute-compdir.c deleted file mode 100644 index f47889cd443d7bf..000000000000000 --- a/lldb/test/Shell/SymbolFile/DWARF/dwo-debug-file-search-paths-filename-only-absolute-compdir.c +++ /dev/null @@ -1,31 +0,0 @@ -/// Check that LLDB uses the paths in target.debug-file-search-paths to find -/// split DWARF files with DW_AT_comp_dir set to some non-relative path, when -/// the program file and DWO have been moved and/or we're executing from another -/// directory. Specifically when the DWO is not at it's "name", here we move -/// it to %t.compdir/main-main.dwo and it's name is c/d/main-main.dwo. -// RUN: rm -rf %t.compdir/ %t.e/ -// RUN: mkdir -p %t.compdir/a/b/c/d/ -// RUN: cp %s %t.compdir/a/b/c/d/main.c -// RUN: cd %t.compdir/a/b/ -/// The produced DWO is named c/d/main-main.dwo, with a non-relative -/// DW_AT_comp_dir of <pathtobuild>/a/b -// RUN: %clang_host -g -gsplit-dwarf c/d/main.c -o c/d/main -// RUN: cd ../../.. -/// Move the program. -// RUN: mv %t.compdir/a/b/c/d/main %t.compdir/a/ -/// Move the DWO. -// RUN: mv %t.compdir/a/b/c/d/*.dwo %t.compdir -/// Debug it from yet another path. -// RUN: mkdir -p %t.e/ -// RUN: cd %t.e -/// LLDB should find in %t.compdir. -// RUN: %lldb --no-lldbinit %t.compdir/a/main \ -// RUN: -O "settings append target.debug-file-search-paths %t.compdir" \ -// RUN: -o "b main" -o "run" -o "p num" --batch 2>&1 | FileCheck %s - -// CHECK-NOT: warning: {{.*}}main unable to locate separate debug file (dwo, dwp). Debugging will be degraded. -// CHECK: (int) 5 - -int num = 5; - -int main(void) { return 0; } \ No newline at end of file diff --git a/lldb/test/Shell/SymbolFile/DWARF/dwo-debug-file-search-paths-filename-only-relative-compdir.c b/lldb/test/Shell/SymbolFile/DWARF/dwo-debug-file-search-paths-filename-only-relative-compdir.c deleted file mode 100644 index 07befc450dc7650..000000000000000 --- a/lldb/test/Shell/SymbolFile/DWARF/dwo-debug-file-search-paths-filename-only-relative-compdir.c +++ /dev/null @@ -1,26 +0,0 @@ -/// Check that when LLDB is looking for a relative DWO it uses the debug search -/// paths setting. If it doesn't find it by adding the whole relative path to -/// of DWO it should try adding just the filename (e.g. main.dwo) to each debug -/// search path. -// RUN: rm -rf %t.compdir/ -// RUN: mkdir -p %t.compdir/a/b/ -// RUN: cp %s %t.compdir/a/b/main.c -// RUN: cd %t.compdir/a/ -/// The produced DWO is named /b/main-main.dwo, with a DW_AT_comp_dir of a/. -// RUN: %clang_host -g -gsplit-dwarf -fdebug-prefix-map=%t.compdir=. b/main.c -o b/main -// RUN: cd ../.. -/// Move the DWO file away from the expected location. -// RUN: mv %t.compdir/a/b/*.dwo %t.compdir/ -/// LLDB won't find the DWO next to the binary or by adding the relative path -/// to any of the search paths. So it should find the DWO file at -/// %t.compdir/main-main.dwo. -// RUN: %lldb --no-lldbinit %t.compdir/a/b/main \ -// RUN: -O "settings append target.debug-file-search-paths %t.compdir" \ -// RUN: -o "b main" -o "run" -o "p num" --batch 2>&1 | FileCheck %s - -// CHECK-NOT: warning: {{.*}}main unable to locate separate debug file (dwo, dwp). Debugging will be degraded. -// CHECK: (int) 5 - -int num = 5; - -int main(void) { return 0; } \ No newline at end of file diff --git a/lldb/test/Shell/SymbolFile/DWARF/dwo-debug-file-search-paths-relative-compdir.c b/lldb/test/Shell/SymbolFile/DWARF/dwo-debug-file-search-paths-relative-compdir.c deleted file mode 100644 index af75877cfb318f1..000000000000000 --- a/lldb/test/Shell/SymbolFile/DWARF/dwo-debug-file-search-paths-relative-compdir.c +++ /dev/null @@ -1,27 +0,0 @@ -/// Check that LLDB uses the paths in target.debug-file-search-paths to find -/// split DWARF files with a relative DW_AT_comp_dir set, when the program file -/// has been moved and/or we're executing it from another directory. -// RUN: rm -rf %t.compdir/ %t.e/ -// RUN: mkdir -p %t.compdir/a/b/c/d/ -// RUN: cp %s %t.compdir/a/b/c/d/main.c -// RUN: cd %t.compdir/a/b/ -/// The produced DWO is named c/d/main-main.dwo, with a DW_AT_comp_dir of a/b. -// RUN: %clang_host -g -gsplit-dwarf -fdebug-prefix-map=%t.compdir=. c/d/main.c -o c/d/main -// RUN: cd ../../.. -/// Move only the program, leaving the DWO file in place. -// RUN: mv %t.compdir/a/b/c/d/main %t.compdir/a/ -/// Debug it from yet another path. -// RUN: mkdir -p %t.e/ -// RUN: cd %t.e -/// LLDB won't find the DWO next to the binary or in the current dir, so it -/// should find the DWO file by doing %t.compdir/ + a/b/ + c/d/main-main.dwo. -// RUN: %lldb --no-lldbinit %t.compdir/a/main \ -// RUN: -O "settings append target.debug-file-search-paths %t.compdir" \ -// RUN: -o "b main" -o "run" -o "p num" --batch 2>&1 | FileCheck %s - -// CHECK-NOT: warning: {{.*}}main unable to locate separate debug file (dwo, dwp). Debugging will be degraded. -// CHECK: (int) 5 - -int num = 5; - -int main(void) { return 0; } diff --git a/lldb/test/Shell/SymbolFile/DWARF/dwo-relative-filename-only-binary-dir.c b/lldb/test/Shell/SymbolFile/DWARF/dwo-relative-filename-only-binary-dir.c deleted file mode 100644 index a08b5a6733c9d0a..000000000000000 --- a/lldb/test/Shell/SymbolFile/DWARF/dwo-relative-filename-only-binary-dir.c +++ /dev/null @@ -1,21 +0,0 @@ -/// Check that LLDB can find a relative DWO file next to a binary just using the -/// filename of that DWO. For example "main.dwo" not "a/b/main.dwo". -// RUN: rm -rf %t.compdir/ -// RUN: mkdir -p %t.compdir/a/b/ -// RUN: cp %s %t.compdir/a/b/main.c -// RUN: cd %t.compdir/a/ -/// The produced DWO is named b/main-main.dwo, with a DW_AT_comp_dir of a/. -// RUN: %clang_host -g -gsplit-dwarf -fdebug-prefix-map=%t.compdir=. b/main.c -o b/main -// RUN: cd ../.. -/// Move binary and DWO out of expected locations. -// RUN: mv %t.compdir/a/b/main %t.compdir/ -// RUN: mv %t.compdir/a/b/*.dwo %t.compdir/ -// RUN: %lldb --no-lldbinit %t.compdir/main \ -// RUN: -o "b main" -o "run" -o "p num" --batch 2>&1 | FileCheck %s - -// CHECK-NOT: warning: {{.*}}main unable to locate separate debug file (dwo, dwp). Debugging will be degraded. -// CHECK: (int) 5 - -int num = 5; - -int main(void) { return 0; } \ No newline at end of file _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits