[llvm] 0ae9e95 - [test][llvm-dwarfdump][NFC] Improve test readability

James Henderson via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 2 09:00:16 PST 2020


Author: James Henderson
Date: 2020-01-02T16:59:09Z
New Revision: 0ae9e952f73f97f2d4355f82a83770835dd835ea

URL: https://github.com/llvm/llvm-project/commit/0ae9e952f73f97f2d4355f82a83770835dd835ea
DIFF: https://github.com/llvm/llvm-project/commit/0ae9e952f73f97f2d4355f82a83770835dd835ea.diff

LOG: [test][llvm-dwarfdump][NFC] Improve test readability

This patch adds and improves comments in the debug_line_invalid.test and
its associated input file so that it is easier to follow. It uses '##'
to make comments stand out from lit and FileCheck commands.

It also reflows some commands so that the lines are not so long and are
easier to read and fixes some copy/paste errors.

Reviewed by: JDevlieghere

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

Added: 
    

Modified: 
    llvm/test/tools/llvm-dwarfdump/X86/Inputs/debug_line_malformed.s
    llvm/test/tools/llvm-dwarfdump/X86/debug_line_invalid.test

Removed: 
    


################################################################################
diff  --git a/llvm/test/tools/llvm-dwarfdump/X86/Inputs/debug_line_malformed.s b/llvm/test/tools/llvm-dwarfdump/X86/Inputs/debug_line_malformed.s
index 5e567a8295ab..c711cc09872d 100644
--- a/llvm/test/tools/llvm-dwarfdump/X86/Inputs/debug_line_malformed.s
+++ b/llvm/test/tools/llvm-dwarfdump/X86/Inputs/debug_line_malformed.s
@@ -1,5 +1,5 @@
 .section .debug_line,"", at progbits
-# Leading good section
+# Leading good section.
 .long   .Lunit1_end - .Lunit1_start # Length of Unit (DWARF-32 format)
 .Lunit1_start:
 .short  4               # DWARF version number
@@ -26,19 +26,19 @@
 .byte   0, 1, 1         # DW_LNE_end_sequence
 .Lunit1_end:
 
-# version 0
+# Version 0.
 .long   .Lunit_v0_end - .Lunit_v0_start # unit length
 .Lunit_v0_start:
 .short  0               # version
 .Lunit_v0_end:
 
-# version 1
+# Version 1.
 .long   .Lunit_v1_end - .Lunit_v1_start # unit length
 .Lunit_v1_start:
 .short  1               # version
 .Lunit_v1_end:
 
-# version 5 malformed line/include table
+# Version 5 malformed line/include table.
 .long   .Lunit_v5_end - .Lunit_v5_start # unit length
 .Lunit_v5_start:
 .short  5               # version
@@ -53,11 +53,11 @@
 .byte   14              # Line Range
 .byte   13              # Opcode Base
 .byte   0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1 # Standard Opcode Lengths
-.byte   0               # directory table (invalid)
+.byte   0               # directory table (invalid as no path component)
 .Lprologue_v5_end:
 .Lunit_v5_end:
 
-# Short prologue
+# Short prologue.
 .long   .Lunit_short_prologue_end - .Lunit_short_prologue_start # unit length
 .Lunit_short_prologue_start:
 .short  4               # version
@@ -81,7 +81,7 @@
 .Lprologue_short_prologue_end:
 .Lunit_short_prologue_end:
 
-# Over-long prologue
+# Over-long prologue.
 .long   .Lunit_long_prologue_end - .Lunit_long_prologue_start # unit length
 .Lunit_long_prologue_start:
 .short  4               # version
@@ -105,7 +105,7 @@
 .Lprologue_long_prologue_end:
 .Lunit_long_prologue_end:
 
-# Over-long extended opcode
+# Over-long extended opcode.
 .long   .Lunit_long_opcode_end - .Lunit_long_opcode_start # unit length
 .Lunit_long_opcode_start:
 .short  4               # version
@@ -127,15 +127,15 @@
 .byte   1, 0, 0
 .byte   0
 .Lprologue_long_opcode_end:
