Author: Zequan Wu
Date: 2022-06-13T12:04:25-07:00
New Revision: 3222f95ea8c4de153f908c138cdec178e22acaf4

URL: 
https://github.com/llvm/llvm-project/commit/3222f95ea8c4de153f908c138cdec178e22acaf4
DIFF: 
https://github.com/llvm/llvm-project/commit/3222f95ea8c4de153f908c138cdec178e22acaf4.diff

LOG: [LLDB][NativePDB] Convert backslash to slash when creating CU and filter 
out CU with no function in ResolveSymbolContext.

On Windows, when compile with -fdebug-compilation-dir which contains slash, the 
source file path in PDB will look like "../tmp\file.cc" because the path 
separator used is determined by target machine. Converting backslash to slash 
helps lldb to find the CU in ResolveSymbolContext.

We want to filter out CU with no function in ResolveSymbolContext as a cpp file 
will have two debug info modules in PDB if built with thinlto and one of them 
is a skeleton with no function debug info.

Added: 
    

Modified: 
    lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp 
b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
index 18fd7efb93e82..5c98ac38de6f7 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
@@ -449,7 +449,8 @@ SymbolFileNativePDB::CreateCompileUnit(const 
CompilandIndexItem &cci) {
 
   llvm::SmallString<64> source_file_name =
       m_index->compilands().GetMainSourceFile(cci);
-  FileSpec fs(source_file_name);
+  FileSpec fs(llvm::sys::path::convert_to_slash(
+      source_file_name, llvm::sys::path::Style::windows_backslash));
 
   CompUnitSP cu_sp =
       std::make_shared<CompileUnit>(m_objfile_sp->GetModule(), nullptr, fs,
@@ -1051,7 +1052,7 @@ uint32_t SymbolFileNativePDB::ResolveSymbolContext(
     for (uint32_t cu_idx = 0, num_cus = GetNumCompileUnits(); cu_idx < num_cus;
          ++cu_idx) {
       CompileUnit *cu = ParseCompileUnitAtIndex(cu_idx).get();
-      if (!cu)
+      if (!cu && cu->GetNumFunctions() != 0)
         continue;
 
       bool file_spec_matches_cu_file_spec = FileSpec::Match(


        
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to