1#! /bin/sh 2# Copyright (C) 2013 Red Hat, Inc. 3# This file is part of elfutils. 4# 5# This file is free software; you can redistribute it and/or modify 6# it under the terms of the GNU General Public License as published by 7# the Free Software Foundation; either version 3 of the License, or 8# (at your option) any later version. 9# 10# elfutils is distributed in the hope that it will be useful, but 11# WITHOUT ANY WARRANTY; without even the implied warranty of 12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13# GNU General Public License for more details. 14# 15# You should have received a copy of the GNU General Public License 16# along with this program. If not, see <http://www.gnu.org/licenses/>. 17 18. $srcdir/test-subr.sh 19 20testfiles testfile 21tempfiles good.out stdin.nl stdin.nl.out stdin.nonl stdin.nonl.out foo.out 22tempfiles addr2line.out 23 24cat > good.out <<\EOF 25foo 26/home/drepper/gnu/new-bu/build/ttt/f.c:3 27bar 28/home/drepper/gnu/new-bu/build/ttt/b.c:4 29foo 30/home/drepper/gnu/new-bu/build/ttt/f.c:3 31bar 32/home/drepper/gnu/new-bu/build/ttt/b.c:4 33foo 34/home/drepper/gnu/new-bu/build/ttt/f.c:3 35bar 36/home/drepper/gnu/new-bu/build/ttt/b.c:4 37foo 38/home/drepper/gnu/new-bu/build/ttt/f.c:3 39bar 40/home/drepper/gnu/new-bu/build/ttt/b.c:4 41EOF 42 43echo "# Everything on the command line" 44cat good.out | testrun_compare ${abs_top_builddir}/src/addr2line -f -e testfile 0x08048468 0x0804845c foo bar foo+0x0 bar+0x0 foo-0x0 bar-0x0 45 46cat > stdin.nl <<\EOF 470x08048468 480x0804845c 49foo 50bar 51foo+0x0 52bar+0x0 53foo-0x0 54bar-0x0 55EOF 56 57echo "# Everything from stdin (with newlines)." 58cat stdin.nl | testrun ${abs_top_builddir}/src/addr2line -f -e testfile > stdin.nl.out || exit 1 59cmp good.out stdin.nl.out || exit 1 60 61cat > foo.out <<\EOF 62foo 63/home/drepper/gnu/new-bu/build/ttt/f.c:3 64EOF 65 66echo "# stdin without newline address, just EOF." 67echo -n "0x08048468" | testrun ${abs_top_builddir}/src/addr2line -f -e testfile > stdin.nonl.out || exit 1 68cmp foo.out stdin.nonl.out || exit 1 69 70echo "# stdin without newline symbol, just EOF." 71echo -n "foo" | testrun ${abs_top_builddir}/src/addr2line -f -e testfile > stdin.nl.out || exit 1 72cmp foo.out stdin.nonl.out || exit 1 73 74tempfiles good.addr.out 75 76cat > good.addr.out <<\EOF 770x08048468 78foo 79/home/drepper/gnu/new-bu/build/ttt/f.c:3 800x0804845c 81bar 82/home/drepper/gnu/new-bu/build/ttt/b.c:4 830x08048468 84foo 85/home/drepper/gnu/new-bu/build/ttt/f.c:3 860x0804845c 87bar 88/home/drepper/gnu/new-bu/build/ttt/b.c:4 890x08048468 90foo 91/home/drepper/gnu/new-bu/build/ttt/f.c:3 920x0804845c 93bar 94/home/drepper/gnu/new-bu/build/ttt/b.c:4 950x08048468 96foo 97/home/drepper/gnu/new-bu/build/ttt/f.c:3 980x0804845c 99bar 100/home/drepper/gnu/new-bu/build/ttt/b.c:4 101EOF 102 103echo "# Everything on the command line with addresses" 104cat good.addr.out | testrun_compare ${abs_top_builddir}/src/addr2line -a -f -e testfile 0x08048468 0x0804845c foo bar foo+0x0 bar+0x0 foo-0x0 bar-0x0 105 106echo "# Everything from stdin (with newlines) with addresses." 107cat stdin.nl | testrun ${abs_top_builddir}/src/addr2line -a -f -e testfile > stdin.nl.out || exit 1 108cmp good.addr.out stdin.nl.out || exit 1 109 110echo "# Pretty with functions and addresses." 111testrun_compare ${abs_top_builddir}/src/addr2line --pretty -a -f -e testfile 0x08048468 0x0804845c << EOF 1120x08048468: foo at /home/drepper/gnu/new-bu/build/ttt/f.c:3 1130x0804845c: bar at /home/drepper/gnu/new-bu/build/ttt/b.c:4 114EOF 115 116exit 0 117