-.byte   0, 9, 2        # DW_LNE_set_address
+.byte   0, 9, 2         # DW_LNE_set_address
 .quad   0xabbadaba
-.byte   0, 2, 1         # DW_LNE_end_sequence (wrong length)
-.byte   0, 9, 2        # DW_LNE_set_address
+.byte   0, 2, 1         # DW_LNE_end_sequence (too long)
+.byte   0, 9, 2         # DW_LNE_set_address
 .quad   0xbabb1e45
-.byte   0, 1, 1         # DW_LNE_end_sequence (wrong length)
+.byte   0, 1, 1         # DW_LNE_end_sequence
 .Lunit_long_opcode_end:
 
-# No end of sequence
+# No end of sequence.
 .long   .Lunit_no_eos_end - .Lunit_no_eos_start # unit length
 .Lunit_no_eos_start:
 .short  4               # version
@@ -162,7 +162,7 @@
 .byte   1              # DW_LNS_copy
 .Lunit_no_eos_end:
 
-# Invalid prologue length
+# V5 very short prologue length.
 .long   .Linvalid_description_end0-.Linvalid_description_start0   # Length of Unit
 .Linvalid_description_start0:
 .short  5               # DWARF version number
@@ -201,7 +201,7 @@
 .byte   0,1,1           # DW_LNE_end_sequence
 .Linvalid_description_end0:
 
-# Invalid file entry
+# V5 prologue ends during file table.
 .long   .Linvalid_file_end0-.Linvalid_file_start0   # Length of Unit
 .Linvalid_file_start0:
 .short  5               # DWARF version number
@@ -240,7 +240,7 @@
 .byte   0,1,1           # DW_LNE_end_sequence
 .Linvalid_file_end0:
 
-# Invalid directory entry
+# V5 prologue ends during directory table.
 .long   .Linvalid_dir_end0-.Linvalid_dir_start0   # Length of Unit
 .Linvalid_dir_start0:
 .short  5               # DWARF version number
@@ -279,13 +279,13 @@
 .byte   0,1,1           # DW_LNE_end_sequence
 .Linvalid_dir_end0:
 
-# Invalid MD5 hash
+# Invalid MD5 hash.
 .long   .Linvalid_md5_end0-.Linvalid_md5_start0   # Length of Unit
 .Linvalid_md5_start0:
 .short  5               # DWARF version number
 .byte   8               # Address Size
 .byte   0               # Segment Selector Size
-.long   .Linvalid_md5_header_end0-.Linvalid_md5_params0     # Length of Prologue (invalid)
+.long   .Linvalid_md5_header_end0-.Linvalid_md5_params0     # Length of Prologue
 .Linvalid_md5_params0:
 .byte   1               # Minimum Instruction Length
 .byte   1               # Maximum Operations per Instruction
@@ -302,7 +302,7 @@
 .byte   1               # 1 directory
 .asciz  "/tmp"
 # File table format
-.byte   3               # 2 elements per file entry
+.byte   3               # 3 elements per file entry
 .byte   1               # DW_LNCT_path
 .byte   0x08            # DW_FORM_string
 .byte   2               # DW_LNCT_directory_index
@@ -320,7 +320,7 @@
 .byte   0,1,1           # DW_LNE_end_sequence
 .Linvalid_md5_end0:
 
-# Trailing good section
+# Trailing good section.
 .long   .Lunit_good_end - .Lunit_good_start # Length of Unit (DWARF-32 format)
 .Lunit_good_start:
 .short  4               # DWARF version number
@@ -346,4 +346,3 @@
 .quad   0xcafebabe
 .byte   0, 1, 1         # DW_LNE_end_sequence
 .Lunit_good_end:
-

diff  --git a/llvm/test/tools/llvm-dwarfdump/X86/debug_line_invalid.test b/llvm/test/tools/llvm-dwarfdump/X86/debug_line_invalid.test
index 04bf8a7c8360..b28c7141918b 100644
--- a/llvm/test/tools/llvm-dwarfdump/X86/debug_line_invalid.test
+++ b/llvm/test/tools/llvm-dwarfdump/X86/debug_line_invalid.test
@@ -1,31 +1,43 @@
-# Test the 
diff erent error cases in the debug line parsing and how they prevent
-# or don't prevent further dumping of section contents.
+## Test the 
diff erent error cases in the debug line parsing and how they prevent
+## or don't prevent further dumping of section contents.
 
