summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/SymbolFile
diff options
context:
space:
mode:
authorPavel Labath <pavel@labath.sk>2019-12-20 16:34:55 +0100
committerPavel Labath <pavel@labath.sk>2019-12-23 11:24:04 +0100
commit3cfb6677b2aa20f782d9bb0f7958e61f5a976c16 (patch)
tree3214335185ad6290742e3e4cf02296bdda33cf49 /lldb/source/Plugins/SymbolFile
parent2cebc1a7170fc6c0ff3d15e677a59582450eb81d (diff)
downloadbcm5719-llvm-3cfb6677b2aa20f782d9bb0f7958e61f5a976c16.tar.gz
bcm5719-llvm-3cfb6677b2aa20f782d9bb0f7958e61f5a976c16.zip
[lldb] Don't process symlinks deep inside DWARFUnit
Summary: This code is handling debug info paths starting with /proc/self/cwd, which is one of the mechanisms people use to obtain "relocatable" debug info (the idea being that one starts the debugger with an appropriate cwd and things "just work"). Instead of resolving the symlinks inside DWARFUnit, we can do the same thing more elegantly by hooking into the existing Module path remapping code. Since llvm::DWARFUnit does not support any similar functionality, doing things this way is also a step towards unifying llvm and lldb dwarf parsers. Reviewers: JDevlieghere, aprantl, clayborg, jdoerfert Subscribers: lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D71770
Diffstat (limited to 'lldb/source/Plugins/SymbolFile')
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp21
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp11
2 files changed, 12 insertions, 20 deletions
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
index a7df540ba56..fde6459b2c6 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -732,25 +732,6 @@ 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();
@@ -762,7 +743,7 @@ void DWARFUnit::ComputeCompDirAndGuessPathStyle() {
if (!comp_dir.empty()) {
FileSpec::Style comp_dir_style =
FileSpec::GuessPathStyle(comp_dir).getValueOr(FileSpec::Style::native);
- m_comp_dir = resolveCompDir(FileSpec(comp_dir, comp_dir_style));
+ m_comp_dir = 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 466d5ddd23d..9021cda4941 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -453,6 +453,17 @@ 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);
OpenPOWER on IntegriCloud