From: Mark Wielaard Date: Mon, 16 Apr 2018 09:40:22 +0000 (+0200) Subject: tests: Test readelf --debug-dump=[decoded]line with min_inst_len > 1. X-Git-Tag: elfutils-0.171~52 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=61eaf1f011dafccfddca8e55bd94c03941d7b516;p=thirdparty%2Felfutils.git 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 --- diff --git a/tests/ChangeLog b/tests/ChangeLog index c9403fbf9..27e5bd85f 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 a8cc2df7e..16abfb08e 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 32bcf9d5f..f93bf47d1 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 0x100005a4
+ [ 33] special opcode 22: address+0 = 0x100005a4
, line+4 = 5 + [ 34] set column to 27 + [ 36] set prologue end flag + [ 37] special opcode 19: address+0 = 0x100005a4
, line+1 = 6 + [ 38] set column to 8 + [ 3a] special opcode 47: address+8 = 0x100005ac , line+1 = 7 + [ 3b] set 'is_stmt' to 0 + [ 3c] advance line by constant -7 to 0 + [ 3e] special opcode 32: address+4 = 0x100005b0 , line+0 = 0 + [ 3f] set column to 3 + [ 41] set 'is_stmt' to 1 + [ 42] special opcode 108: address+24 = 0x100005c8 , line+6 = 6 + [ 43] special opcode 76: address+16 = 0x100005d8 , 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
+ 6:27 S P 0 0 0 0x00000000100005a4
+ 7:8 S 0 0 0 0x00000000100005ac + 0:8 0 0 0 0x00000000100005b0 + 6:3 S 0 0 0 0x00000000100005c8 + 8:3 S 0 0 0 0x00000000100005d8 + 8:3 S * 0 0 0 0x00000000100005f7 + +EOF exit 0 diff --git a/tests/testfile-ppc64-min-instr.bz2 b/tests/testfile-ppc64-min-instr.bz2 new file mode 100755 index 000000000..85bef57be Binary files /dev/null and b/tests/testfile-ppc64-min-instr.bz2 differ