summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMark Wielaard <[email protected]>2018-04-16 11:40:22 +0200
committerMark Wielaard <[email protected]>2018-04-16 11:44:16 +0200
commit61eaf1f011dafccfddca8e55bd94c03941d7b516 (patch)
tree0cfcf455806f6edee2e857d97c7a1ba30c148a09 /tests
parent40b1f188a3b3194c7f62db9760d81f07db229b33 (diff)
tests: Test readelf --debug-dump=[decoded]line with min_inst_len > 1.
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 <[email protected]>
Diffstat (limited to 'tests')
-rw-r--r--tests/ChangeLog6
-rw-r--r--tests/Makefile.am1
-rwxr-xr-xtests/run-readelf-line.sh89
-rwxr-xr-xtests/testfile-ppc64-min-instr.bz2bin0 -> 3106 bytes
4 files changed, 96 insertions, 0 deletions
diff --git a/tests/ChangeLog b/tests/ChangeLog
index c9403fbf..27e5bd85 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,9 @@
+2018-04-16 Mark Wielaard <[email protected]>
+
+ * 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 <[email protected]>
* run-addrcfi.sh: Adjust expected rule for aarch64 sp.
diff --git a/tests/Makefile.am b/tests/Makefile.am
index a8cc2df7..16abfb08 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 32bcf9d5..f93bf47d 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 <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
index 00000000..85bef57b
--- /dev/null
+++ b/tests/testfile-ppc64-min-instr.bz2
Binary files differ