+## Show that a bad length stops parsing of the section.
 # RUN: llvm-mc -triple x86_64-pc-linux %S/Inputs/debug_line_reserved_length.s -filetype=obj -o %t-reserved.o
-# RUN: llvm-dwarfdump -debug-line %t-reserved.o 2> %t-reserved.err | FileCheck %s --check-prefixes=FIRST,FATAL
+# RUN: llvm-dwarfdump -debug-line %t-reserved.o 2> %t-reserved.err \
+# RUN:   | FileCheck %s --check-prefixes=FIRST,FATAL
 # RUN: FileCheck %s --input-file=%t-reserved.err --check-prefix=RESERVED
-# RUN: llvm-dwarfdump -debug-line %t-reserved.o -verbose 2> %t-reserved-verbose.err | FileCheck %s --check-prefixes=FIRST,FATAL
+# RUN: llvm-dwarfdump -debug-line %t-reserved.o -verbose 2> %t-reserved-verbose.err \
+# RUN:   | FileCheck %s --check-prefixes=FIRST,FATAL
 # RUN: FileCheck %s --input-file=%t-reserved-verbose.err --check-prefix=RESERVED
 
-# We should still produce warnings for malformed tables after the specified unit.
-# RUN: llvm-dwarfdump -debug-line=0 %t-reserved.o 2> %t-reserved-off-first.err | FileCheck %s --check-prefixes=FIRST,NOLATER
+## We only produce warnings for malformed tables after the specified unit if
+## parsing can continue.
+# RUN: llvm-dwarfdump -debug-line=0 %t-reserved.o 2> %t-reserved-off-first.err \
+# RUN:   | FileCheck %s --check-prefixes=FIRST,NOLATER
 # RUN: FileCheck %s --input-file=%t-reserved-off-first.err --check-prefix=RESERVED
 
-# Stop looking for the specified unit, if a fatally-bad prologue is detected.
-# RUN: llvm-dwarfdump -debug-line=0x4b %t-reserved.o 2> %t-reserved-off-last.err | FileCheck %s --check-prefixes=NOFIRST,NOLATER
+## Stop looking for the specified unit, if a fatally-bad prologue is detected.
+# RUN: llvm-dwarfdump -debug-line=0x4b %t-reserved.o 2> %t-reserved-off-last.err \
+# RUN:   | FileCheck %s --check-prefixes=NOFIRST,NOLATER
 # RUN: FileCheck %s --input-file=%t-reserved-off-last.err --check-prefix=RESERVED
 
+## Show that non-fatal errors do not prevent parsing the rest of the section.
 # RUN: llvm-mc -triple x86_64-pc-linux %S/Inputs/debug_line_malformed.s -filetype=obj -o %t-malformed.o
-# RUN: llvm-dwarfdump -debug-line %t-malformed.o 2> %t-malformed.err | FileCheck %s --check-prefixes=FIRST,NONFATAL
+# RUN: llvm-dwarfdump -debug-line %t-malformed.o 2> %t-malformed.err \
+# RUN:   | FileCheck %s --check-prefixes=FIRST,NONFATAL
 # RUN: FileCheck %s --input-file=%t-malformed.err --check-prefixes=ALL,OTHER
-# RUN: llvm-dwarfdump -debug-line %t-malformed.o -verbose 2> %t-malformed-verbose.err | FileCheck %s --check-prefixes=FIRST,NONFATAL
+# RUN: llvm-dwarfdump -debug-line %t-malformed.o -verbose 2> %t-malformed-verbose.err \
+# RUN:   | FileCheck %s --check-prefixes=FIRST,NONFATAL
 # RUN: FileCheck %s --input-file=%t-malformed-verbose.err --check-prefixes=ALL,OTHER
 
