]> granicus.if.org Git - llvm/commitdiff
Re-submit r289925 (Update .debug_line section version to match DWARF version)
authorPaul Robinson <paul.robinson@sony.com>
Mon, 4 Dec 2017 21:27:46 +0000 (21:27 +0000)
committerPaul Robinson <paul.robinson@sony.com>
Mon, 4 Dec 2017 21:27:46 +0000 (21:27 +0000)
Set the .debug_line version to match the requested DWARF version,
except with a maximum of v4 because we don't support v5 yet.

Previously Chromium had issues with this patch; see PR31407.  Chromium
tool issues have been addressed, so hopefully this will go through
this time.

Patch by Katya Romanova!

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@319699 91177308-0d34-0410-b5e6-96231b3b80d8

15 files changed:
lib/MC/MCDwarf.cpp
test/CodeGen/X86/dbg-line-0-no-discriminator.ll
test/DebugInfo/AArch64/line-header.ll
test/DebugInfo/Generic/empty.ll
test/DebugInfo/Generic/nodebug.ll
test/DebugInfo/X86/empty.ll
test/DebugInfo/X86/stmt-list-multiple-compile-units.ll
test/MC/ELF/debug-line.s
test/MC/ELF/debug-line2.s
test/MC/ELF/debug-loc.s
test/MC/ELF/discriminator.s
test/MC/ELF/empty-dwarf-lines.s
test/MC/MachO/file.s
test/MC/MachO/gen-dwarf.s
test/MC/MachO/loc.s

