[llvm] r358148 - [DWARF] Set discriminator to 0 for DW_LNS_copy

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 10 19:02:44 PDT 2019


Author: maskray
Date: Wed Apr 10 19:02:44 2019
New Revision: 358148

URL: http://llvm.org/viewvc/llvm-project?rev=358148&view=rev
Log:
[DWARF] Set discriminator to 0 for DW_LNS_copy

Summary:
Make DW_LNS_copy set the discriminator register to 0, to conform to
DWARF 4 & 5: "Then it sets the discriminator register to 0, and sets the
basic_block, prologue_end and epilogue_begin registers to false."

Because all of DW_LNE_end_sequence, DN_LNS_copy, and special opcodes reset
discriminator to 0, we can move discriminator=0 to appendRowToMatrix.

Also, make DW_LNS_copy print before appending the row, as it is similar
to a address+=0,line+=0 special opcode, which prints before appending
the row.

Reviewers: dblaikie, probinson, aprantl

Reviewed By: dblaikie

Subscribers: danielcdh, llvm-commits

Tags: #llvm

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

Added:
    llvm/trunk/test/tools/llvm-dwarfdump/X86/debug-line-dw-lns-copy.s
Modified:
    llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugLine.cpp

Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugLine.cpp?rev=358148&r1=358147&r2=358148&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugLine.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugLine.cpp Wed Apr 10 19:02:44 2019
@@ -347,6 +347,7 @@ Error DWARFDebugLine::Prologue::parse(co
 DWARFDebugLine::Row::Row(bool DefaultIsStmt) { reset(DefaultIsStmt); }
 
 void DWARFDebugLine::Row::postAppend() {
+  Discriminator = 0;
   BasicBlock = false;
   PrologueEnd = false;
   EpilogueBegin = false;
@@ -640,15 +641,14 @@ Error DWARFDebugLine::LineTable::parse(
       // Standard Opcodes
       case DW_LNS_copy:
         // Takes no arguments. Append a row to the matrix using the
-        // current values of the state-machine registers. Then set
-        // the basic_block register to false.
-        State.appendRowToMatrix();
+        // current values of the state-machine registers.
         if (OS) {
           *OS << "\n";
           OS->indent(12);
           State.Row.dump(*OS);
           *OS << "\n";
         }
+        State.appendRowToMatrix();
         break;
 
       case DW_LNS_advance_pc:
@@ -828,8 +828,6 @@ Error DWARFDebugLine::LineTable::parse(
       }
 
       State.appendRowToMatrix();
-      // Reset discriminator to 0.
-      State.Row.Discriminator = 0;
     }
     if(OS)
       *OS << "\n";

Added: llvm/trunk/test/tools/llvm-dwarfdump/X86/debug-line-dw-lns-copy.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-dwarfdump/X86/debug-line-dw-lns-copy.s?rev=358148&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-dwarfdump/X86/debug-line-dw-lns-copy.s (added)
+++ llvm/trunk/test/tools/llvm-dwarfdump/X86/debug-line-dw-lns-copy.s Wed Apr 10 19:02:44 2019
@@ -0,0 +1,47 @@
+# RUN: llvm-mc -filetype obj -triple x86_64-pc-linux %s -o %t.o
+# RUN: llvm-dwarfdump -debug-line %t.o | FileCheck %s
+
+# CHECK:      Address            Line   Column File   ISA Discriminator Flags
+# CHECK-NEXT: ------------------ ------ ------ ------ --- ------------- -------------
+# CHECK-NEXT: 0x0000000000000000      1      0      1   0             1  is_stmt
+# CHECK-NEXT: 0x0000000000000001      2      0      1   0             0  is_stmt
+# CHECK-NEXT: 0x0000000000000001      2      0      1   0             0  is_stmt end_sequence
+
+.section .debug_line,"", at progbits
+.Line_table_start0:
+  .long   .Line_table_end0-.Line_table_start0-4   # Length of Unit
+  .short  5               # DWARF version number
+  .byte   8               # Address Size
+  .byte   0               # Segment Selector Size
+  .long   .Line_table_header_end0-.Line_table_params0     # Length of Prologue
+.Line_table_params0:
+  .byte   1               # Minimum Instruction Length
+  .byte   1               # Maximum Operations per Instruction
+  .byte   1               # Default is_stmt
+  .byte   -5              # Line Base
+  .byte   14              # Line Range
+  .byte   13              # Opcode Base
+  .byte   0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1 # Standard Opcode Lengths
+  # Directory table format
+  .byte   1               # One element per directory entry
+  .byte   1               # DW_LNCT_path
+  .byte   0x08            # DW_FORM_string
+  # Directory table entries
+  .byte   1               # 1 directory
+  .asciz  "/tmp"
+  # File table format
+  .byte   2               # 2 elements per file entry
+  .byte   1               # DW_LNCT_path
+  .byte   0x08            # DW_FORM_string
+  .byte   2               # DW_LNCT_directory_index
+  .byte   0x0b            # DW_FORM_data1
+  # File table entries
+  .byte   1               # 1 file
+  .asciz  "a.c"
+  .byte   0
+.Line_table_header_end0:
+  .byte   0,2,4,1         # DW_LNE_set_discriminator 1
+  .byte   1               # DW_LNS_copy
+  .byte   33              # address += 1, line += 1
+  .byte   0,1,1           # DW_LNE_end_sequence
+.Line_table_end0:




More information about the llvm-commits mailing list