[Lldb-commits] [lldb] r368879 - [DebugLine] Improve path handling.

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Wed Aug 14 10:00:11 PDT 2019


Author: jdevlieghere
Date: Wed Aug 14 10:00:10 2019
New Revision: 368879

URL: http://llvm.org/viewvc/llvm-project?rev=368879&view=rev
Log:
[DebugLine] Improve path handling.

After switching over LLDB's line table parser to libDebugInfo, we
noticed two regressions on the Windows bot. The problem is that when
obtaining a file from the line table prologue, we append paths without
specifying a path style. This leads to incorrect results on Windows for
debug info containing Posix paths:

  0x0000000000201000: /tmp\b.c, is_start_of_statement = TRUE

This patch is an attempt to fix that by guessing the path style whenever
possible.

Differential revision: https://reviews.llvm.org/D66227

Modified:
    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=368879&r1=368878&r2=368879&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Wed Aug 14 10:00:10 2019
@@ -178,6 +178,11 @@ ParseLLVMLineTable(lldb_private::DWARFCo
   return *line_table;
 }
 
+static FileSpec::Style GuessPathStyleOrNative(llvm::StringRef p) {
+  llvm::Optional<FileSpec::Style> style = FileSpec::GuessPathStyle(p);
+  return style ? *style : FileSpec::Style::native;
+}
+
 static FileSpecList
 ParseSupportFilesFromPrologue(const lldb::ModuleSP &module,
                               const llvm::DWARFDebugLine::Prologue &prologue,
@@ -186,8 +191,6 @@ ParseSupportFilesFromPrologue(const lldb
   FileSpecList support_files;
   support_files.Append(first_file);
 
-  llvm::Optional<FileSpec::Style> compile_dir_style =
-      FileSpec::GuessPathStyle(compile_dir);
   const size_t number_of_files = prologue.FileNames.size();
   for (size_t idx = 1; idx <= number_of_files; ++idx) {
     std::string original_file;
@@ -200,26 +203,22 @@ ParseSupportFilesFromPrologue(const lldb
       continue;
     }
 
-    FileSpec::Style style = FileSpec::Style::native;
-    if (compile_dir_style) {
-      style = *compile_dir_style;
-    } else if (llvm::Optional<FileSpec::Style> file_style =
-                   FileSpec::GuessPathStyle(original_file)) {
-      style = *file_style;
-    }
-
     std::string remapped_file;
     if (!prologue.getFileNameByIndex(
             idx, compile_dir,
             llvm::DILineInfoSpecifier::FileLineInfoKind::AbsoluteFilePath,
             remapped_file)) {
       // Always add an entry so the indexes remain correct.
-      support_files.EmplaceBack(original_file, style);
+      support_files.EmplaceBack(original_file,
+                                FileSpec::GuessPathStyle(original_file)
+                                    .getValueOr(FileSpec::Style::native));
       continue;
     }
 
     module->RemapSourceFile(llvm::StringRef(original_file), remapped_file);
-    support_files.EmplaceBack(remapped_file, style);
+    support_files.EmplaceBack(remapped_file,
+                              FileSpec::GuessPathStyle(remapped_file)
+                                  .getValueOr(FileSpec::Style::native));
   }
 
   return support_files;




More information about the lldb-commits mailing list