diff options
author | Mark Wielaard <mjw@redhat.com> | 2013-08-13 11:40:21 +0200 |
---|---|---|
committer | Mark Wielaard <mjw@redhat.com> | 2013-08-13 12:15:22 +0200 |
commit | 4b9e639d314e1ba63dbf661eb1fd7df1a8ee7d4a (patch) | |
tree | a5babe86dda3e4c7ed09633874350cadb284b6e3 /tests | |
parent | d0f8501761b15b35dc52eaf5709a638276270077 (diff) | |
download | elfutils-4b9e639d314e1ba63dbf661eb1fd7df1a8ee7d4a.tar.gz |
addr2line: Support -i, --inlines output option.
Show all source locations that caused inline expansion of subroutines
at the given address. This can easily be supported by using libdw
dwarf_getscopes_die which will give all nested inlined subroutines.
When -f, --functions is given also show the function names where the
subroutines were inlined.
The output matches that of binutils addr2line --inlines.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/ChangeLog | 8 | ||||
-rw-r--r-- | tests/Makefile.am | 6 | ||||
-rwxr-xr-x | tests/run-addr2line-i-test.sh | 145 | ||||
-rwxr-xr-x | tests/testfile-inlines.bz2 | bin | 0 -> 2815 bytes |
4 files changed, 157 insertions, 2 deletions
diff --git a/tests/ChangeLog b/tests/ChangeLog index 3475d7bd..9808ce73 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,11 @@ +2013-08-13 Mark Wielaard <mjw@redhat.com> + + * run-addr2line-i-test.sh: New test. + * testfile-inlines.bz2: New testfile. + * Makefile.am (EXTRA_DIST): Add run-addr2line-i-test.sh and + testfile-inlines.bz2. + (TESTS): Add run-addr2line-i-test.sh. + 2013-08-12 Mark Wielaard <mjw@redhat.com> * run-addr2line-test.sh: New test. diff --git a/tests/Makefile.am b/tests/Makefile.am index ac99e3e4..9aa06a6a 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -88,7 +88,8 @@ TESTS = run-arextract.sh run-arsymtest.sh newfile test-nlist \ run-low_high_pc.sh run-macro-test.sh run-elf_cntl_gelf_getshdr.sh \ run-test-archive64.sh run-readelf-vmcoreinfo.sh \ run-readelf-mixed-corenote.sh run-dwfllines.sh \ - run-dwfl-report-elf-align.sh run-addr2line-test.sh + run-dwfl-report-elf-align.sh run-addr2line-test.sh \ + run-addr2line-i-test.sh if !STANDALONE check_PROGRAMS += msg_tst md5-sha1-test @@ -200,7 +201,8 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh \ run-dwfllines.sh run-dwfl-report-elf-align.sh \ testfile-dwfl-report-elf-align-shlib.so.bz2 \ testfilenolines.bz2 test-core-lib.so.bz2 test-core.core.bz2 \ - test-core.exec.bz2 run-addr2line-test.sh + test-core.exec.bz2 run-addr2line-test.sh \ + run-addr2line-i-test.sh testfile-inlines.bz2 if USE_VALGRIND valgrind_cmd='valgrind -q --trace-children=yes --error-exitcode=1 --run-libc-freeres=no' diff --git a/tests/run-addr2line-i-test.sh b/tests/run-addr2line-i-test.sh new file mode 100755 index 00000000..e98adda3 --- /dev/null +++ b/tests/run-addr2line-i-test.sh @@ -0,0 +1,145 @@ +#! /bin/sh +# Copyright (C) 2013 Red Hat, Inc. +# This file is part of elfutils. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# elfutils is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +. $srcdir/test-subr.sh + +# // g++ x.cpp -g -fPIC -olibx.so -shared -O3 -fvisibility=hidden +# +# void foobar() +# { +# __asm__ ( "nop" ::: ); +# } +# +# void fubar() +# { +# __asm__ ( "nop" ::: ); +# } +# +# void bar() +# { +# foobar(); +# } +# +# void baz() +# { +# fubar(); +# } +# +# void foo() +# { +# bar(); +# baz(); +# } +# +# void fu() +# { +# __asm__ ( "nop" ::: ); +# fubar(); +# foobar(); +# } + +testfiles testfile-inlines + +testrun_compare ${abs_top_builddir}/src/addr2line -i -e testfile-inlines 0x00000000000005a0 <<\EOF +/tmp/x.cpp:5 +EOF + +testrun_compare ${abs_top_builddir}/src/addr2line -i -e testfile-inlines 0x00000000000005a1 <<\EOF +/tmp/x.cpp:6 +EOF + +testrun_compare ${abs_top_builddir}/src/addr2line -i -e testfile-inlines 0x00000000000005b0 <<\EOF +/tmp/x.cpp:10 +EOF + +testrun_compare ${abs_top_builddir}/src/addr2line -i -e testfile-inlines 0x00000000000005b1 <<\EOF +/tmp/x.cpp:11 +EOF + +testrun_compare ${abs_top_builddir}/src/addr2line -i -e testfile-inlines 0x00000000000005c0 <<\EOF +/tmp/x.cpp:5 +/tmp/x.cpp:15 +EOF + +testrun_compare ${abs_top_builddir}/src/addr2line -i -e testfile-inlines 0x00000000000005d0 <<\EOF +/tmp/x.cpp:10 +/tmp/x.cpp:20 +EOF + +testrun_compare ${abs_top_builddir}/src/addr2line -i -e testfile-inlines 0x00000000000005e0 <<\EOF +/tmp/x.cpp:5 +/tmp/x.cpp:15 +/tmp/x.cpp:25 +EOF + +testrun_compare ${abs_top_builddir}/src/addr2line -i -e testfile-inlines 0x00000000000005e1 <<\EOF +/tmp/x.cpp:10 +/tmp/x.cpp:20 +/tmp/x.cpp:26 +EOF + +testrun_compare ${abs_top_builddir}/src/addr2line -i -e testfile-inlines 0x00000000000005f1 <<\EOF +/tmp/x.cpp:10 +/tmp/x.cpp:32 +EOF + +testrun_compare ${abs_top_builddir}/src/addr2line -i -e testfile-inlines 0x00000000000005f2 <<\EOF +/tmp/x.cpp:5 +/tmp/x.cpp:33 +EOF + +# All together now (plus function names). +testrun_compare ${abs_top_builddir}/src/addr2line -f -i -e testfile-inlines 0x00000000000005a0 0x00000000000005a1 0x00000000000005b0 0x00000000000005b1 0x00000000000005c0 0x00000000000005d0 0x00000000000005e0 0x00000000000005e1 0x00000000000005f1 0x00000000000005f2 <<\EOF +foobar +/tmp/x.cpp:5 +foobar +/tmp/x.cpp:6 +fubar +/tmp/x.cpp:10 +fubar +/tmp/x.cpp:11 +foobar inlined at /tmp/x.cpp:15 in _Z3barv +/tmp/x.cpp:5 +bar +/tmp/x.cpp:15 +fubar inlined at /tmp/x.cpp:20 in _Z3bazv +/tmp/x.cpp:10 +baz +/tmp/x.cpp:20 +foobar inlined at /tmp/x.cpp:15 in _Z3foov +/tmp/x.cpp:5 +bar +/tmp/x.cpp:15 +_Z3foov +/tmp/x.cpp:25 +fubar inlined at /tmp/x.cpp:20 in _Z3foov +/tmp/x.cpp:10 +baz +/tmp/x.cpp:20 +_Z3foov +/tmp/x.cpp:26 +fubar inlined at /tmp/x.cpp:32 in _Z2fuv +/tmp/x.cpp:10 +_Z2fuv +/tmp/x.cpp:32 +foobar inlined at /tmp/x.cpp:33 in _Z2fuv +/tmp/x.cpp:5 +_Z2fuv +/tmp/x.cpp:33 +EOF + +exit 0 diff --git a/tests/testfile-inlines.bz2 b/tests/testfile-inlines.bz2 Binary files differnew file mode 100755 index 00000000..6a0c7c57 --- /dev/null +++ b/tests/testfile-inlines.bz2 |