[PATCH] D131804: [DebugInfo] Don't join DW_AT_comp_dir and directories[0] for DWARF v5 line tables

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 12 14:02:14 PDT 2022


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3329cec2f791: [DebugInfo] Don't join DW_AT_comp_dir and directories[0] for DWARF v5 lineā€¦ (authored by MaskRay).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D131804/new/

https://reviews.llvm.org/D131804

Files:
  llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
  llvm/test/DebugInfo/X86/symbolize_function_start_v5.s
  llvm/test/MC/ELF/debug-prefix-map.s


Index: llvm/test/MC/ELF/debug-prefix-map.s
===================================================================
--- llvm/test/MC/ELF/debug-prefix-map.s
+++ llvm/test/MC/ELF/debug-prefix-map.s
@@ -33,14 +33,12 @@
 
 # MAP_V5:      DW_AT_name [DW_FORM_string] ("src.s")
 # MAP_V5:      DW_AT_comp_dir [DW_FORM_string] ("src_root")
-## FIXME llvm-dwarfdump incorrectly joins include_directories[0] to DW_AT_comp_dir,
-## so there are two src_root path components.
-# MAP_V5:      DW_AT_decl_file [DW_FORM_data4] ("src_root{{(/|\\)+}}src_root{{(/|\\)+}}src.s")
+# MAP_V5:      DW_AT_decl_file [DW_FORM_data4] ("src_root{{(/|\\)+}}src.s")
 # MAP_V5:      include_directories[ 0] = .debug_line_str[0x00000000] = "src_root"
 
 # MAPABS_V4:      DW_AT_name [DW_FORM_string] ("src.s")
 # MAPABS_V4:      DW_AT_comp_dir [DW_FORM_string] ("{{(/|\\)+}}src_root")
-# MAPABS_V4:      DW_AT_decl_file [DW_FORM_data4] ("{{(/|\\)+}}src_root{{(/|\\)+}}src.s")
+# MAPABS_V4:      DW_AT_decl_file [DW_FORM_data4] ("/src_root{{(/|\\)+}}src.s")
 # MAPABS_V4-NOT:  .foo
 
 # MAPABS_V5:      DW_AT_name [DW_FORM_string] ("src.s")
Index: llvm/test/DebugInfo/X86/symbolize_function_start_v5.s
===================================================================
--- llvm/test/DebugInfo/X86/symbolize_function_start_v5.s
+++ llvm/test/DebugInfo/X86/symbolize_function_start_v5.s
@@ -5,8 +5,8 @@
 # RUN: llvm-symbolizer --verbose 0x0 --obj=test.o | FileCheck --check-prefix=SYM %s
 # RUN: llvm-dwarfdump -lookup=0x1 test.o | FileCheck --check-prefix=LOOKUP %s
 
-# SYM: Filename: .{{[/\\]}}.{{[/\\]}}test.c
-# SYM: Function start filename: .{{[/\\]}}.{{[/\\]}}test.c
+# SYM: Filename: .{{[/\\]}}test.c
+# SYM: Function start filename: .{{[/\\]}}test.c
 
 # LOOKUP: Line info: line 0, column 0, start file 'test.c', start line 1
 
Index: llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
===================================================================
--- llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
+++ llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
@@ -1382,10 +1382,12 @@
       IncludeDir = dwarf::toStringRef(IncludeDirectories[Entry.DirIdx - 1]);
   }
 
-  // For absolute paths only, include the compilation directory of compile unit.
-  // We know that FileName is not absolute, the only way to have an absolute
-  // path at this point would be if IncludeDir is absolute.
-  if (Kind == FileLineInfoKind::AbsoluteFilePath && !CompDir.empty() &&
+  // For absolute paths only, include the compilation directory of compile unit,
+  // unless v5 DirIdx == 0 (IncludeDir indicates the compilation directory). We
+  // know that FileName is not absolute, the only way to have an absolute path
+  // at this point would be if IncludeDir is absolute.
+  if (Kind == FileLineInfoKind::AbsoluteFilePath &&
+      (getVersion() < 5 || Entry.DirIdx != 0) && !CompDir.empty() &&
       !isPathAbsoluteOnWindowsOrPosix(IncludeDir))
     sys::path::append(FilePath, Style, CompDir);
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131804.452300.patch
Type: text/x-patch
Size: 2944 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220812/b425d6b2/attachment.bin>


More information about the llvm-commits mailing list