[PATCH] D84278: DebugInfo: Use debug_line.dwo for debug_macro.dwo

David Blaikie via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 22 14:07:09 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rG5c2451785dfe: DebugInfo: Use debug_line.dwo for debug_macro.dwo (authored by dblaikie).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84278

Files:
  llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
  llvm/test/DebugInfo/X86/debug-macro-dwo.ll


Index: llvm/test/DebugInfo/X86/debug-macro-dwo.ll
===================================================================
--- llvm/test/DebugInfo/X86/debug-macro-dwo.ll
+++ llvm/test/DebugInfo/X86/debug-macro-dwo.ll
@@ -2,26 +2,34 @@
 ; -gdwarf-5 -gsplit-dwarf -fdebug-macro is specified.
 
 ; RUN: %llc_dwarf -dwarf-version=5 -O0 -filetype=obj \
-; RUN: -split-dwarf-file=foo.dwo < %s | llvm-dwarfdump -v - | FileCheck %s
+; RUN: -split-dwarf-file=foo.dwo < %s | llvm-dwarfdump -debug-macro -debug-info -debug-line -v - | FileCheck %s
 
 ; CHECK-LABEL:  .debug_info contents:
 ; CHECK: DW_AT_macros [DW_FORM_sec_offset] (0x00000000)
 
 ; CHECK-LABEL:  .debug_macro.dwo contents:
 ; CHECK-NEXT: 0x00000000:
-; CHECK-NEXT: macro header: version = 0x0005, flags = 0x02, format = DWARF32
+; CHECK-NEXT: macro header: version = 0x0005, flags = 0x02, format = DWARF32, debug_line_offset = 0x00000000
 ; CHECK-NEXT: DW_MACRO_start_file - lineno: 0 filenum: 0
-; FIXME: This should be filenum 1 (and 2 below) if this was using debug_loc.dwo
-;        (rather than currently incorrectly using debug_loc)
-; CHECK-NEXT:   DW_MACRO_start_file - lineno: 1 filenum: 2
+; CHECK-NEXT:   DW_MACRO_start_file - lineno: 1 filenum: 1
 ; CHECK-NEXT:     DW_MACRO_define_strx - lineno: 1 macro: FOO 5
 ; CHECK-NEXT:   DW_MACRO_end_file
-; CHECK-NEXT:   DW_MACRO_start_file - lineno: 2 filenum: 3
+; CHECK-NEXT:   DW_MACRO_start_file - lineno: 2 filenum: 2
 ; CHECK-NEXT:     DW_MACRO_undef_strx - lineno: 14 macro: YEA
 ; CHECK-NEXT:   DW_MACRO_end_file
 ; CHECK-NEXT:   DW_MACRO_undef_strx - lineno: 14 macro: YEA
 ; CHECK-NEXT: DW_MACRO_end_file
 
+; CHECK-LABEL: .debug_line.dwo contents:
+; CHECK: file_names[  0]:
+; CHECK:            name: "test.c"
+; CHECK: file_names[  1]:
+; CHECK:            name: "foo.h"
+; CHECK: file_names[  2]:
+; CHECK:            name: "bar.h"
+
+
+
 ; ModuleID = 'test.c'
 source_filename = "test.c"
 target datalayout = "e-m:e-p200:32:32-p201:32:32-p202:64:64-i64:64-f80:128-n8:16:32:64-S128"
Index: llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -3000,7 +3000,10 @@
   Asm->OutStreamer->AddComment("Flags: 32 bit, debug_line_offset present");
   Asm->emitInt8(Flags);
   Asm->OutStreamer->AddComment("debug_line_offset");
-  Asm->OutStreamer->emitSymbolValue(CU.getLineTableStartSym(), /*Size=*/4);
+  if (DD.useSplitDwarf())
+    Asm->OutStreamer->emitIntValue(0, /*Size=*/4);
+  else
+    Asm->OutStreamer->emitSymbolValue(CU.getLineTableStartSym(), /*Size=*/4);
 }
 
 void DwarfDebug::handleMacroNodes(DIMacroNodeArray Nodes, DwarfCompileUnit &U) {
@@ -3056,16 +3059,22 @@
 }
 
 void DwarfDebug::emitMacroFileImpl(
-    DIMacroFile &F, DwarfCompileUnit &U, unsigned StartFile, unsigned EndFile,
+    DIMacroFile &MF, DwarfCompileUnit &U, unsigned StartFile, unsigned EndFile,
     StringRef (*MacroFormToString)(unsigned Form)) {
 
   Asm->OutStreamer->AddComment(MacroFormToString(StartFile));
   Asm->emitULEB128(StartFile);
   Asm->OutStreamer->AddComment("Line Number");
-  Asm->emitULEB128(F.getLine());
+  Asm->emitULEB128(MF.getLine());
   Asm->OutStreamer->AddComment("File Number");
-  Asm->emitULEB128(U.getOrCreateSourceID(F.getFile()));
-  handleMacroNodes(F.getElements(), U);
+  DIFile &F = *MF.getFile();
+  if (useSplitDwarf())
+    Asm->emitULEB128(getDwoLineTable(U)->getFile(
+        F.getDirectory(), F.getFilename(), getMD5AsBytes(&F),
+        Asm->OutContext.getDwarfVersion(), F.getSource()));
+  else
+    Asm->emitULEB128(U.getOrCreateSourceID(&F));
+  handleMacroNodes(MF.getElements(), U);
   Asm->OutStreamer->AddComment(MacroFormToString(EndFile));
   Asm->emitULEB128(EndFile);
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D84278.279940.patch
Type: text/x-patch
Size: 3791 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200722/0e8c174c/attachment.bin>


More information about the llvm-commits mailing list