[PATCH] D71540: [DebugInfo] Only print a single blank line after an empty line table

James Henderson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 16 04:22:14 PST 2019


jhenderson created this revision.
jhenderson added reviewers: aprantl, JDevlieghere, probinson, dblaikie.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.

rG84a9756 <https://reviews.llvm.org/rG84a9756a72d81c32972b85c1d11cfd391f5b93a6> added an extra blank line at the end of any line table. However, a blank line is also printed after the line table header, which meant that two blank lines in a row were being printed after a header, if there were no rows. This patch defers the post-header blank line printing until it has been determined that there are rows to print.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71540

Files:
  llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
  llvm/test/tools/llvm-dwarfdump/X86/debug-line.s


Index: llvm/test/tools/llvm-dwarfdump/X86/debug-line.s
===================================================================
--- llvm/test/tools/llvm-dwarfdump/X86/debug-line.s
+++ llvm/test/tools/llvm-dwarfdump/X86/debug-line.s
@@ -62,7 +62,8 @@
 # CHECK-NEXT:       dir_index: 1
 # CHECK-NEXT:        mod_time: 0x00000011
 # CHECK-NEXT:          length: 0x00000022
-# CHECK-NOT:  {{.}}
+# CHECK-EMPTY:
+# CHECK-NEXT: debug_line[0x0000008c]
 
 .section .debug_line,"", at progbits
     .long .Lunit0_end - .Lunit0_begin ## unit_length
@@ -120,7 +121,7 @@
     .byte 0, 0x1, 0x1 ## DW_LNE_end_sequence
 .Lunit0_end:
 
-## Second line table program with version 4.
+## Second line table program with version 4 and no sequences.
     .long .Lunit1_end - .Lunit1_begin ## unit_length
 .Lunit1_begin:
     .short 4 ## version
@@ -143,3 +144,29 @@
     .byte 0x22 ## Length
 .Lheader1_end:
 .Lunit1_end:
+
+## Third line table program needed to show that only a single blank line is
+## printed after a program with no sequences. The values in this table are
+## arbitrary.
+    .long .Lunit2_end - .Lunit2_begin ## unit_length
+.Lunit2_begin:
+    .short 4 ## version
+    .long .Lheader2_end - .Lheader2_begin ## header_length
+.Lheader2_begin:
+    .byte 1 ## minimum_instruction_length
+    .byte 2 ## maximum_operations_per_instruction
+    .byte 1 ## default_is_stmt
+    .byte 1 ## line_base
+    .byte 1 ## line_range
+    .byte 2 ## opcode_base
+    .byte 1 ## standard_opcode_lengths
+    ## include_directories
+    .byte 0
+    ## file_names
+    .asciz "bar.c"
+    .byte 0 ## Directory index
+    .byte 0 ## Timestamp
+    .byte 0 ## Length
+.Lheader2_end:
+    .byte 0, 0x1, 0x1 ## DW_LNE_end_sequence
+.Lunit2_end:
Index: llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
===================================================================
--- llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
+++ llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
@@ -453,9 +453,9 @@
 void DWARFDebugLine::LineTable::dump(raw_ostream &OS,
                                      DIDumpOptions DumpOptions) const {
   Prologue.dump(OS, DumpOptions);
-  OS << '\n';
 
   if (!Rows.empty()) {
+    OS << '\n';
     Row::dumpTableHeader(OS);
     for (const Row &R : Rows) {
       R.dump(OS);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71540.234027.patch
Type: text/x-patch
Size: 2260 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191216/3b8b6202/attachment.bin>


More information about the llvm-commits mailing list