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
---
tests/ChangeLog| 6 +++
tests/Makefile.am | 1 +
tests/run-readelf-line.sh | 89 +
tests/testfile-ppc64-min-instr.bz2 | Bin 0 -> 3106 bytes
4 files changed, 96 insertions(+)
create mode 100755 tests/testfile-ppc64-min-instr.bz2
diff --git a/tests/ChangeLog b/tests/ChangeLog
index c9403fb..27e5bd8 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,9 @@
+2018-04-16 Mark Wielaard
+
+ * 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
* run-addrcfi.sh: Adjust expected rule for aarch64 sp.
diff --git a/tests/Makefile.am b/tests/Makefile.am
index a8cc2df..16abfb0 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -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 \
diff --git a/tests/run-readelf-line.sh b/tests/run-readelf-line.sh
index 32bcf9d..f93bf47 100755
--- a/tests/run-readelf-line.sh
+++ b/tests/run-readelf-line.sh
@@ -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
+#
+# 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 0x15a4
+ [33] special opcode 22: address+0 = 0x15a4 , line+4 = 5
+ [34] set column to 27
+ [36] set prologue end flag
+ [37] special opcode 19: address+0 = 0x15a4 , line+1 = 6
+ [38] set column to 8
+ [3a] special opcode 47: address+8 = 0x15ac , line+1 = 7
+ [3b] set 'is_stmt' to 0
+ [3c] advance line by constant -7 to 0
+ [3e] special opcode 32: address+4 = 0x15b0 , line+0 = 0
+ [3f] set column to 3
+ [41] set 'is_stmt' to 1
+ [42] special opcode 108: address+24 = 0x15c8 , line+6 = 6
+ [43] special opcode 76: address+16 = 0x15d8 , line+2 = 8
+ [44] advance address by 32 to 0x15f8
+ [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 S0 0 0 0x15a4
+ 6:27 S P 0 0 0 0x15a4
+ 7:8 S0 0 0 0x15ac
+ 0:80 0 0 0x15b0
+ 6:3 S0 0 0 0x15c8
+ 8:3 S0 0 0 0x15d8
+ 8:3 S *0 0 0 0x15f7
+
+EOF
exit 0
diff --git a/tests/testfile-ppc64-min-instr.bz2
b/tests/testfile-ppc64-min-instr.bz2
new file mode 100755
index
..85bef57be5819daecec07592b3e5044c4ef4953f
GIT binary patch
literal 3106
zcmV+-