[Lldb-commits] [lldb] ebcb36d - Revert "[lldb] Don't process symlinks deep inside DWARFUnit"
Jonas Devlieghere via lldb-commits
lldb-commits at lists.llvm.org
Mon Dec 23 18:09:37 PST 2019
Author: Jonas Devlieghere
Date: 2019-12-23T18:04:29-08:00
New Revision: ebcb36d4a1387e771fb49d1f6379cb5774373a5a
URL: https://github.com/llvm/llvm-project/commit/ebcb36d4a1387e771fb49d1f6379cb5774373a5a
DIFF: https://github.com/llvm/llvm-project/commit/ebcb36d4a1387e771fb49d1f6379cb5774373a5a.diff
LOG: Revert "[lldb] Don't process symlinks deep inside DWARFUnit"
This temporarily reverts commit 3cfb6677b2aa20f782d9bb0f7958e61f5a976c16
because it breaks TestCompDirSymLink.py on macOS.
Added:
Modified:
lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
Removed:
################################################################################
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
index b71595b1448d..d8d70bae0232 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -716,6 +716,25 @@ removeHostnameFromPathname(llvm::StringRef path_from_dwarf) {
return path;
}
+static FileSpec resolveCompDir(const FileSpec &path) {
+ bool is_symlink = SymbolFileDWARF::GetSymlinkPaths().FindFileIndex(
+ 0, path, /*full*/ true) != UINT32_MAX;
+
+ if (!is_symlink)
+ return path;
+
+ namespace fs = llvm::sys::fs;
+ if (fs::get_file_type(path.GetPath(), false) != fs::file_type::symlink_file)
+ return path;
+
+ FileSpec resolved_symlink;
+ const auto error = FileSystem::Instance().Readlink(path, resolved_symlink);
+ if (error.Success())
+ return resolved_symlink;
+
+ return path;
+}
+
void DWARFUnit::ComputeCompDirAndGuessPathStyle() {
m_comp_dir = FileSpec();
const DWARFDebugInfoEntry *die = GetUnitDIEPtrOnly();
@@ -727,7 +746,7 @@ void DWARFUnit::ComputeCompDirAndGuessPathStyle() {
if (!comp_dir.empty()) {
FileSpec::Style comp_dir_style =
FileSpec::GuessPathStyle(comp_dir).getValueOr(FileSpec::Style::native);
- m_comp_dir = FileSpec(comp_dir, comp_dir_style);
+ m_comp_dir = resolveCompDir(FileSpec(comp_dir, comp_dir_style));
} else {
// Try to detect the style based on the DW_AT_name attribute, but just store
// the detected style in the m_comp_dir field.
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 96073f31f538..53339ea31e71 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -453,17 +453,6 @@ SymbolFileDWARF::GetTypeSystemForLanguage(LanguageType language) {
void SymbolFileDWARF::InitializeObject() {
Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO);
- Module &module = *GetObjectFile()->GetModule();
-
- for (const FileSpec &symlink : GetSymlinkPaths()) {
- FileSpec resolved;
- Status status = FileSystem::Instance().Readlink(symlink, resolved);
- if (status.Success())
- module.GetSourceMappingList().Append(ConstString(symlink.GetPath()),
- ConstString(resolved.GetPath()),
- /*notify=*/true);
- }
-
if (!GetGlobalPluginProperties()->IgnoreFileIndexes()) {
DWARFDataExtractor apple_names, apple_namespaces, apple_types, apple_objc;
LoadSectionData(eSectionTypeDWARFAppleNames, apple_names);
More information about the lldb-commits
mailing list