tests: Test readelf --debug-dump=[decoded]line with min_inst_len > 1.
authorMark Wielaard <mark@klomp.org>
Mon, 16 Apr 2018 09:40:22 +0000 (11:40 +0200)
committerMark Wielaard <mark@klomp.org>
Mon, 16 Apr 2018 09:44:16 +0000 (11:44 +0200)
This testcase tests the fix for the readelf --debug-dump=line bug fixed
in commit 40b1f18 "readelf: Fix advance_pc to use op_addr_advance, not
just op_advance."

This tests both the --debug-dump=line (readelf) implementation and the
--debug-dump=decodedline (libdw) implementation. The first fails without
the bug fix. The second was already correct.

Signed-off-by: Mark Wielaard <mark@klomp.org>
tests/ChangeLog
tests/Makefile.am
tests/run-readelf-line.sh
tests/testfile-ppc64-min-instr.bz2 [new file with mode: 0755]

index c9403fb..27e5bd8 100644 (file)
@@ -1,3 +1,9 @@
+2018-04-16  Mark Wielaard  <mark@klomp.org>
+
+       * testfile-ppc64-min-instr.bz2: New testfile.
+       * run-readelf-line.sh: Run against testfile-ppc64-min-instr.bz2.
+       * Makefile.am (EXTRA_DIST): Add testfile-ppc64-min-instr.bz2.
+
 2018-04-11  Mark Wielaard  <mark@klomp.org>
 
        * run-addrcfi.sh: Adjust expected rule for aarch64 sp.
index a8cc2df..16abfb0 100644 (file)
@@ -230,6 +230,7 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh run-ar.sh \
             run-readelf-macro.sh testfilemacro.bz2 \
             run-readelf-loc.sh testfileloc.bz2 \
             run-readelf-aranges.sh run-readelf-line.sh testfilefoobarbaz.bz2 \
+            testfile-ppc64-min-instr.bz2 \
             run-readelf-z.sh \
             run-readelf-dwz-multi.sh libtestfile_multi_shared.so.bz2 \
             testfile_multi.dwz.bz2 testfile_multi_main.bz2 \
index 32bcf9d..f93bf47 100755 (executable)
@@ -256,4 +256,93 @@ DWARF section [30] '.debug_line' at offset 0x15f6:
 
 EOF
 
+# A .debug_line table with mininum instruction length > 1.
+#
+# = hello.c
+# #include <stdio.h>
+#
+# int
+# main (int argc, char **argv)
+# {
+#   printf ("Hello, %s\n", (argc > 0
+#                        ? argv[1]: "World"));
+#   return 0;
+# }
+#
+# clang version 5.0.1 (tags/RELEASE_501/final)
+# Target: powerpc64-unknown-linux-gnu
+# clang -g -O2 -o testfile-ppc64-min-instr hello.c
+testfiles testfile-ppc64-min-instr
+
+testrun_compare ${abs_top_builddir}/src/readelf --debug-dump=line testfile-ppc64-min-instr <<\EOF
+
+DWARF section [29] '.debug_line' at offset 0xdf6:
+
+Table at offset 0:
+
+ Length:                     69
+ DWARF version:              2
+ Prologue length:            30
+ Minimum instruction length: 4
+ Maximum operations per instruction: 1
+ Initial value if 'is_stmt': 1
+ Line base:                  -5
+ Line range:                 14
+ Opcode base:                13
+
+Opcodes:
+  [ 1]  0 arguments
+  [ 2]  1 argument
+  [ 3]  1 argument
+  [ 4]  1 argument
+  [ 5]  1 argument
+  [ 6]  0 arguments
+  [ 7]  0 arguments
+  [ 8]  0 arguments
+  [ 9]  1 argument
+  [10]  0 arguments
+  [11]  0 arguments
+  [12]  1 argument
+
+Directory table:
+
+File name table:
+ Entry Dir   Time      Size      Name
+ 1     0     0         0         hello.c
+
+Line number statements:
+ [    28] extended opcode 2:  set address to 0x100005a4 <main>
+ [    33] special opcode 22: address+0 = 0x100005a4 <main>, line+4 = 5
+ [    34] set column to 27
+ [    36] set prologue end flag
+ [    37] special opcode 19: address+0 = 0x100005a4 <main>, line+1 = 6
+ [    38] set column to 8
+ [    3a] special opcode 47: address+8 = 0x100005ac <main+0x8>, line+1 = 7
+ [    3b] set 'is_stmt' to 0
+ [    3c] advance line by constant -7 to 0
+ [    3e] special opcode 32: address+4 = 0x100005b0 <main+0xc>, line+0 = 0
+ [    3f] set column to 3
+ [    41] set 'is_stmt' to 1
+ [    42] special opcode 108: address+24 = 0x100005c8 <main+0x24>, line+6 = 6
+ [    43] special opcode 76: address+16 = 0x100005d8 <main+0x34>, line+2 = 8
+ [    44] advance address by 32 to 0x100005f8
+ [    46] extended opcode 1:  end of sequence
+EOF
+
+testrun_compare ${abs_top_builddir}/src/readelf --debug-dump=decodedline testfile-ppc64-min-instr <<\EOF
+
+DWARF section [29] '.debug_line' at offset 0xdf6:
+
+ CU [b] hello.c
+  line:col SBPE* disc isa op address (Statement Block Prologue Epilogue *End)
+  /home/fedora/mjw/hello.c (mtime: 0, length: 0)
+     5:0   S        0   0  0 0x00000000100005a4 <main>
+     6:27  S P      0   0  0 0x00000000100005a4 <main>
+     7:8   S        0   0  0 0x00000000100005ac <main+0x8>
+     0:8            0   0  0 0x00000000100005b0 <main+0xc>
+     6:3   S        0   0  0 0x00000000100005c8 <main+0x24>
+     8:3   S        0   0  0 0x00000000100005d8 <main+0x34>
+     8:3   S   *    0   0  0 0x00000000100005f7 <main+0x53>
+
+EOF
 exit 0
diff --git a/tests/testfile-ppc64-min-instr.bz2 b/tests/testfile-ppc64-min-instr.bz2
new file mode 100755 (executable)
index 0000000..85bef57
Binary files /dev/null and b/tests/testfile-ppc64-min-instr.bz2 differ