-# RUN: llvm-dwarfdump -debug-line=0 %t-malformed.o 2> %t-malformed-off-first.err | FileCheck %s --check-prefixes=FIRST,NOLATER
+## We should still produce warnings for malformed tables after the specified unit.
+# RUN: llvm-dwarfdump -debug-line=0 %t-malformed.o 2> %t-malformed-off-first.err \
+# RUN:   | FileCheck %s --check-prefixes=FIRST,NOLATER
 # RUN: FileCheck %s --input-file=%t-malformed-off-first.err --check-prefix=ALL
 
-# Don't stop looking for the later unit if non-fatal issues are found.
-# RUN: llvm-dwarfdump -debug-line=0x271 %t-malformed.o 2> %t-malformed-off-last.err | FileCheck %s --check-prefixes=LASTONLY
+## Don't stop looking for the later unit if non-fatal issues are found.
+# RUN: llvm-dwarfdump -debug-line=0x271 %t-malformed.o 2> %t-malformed-off-last.err \
+# RUN:   | FileCheck %s --check-prefixes=LASTONLY
 # RUN: FileCheck %s --input-file=%t-malformed-off-last.err --check-prefix=ALL
 
 # FIRST: debug_line[0x00000000]
@@ -35,41 +47,60 @@
 # NOLATER-NOT: debug_line[{{.*}}]
 # NOLATER-NOT: end_sequence
 
-# For fatal issues, the following table(s) should not be dumped.
+## For fatal issues, the following table(s) should not be dumped.
 # FATAL: debug_line[0x00000048]
 # FATAL-NEXT: Line table prologue
 # FATAL-NEXT: total_length: 0xfffffffe
 # FATAL-NOT: debug_line
 
-# For non-fatal prologue issues, the table prologue should be dumped, and any subsequent tables should also be.
+## For non-fatal prologue issues, the table prologue should be dumped, and any
+## subsequent tables should also be.
+## Case 1: Version 0 table.
 # NONFATAL: debug_line[0x00000048]
 # NONFATAL-NEXT: Line table prologue
 # NONFATAL-NOT: Address
+
+## Case 2: Version 1 table.
 # NONFATAL: debug_line[0x0000004e]
 # NONFATAL-NEXT: Line table prologue
 # NONFATAL-NOT: Address
+
+## Case 3: Malformed directory format with no path component.
 # NONFATAL: debug_line[0x00000054]
 # NONFATAL-NEXT: Line table prologue
 # NONFATAL-NOT: Address
+
+## Case 4: Prologue with length shorter than parsed.
 # NONFATAL: debug_line[0x00000073]
 # NONFATAL-NEXT: Line table prologue
 # NONFATAL-NOT: Address
+
+## Case 5: Prologue with length longer than parsed.
 # NONFATAL: debug_line[0x000000ad]
 # NONFATAL-NEXT: Line table prologue
 # NONFATAL-NOT: Address
+
+## Case 6: Extended opcode with incorrect length versus expected.
 # NONFATAL: debug_line[0x000000e7]
-# Dumping prints the line table prologue and any valid operations up to the point causing the problem.
+## Dumping prints the line table prologue and any valid operations up to the
+## point causing the problem.
 # NONFATAL-NEXT: Line table prologue
 # NONFATAL: 0x00000000abbadaba {{.*}} end_sequence
 # NONFATAL-NOT: is_stmt
 
-# For minor issues, we can dump the table.
+## For minor issues, we can dump the whole table.
+## Case 7: No end of sequence.
 # NONFATAL: debug_line[0x0000013d]
 # NONFATAL-NEXT: Line table prologue
 # NONFATAL-NOT: debug_line[{{.*}}]
 # NONFATAL: 0x00000000deadfade {{.*}}
+
+## Case 8: Very short prologue length for V5 (ends during parameters).
 # NONFATAL: debug_line[0x00000183]
 # NONFATAL-NEXT: Line table prologue
+
+## TODO: Add checks here for remaining tables.
+
 # NONFATAL: debug_line[0x00000271]
 # NONFATAL-NOT: debug_line[{{.*}}]
 # NONFATAL: 0x00000000cafebabe {{.*}} end_sequence


        


More information about the llvm-commits mailing list