index 3dc0786e4456ebb6859d21470c73be6d43960ae4..748036e8a25774cb616681f8eda5ccc438bf96db 100644 (file)
@@ -277,8 +277,13 @@ MCDwarfLineTableHeader::Emit(MCStreamer *MCOS, MCDwarfLineTableParams Params,
   emitAbsValue(*MCOS,
                MakeStartMinusEndExpr(*MCOS, *LineStartSym, *LineEndSym, 4), 4);
 
-  // Next 2 bytes is the Version, which is Dwarf 2.
-  MCOS->EmitIntValue(2, 2);
+  // Next 2 bytes is the Version.
+  unsigned LineTableVersion = context.getDwarfVersion();
+  // FIXME: Right now the compiler doesn't support line table V5. Until it's
+  // supported keep generating line table V4, when Dwarf Info version V5 is used.  
+  if (LineTableVersion >= 5) 
+    LineTableVersion = 4; 
+  MCOS->EmitIntValue(LineTableVersion, 2);
 
   // Create a symbol for the end of the prologue (to be set when we get there).
   MCSymbol *ProEndSym = context.createTempSymbol(); // Lprologue_end
@@ -293,6 +298,11 @@ MCDwarfLineTableHeader::Emit(MCStreamer *MCOS, MCDwarfLineTableParams Params,
 
   // Parameters of the state machine, are next.
   MCOS->EmitIntValue(context.getAsmInfo()->getMinInstAlignment(), 1);
+  // maximum_operations_per_instruction 
+  // For non-VLIW architectures this field is always 1.
+  // FIXME: VLIW architectures need to update this field accordingly.
+  if (context.getDwarfVersion() >= 4)
+    MCOS->EmitIntValue(1, 1);
   MCOS->EmitIntValue(DWARF2_LINE_DEFAULT_IS_STMT, 1);
   MCOS->EmitIntValue(Params.DWARF2LineBase, 1);
   MCOS->EmitIntValue(Params.DWARF2LineRange, 1);
index 72fc0480fd4e2bc3610f78a5c5978b7e8952181d..cc96c3affc84b77bb34918ec4a854d5db3a4f0cf 100644 (file)
@@ -29,8 +29,8 @@ declare void @_Z3foov()
 ; Look at the lengths. We can't verify the line-number-program size
 ; directly, but the difference in the two lengths should not change
 ; unexpectedly.
-; CHECK:    total_length: 0x00000043
-; CHECK: prologue_length: 0x0000001e
+; CHECK:    total_length: 0x00000044
+; CHECK: prologue_length: 0x0000001f
 ;
 ; Verify that we see a line entry with a discriminator, and the next entry
 ; has line 0 and no discriminator.
index a51561be6e619826780508d414c24fc3a89a12ea..04d82edb2e3c419767262442fe9e1b7969a3f237 100644 (file)
@@ -3,4 +3,4 @@
 
 ; check line table length is correctly calculated for both big and little endian
 CHECK-LABEL: .debug_line contents:
-CHECK: total_length: 0x0000003e
+CHECK: total_length: 0x0000003f
index 3488fe5aeca2e9498df12de0f5d2825888be2c5a..aeb4726ecfe5e4e3744ca96ec2a9198192623b05 100644 (file)
@@ -9,7 +9,7 @@
 ; Expect no line table entry since there are no functions and file references in this compile unit
 ; CHECK: .debug_line contents:
 ; CHECK: Line table prologue:
-; CHECK: total_length: 0x00000019
+; CHECK: total_length: 0x0000001a
 ; CHECK-NOT: file_names[
 
 ; CHECK-NOT: .debug_pubnames contents:
index a911cf13dffe5867fffa8493ecfb1f00bff358ea..82528db773ec35fa8d2c049b349a3692cf990115 100644 (file)
@@ -24,7 +24,7 @@
 ; Expect no line table entry since there are no functions and file references in this compile unit
 ; CHECK: .debug_line contents:
 ; CHECK: Line table prologue:
-; CHECK: total_length: 0x00000019
+; CHECK: total_length: 0x0000001a
 ; CHECK-NOT: file_names[
 
 @i = external global i32
index 7abf217be27392de570e7497df5165de629b2637..10b6d5a596e6bedc68a986a1c55436946345943f 100644 (file)
@@ -4,7 +4,7 @@
 ; Expect no line table entry since there are no functions and file references in this compile unit
 ; CHECK: .debug_line contents:
 ; CHECK: Line table prologue:
-; CHECK: total_length: 0x00000019
+; CHECK: total_length: 0x0000001a
 ; CHECK-NOT: file_names[
 
 ; CHECK: .debug_pubnames contents:
index 64b20e04dee7ad502db9c17192a94d525781850e..0400e6386a3dcef12f2af32edce40c5430f78a4e 100644 (file)
@@ -15,7 +15,7 @@
 ; CHECK: DW_AT_high_pc [DW_FORM_data4]          (0x00000010)
 
 ; CHECK: DW_TAG_compile_unit
-; CHECK: DW_AT_stmt_list [DW_FORM_sec_offset]   (0x0000003c)
+; CHECK: DW_AT_stmt_list [DW_FORM_sec_offset]   (0x0000003d)
 ; CHECK: DW_AT_low_pc [DW_FORM_addr]            (0x0000000000000010)
 ; CHECK: DW_AT_high_pc [DW_FORM_data4]          (0x00000009)
 ; CHECK: DW_TAG_subprogram
 ; CHECK: .debug_line contents:
 ; CHECK-NEXT: debug_line[{{.*}}]
 ; CHECK-NEXT: Line table prologue:
-; CHECK-NEXT: total_length: 0x00000038
+; CHECK-NEXT: total_length: 0x00000039
 ; CHECK: file_names[  1]    0 0x00000000 0x00000000 simple.c
 ; CHECK: debug_line[{{.*}}]
 ; CHECK-NEXT: Line table prologue:
-; CHECK-NEXT: total_length: 0x00000039
+; CHECK-NEXT: total_length: 0x0000003a
 ; CHECK: file_names[  1]    0 0x00000000 0x00000000 simple2.c
 ; CHECK-NOT: file_names
 
index 072265c5c701f1869e9e398b234a2a5097bbfc02..c831eb915711beaa3796a2f846de2b174e429dd4 100644 (file)
 // CHECK-NEXT:     ]
 // CHECK-NEXT:     Address: 0x0
 // CHECK-NEXT:     Offset:
-// CHECK-NEXT:     Size: 57
+// CHECK-NEXT:     Size: 58
 // CHECK-NEXT:     Link: 0
 // CHECK-NEXT:     Info: 0
 // CHECK-NEXT:     AddressAlignment: 1
 // CHECK-NEXT:     EntrySize: 0
 // CHECK-NEXT:     SectionData (
 
-// CHECK-NEXT:       0000: 35000000 02001C00 00000101 FB0E0D00
-// CHECK-NEXT:       0010: 01010101 00000001 00000100 666F6F2E
-// CHECK-NEXT:       0020: 63000000 00000009 02000000 00000000
-// CHECK-NEXT:       0030: 00154B21 02080001 01
+// CHECK-NEXT:       0000: 36000000 04001D00 00000101 01FB0E0D
+// CHECK-NEXT:       0010: 00010101 01000000 01000001 00666F6F  
+// CHECK-NEXT:       0020: 2E630000 00000000 09020000 00000000  
+// CHECK-NEXT:       0030: 0000154B 21020800 0101              
 // CHECK-NEXT:     )
 // CHECK-NEXT:   }
 
index 71b0b16478869b2a2cfa8c547303285ca1bd650e..809b976824a00b59bce7673b131e87baf977b7a8 100644 (file)
 // CHECK-NEXT:     ]
 // CHECK-NEXT:     Address: 0x0
 // CHECK-NEXT:     Offset:
-// CHECK-NEXT:     Size: 56
+// CHECK-NEXT:     Size: 57
 // CHECK-NEXT:     Link: 0
 // CHECK-NEXT:     Info: 0
 // CHECK-NEXT:     AddressAlignment: 1
 // CHECK-NEXT:     EntrySize: 0
 // CHECK-NEXT:     SectionData (
-// CHECK-NEXT:       0000: 34000000 02001C00 00000101 FB0E0D00
-// CHECK-NEXT:       0010: 01010101 00000001 00000100 666F6F2E
-// CHECK-NEXT:       0020: 63000000 00000009 02000000 00000000
-// CHECK-NEXT:       0030: 00011302 01000101
+// CHECK-NEXT:       0000: 35000000 04001D00 00000101 01FB0E0D  |5...............|
+// CHECK-NEXT:       0010: 00010101 01000000 01000001 00666F6F  |.............foo|
+// CHECK-NEXT:       0020: 2E630000 00000000 09020000 00000000  |.c..............|
+// CHECK-NEXT:       0030: 00000113 02010001 01                 |.........|
 // CHECK-NEXT:     )
 // CHECK-NEXT:   }
 
index 4f1487284231302eb9c29e3e1c392b1b19636a92..21eac60d896d1c08e17943f7d4d67e37003bd22c 100644 (file)
@@ -15,7 +15,7 @@
 // CHECK-NEXT:     ]
 // CHECK-NEXT:     Address: 0x0
 // CHECK-NEXT:     Offset:
-// CHECK-NEXT:     Size: 61
+// CHECK-NEXT:     Size: 62
 // CHECK-NEXT:     Link: 0
 // CHECK-NEXT:     Info: 0
 // CHECK-NEXT:     AddressAlignment: 1
index 17b8ee41f294d80f52b9367cd7ff0d8b7b19cf03..2aab2404dfb828a4f0280fbadb40e9939181945f 100644 (file)
@@ -53,7 +53,7 @@ foo:
 
 # CHECK:      Relocations [
 # CHECK:        Section ({{[^ ]+}}) .rel.debug_line {
-# CHECK-NEXT:     0x2D R_386_32 .text 0x0
+# CHECK-NEXT:     0x2E R_386_32 .text 0x0
 # CHECK-NEXT:   }
 
 # DWARF-DUMP: Address            Line   Column File   ISA Discriminator Flags
index 19305709cda6180692d926726713aa463c4ef287..3b14fe0e6c5c6eedee854d77f95b9a7234714054 100644 (file)
@@ -15,7 +15,7 @@ c:
 // CHECK-NEXT:     ]
 // CHECK-NEXT:     Address: 0x0
 // CHECK-NEXT:     Offset: 0x44
-// CHECK-NEXT:     Size: 39
+// CHECK-NEXT:     Size: 40
 // CHECK-NEXT:     Link: 0
 // CHECK-NEXT:     Info: 0
 // CHECK-NEXT:     AddressAlignment: 1
index 108e3bbf173f2931e1ce69ea3b28d377d33c44d2..40f8c4ab87de68a90f732f4d260497449cdee9f5 100644 (file)
@@ -8,7 +8,7 @@
 // CHECK-NEXT:    Name: __debug_line
 // CHECK-NEXT:    Segment: __DWARF
 // CHECK-NEXT:    Address: 0x1
-// CHECK-NEXT:    Size: 0x28
+// CHECK-NEXT:    Size: 0x29
 // CHECK-NEXT:    Offset: 237
 // CHECK-NEXT:    Alignment: 0
 // CHECK-NEXT:    RelocationOffset: 0x0
@@ -20,8 +20,8 @@
 // CHECK-NEXT:    Reserved1: 0x0
 // CHECK-NEXT:    Reserved2: 0x0
 // CHECK-NEXT:    SectionData (
-// CHECK-NEXT:      0000: 24000000 02001E00 00000101 FB0E0D00
-// CHECK-NEXT:      0010: 01010101 00000001 00000164 69720000
-// CHECK-NEXT:      0020: 666F6F00 01000000
+// CHECK-NEXT:      0000: 25000000 04001F00 00000101 01FB0E0D  |%...............|
+// CHECK-NEXT:      0010: 00010101 01000000 01000001 64697200  |............dir.|
+// CHECK-NEXT:      0020: 00666F6F 00010000 00                 |.foo.....|
 // CHECK-NEXT:    )
 // CHECK-NEXT:  }
index 74d3d2aa8bf7588a6e809400ceb91ce5bac1c4be..349c59f3df209a61044f1909477d193d155e5e09 100644 (file)
@@ -89,7 +89,7 @@ _x:   .long 1
 // CHECK: .debug_line contents:
 // CHECK: Line table prologue:
 // We don't check the total_length as it includes lengths of temp paths
-// CHECK:         version: 2
+// CHECK:         version: 4
 // We don't check the prologue_length as it too includes lengths of temp paths
 // CHECK: min_inst_length: 1
 // CHECK: default_is_stmt: 1
index c1a2edd60909fccd9866b3be3f4cd7d4c9b8d8ac..d38bcf903576467efeefe8a61d51cb668f03a840 100644 (file)
@@ -9,10 +9,10 @@
 // CHECK:     Name: __debug_line (5F 5F 64 65 62 75 67 5F 6C 69 6E 65 00 00 00 00)
 // CHECK:     Segment: __DWARF (5F 5F 44 57 41 52 46 00 00 00 00 00 00 00 00 00)
 // CHECK:     Address: 0x1
-// CHECK:     Size: 0x33
+// CHECK:     Size: 0x34
 // CHECK:     Offset: 237
 // CHECK:     Alignment: 0
-// CHECK:     RelocationOffset: 0x120
+// CHECK:     RelocationOffset: 0x124
 // CHECK:     RelocationCount: 1
 // CHECK:     Type: 0x0
 // CHECK:     Attributes [ (0x20000)
 // CHECK:     Reserved1: 0x0
 // CHECK:     Reserved2: 0x0
 // CHECK:     SectionData (
-// CHECK:       0000: 2F000000 02001A00 00000101 FB0E0D00  |/...............|
-// CHECK:       0010: 01010101 00000001 00000100 666F6F00  |............foo.|
-// CHECK:       0020: 00000000 00050200 00000003 3F010201  |............?...|
-// CHECK:       0030: 000101                               |...|
+// CHECK:       0000: 30000000 04001B00 00000101 01FB0E0D  |0...............|
+// CHECK:       0010: 00010101 01000000 01000001 00666F6F  |.............foo|
+// CHECK:       0020: 00000000 00000502 00000000 033F0102  |.............?..|
+// CHECK:       0030: 01000101   
 // CHECK:     )
 // CHECK:   }
 // CHECK: ]
 // CHECK: Relocations [
 // CHECK:   Section __debug_line {
-// CHECK:     0x27 0 2 0 GENERIC_RELOC_VANILLA 0 __text
+// CHECK:     0x28 0 2 0 GENERIC_RELOC_VANILLA 0 __text
 // CHECK:   }
 // CHECK: ]