[Lldb-commits] [PATCH] D56543: DWARF: Add some support for non-native directory separators

Greg Clayton via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Jan 10 10:25:58 PST 2019

clayborg requested changes to this revision.
clayborg added a comment.
This revision now requires changes to proceed.

DW_AT_comp_dir isn't enough. See inline suggestions.

Comment at: source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp:775-787
+void DWARFUnit::ComputePathStyle() {
+  m_path_style = FileSpec::Style::native;
+  const DWARFDebugInfoEntry *die = GetUnitDIEPtrOnly();
+  if (!die)
+    return;
+  llvm::StringRef comp_dir =
+      die->GetAttributeValueAsString(m_dwarf, this, DW_AT_comp_dir, NULL);
I would suggest adding a "FileSpec DWARFUnit::GetFileSpec()" and moving code from SymbolFileDWARF::ParseCompileUnit into this function:
            FileSpec cu_file_spec(cu_die.GetName());
            if (cu_file_spec) {
              // If we have a full path to the compile unit, we don't need to
              // resolve the file.  This can be expensive e.g. when the source
              // files are
              // NFS mounted.
              if (cu_file_spec.IsRelative()) {
                const char *cu_comp_dir{
                    cu_die.GetAttributeValueAsString(DW_AT_comp_dir, nullptr)};

We might even cache the FileSpec object inside DWARFUnit so it doesn't have to be recomputed? 

Then use this resolved path. DW_AT_comp_dir isn't always there, sometimes the DW_AT_name is a full path only. So we should centralize this in DWARFUnit. We might want to make a function like:

void DWARFUnit::ResolveCompileUnitDirectoryRelativeFile(FileSpec &spec);

And then have "FileSpec DWARFUnit::GetFileSpec()" call it. I was looking at the other uses of DW_AT_comp_dir in the source, and the line tables tend to need to resolve relative paths. A few other locations. Might be nice to get the DWARFUnit and resolve the path using that? We can add "FileSpec DWARFDie::GetPath()" accessor, could even add a "void DWARFDie::ResolveRelativePath(FileSpec &)"



More information about the lldb-commits mailing list