[Lldb-commits] [lldb] r327925 - [SymbolFilePDB] Simplify getting the source file path

Aaron Smith via lldb-commits lldb-commits at lists.llvm.org
Mon Mar 19 17:18:23 PDT 2018


Author: asmith
Date: Mon Mar 19 17:18:22 2018
New Revision: 327925

URL: http://llvm.org/viewvc/llvm-project?rev=327925&view=rev
Log:
[SymbolFilePDB] Simplify getting the source file path

Summary: Replace SymbolFilePDB::GetSourceFileNameForPDBCompiland() with PDBSymbolCompiland::getSourceFileFullPath().

Reviewers: zturner, rnk, lldb-commits

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D44456

Modified:
    lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
    lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h

Modified: lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp?rev=327925&r1=327924&r2=327925&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp Mon Mar 19 17:18:22 2018
@@ -614,59 +614,6 @@ SymbolFilePDB::ResolveSymbolContext(cons
   return resolved_flags;
 }
 
-std::string SymbolFilePDB::GetSourceFileNameForPDBCompiland(
-    const PDBSymbolCompiland *pdb_compiland) {
-  if (!pdb_compiland)
-    return std::string();
-
-  std::string source_file_name;
-  // `getSourceFileName` returns the basename of the original source file
-  // used to generate this compiland.  It does not return the full path.
-  // Currently the only way to get that is to do a basename lookup to get the
-  // IPDBSourceFile, but this is ambiguous in the case of two source files
-  // with the same name contributing to the same compiland. This is an edge
-  // case that we ignore for now, although we need to a long-term solution.
-  std::string file_name = pdb_compiland->getSourceFileName();
-  if (!file_name.empty()) {
-    auto one_src_file_up =
-        m_session_up->findOneSourceFile(pdb_compiland, file_name,
-                                        PDB_NameSearchFlags::NS_CaseInsensitive);
-    if (one_src_file_up)
-      source_file_name = one_src_file_up->getFileName();
-  }
-  // For some reason, source file name could be empty, so we will walk through
-  // all source files of this compiland, and determine the right source file
-  // if any that is used to generate this compiland based on language
-  // indicated in compilanddetails language field.
-  if (!source_file_name.empty())
-    return source_file_name;
-
-  auto details_up = pdb_compiland->findOneChild<PDBSymbolCompilandDetails>();
-  PDB_Lang pdb_lang = details_up ? details_up->getLanguage() : PDB_Lang::Cpp;
-  auto src_files_up =
-      m_session_up->getSourceFilesForCompiland(*pdb_compiland);
-  if (src_files_up) {
-    while (auto file_up = src_files_up->getNext()) {
-      FileSpec file_spec(file_up->getFileName(), false,
-                         FileSpec::ePathSyntaxWindows);
-      auto file_extension = file_spec.GetFileNameExtension();
-      if (pdb_lang == PDB_Lang::Cpp || pdb_lang == PDB_Lang::C) {
-        static const char* exts[] = { "cpp", "c", "cc", "cxx" };
-        if (llvm::is_contained(exts, file_extension.GetStringRef().lower())) {
-          source_file_name = file_up->getFileName();
-          break;
-        }
-      } else if (pdb_lang == PDB_Lang::Masm &&
-                 ConstString::Compare(file_extension, ConstString("ASM"),
-                                      false) == 0) {
-        source_file_name = file_up->getFileName();
-        break;
-      }
-    }
-  }
-  return source_file_name;
-}
-
 uint32_t SymbolFilePDB::ResolveSymbolContext(
     const lldb_private::FileSpec &file_spec, uint32_t line, bool check_inlines,
     uint32_t resolve_scope, lldb_private::SymbolContextList &sc_list) {
@@ -690,15 +637,7 @@ uint32_t SymbolFilePDB::ResolveSymbolCon
       // For inline functions, we don't have to match the FileSpec since they
       // could be defined in headers other than file specified in FileSpec.
       if (!check_inlines) {
-        // `getSourceFileName` returns the basename of the original source file
-        // used to generate this compiland.  It does not return the full path.
-        // Currently the only way to get that is to do a basename lookup to get
-        // the IPDBSourceFile, but this is ambiguous in the case of two source
-        // files with the same name contributing to the same compiland.  This is
-        // a moderately extreme edge case, so we consider this OK for now,
-        // although we need to find a long-term solution.
-        std::string source_file =
-            GetSourceFileNameForPDBCompiland(compiland.get());
+        std::string source_file = compiland->getSourceFileFullPath();
         if (source_file.empty())
           continue;
         FileSpec this_spec(source_file, false, FileSpec::ePathSyntaxWindows);
@@ -1284,7 +1223,7 @@ SymbolFilePDB::ParseCompileUnitForUID(ui
   if (lang == lldb::LanguageType::eLanguageTypeUnknown)
     return CompUnitSP();
 
-  std::string path = GetSourceFileNameForPDBCompiland(compiland_up.get());
+  std::string path = compiland_up->getSourceFileFullPath();
   if (path.empty())
     return CompUnitSP();
 

Modified: lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h?rev=327925&r1=327924&r2=327925&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h Mon Mar 19 17:18:22 2018
@@ -198,9 +198,6 @@ private:
   void GetCompileUnitIndex(const llvm::pdb::PDBSymbolCompiland &pdb_compiland,
                            uint32_t &index);
 
-  std::string GetSourceFileNameForPDBCompiland(
-      const llvm::pdb::PDBSymbolCompiland *pdb_compiland);
-
   std::unique_ptr<llvm::pdb::PDBSymbolCompiland>
   GetPDBCompilandByUID(uint32_t uid);
 




More information about the lldb-commits mailing list