Brian Silverman | 8649792 | 2018-02-10 19:28:39 -0500 | [diff] [blame] | 1 | #! /bin/bash |
| 2 | # Copyright (C) 2014, 2015 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 | if test -n "$ELFUTILS_DISABLE_DEMANGLE"; then |
| 19 | echo "demangler unsupported" |
| 20 | exit 77 |
| 21 | fi |
| 22 | |
| 23 | . $srcdir/backtrace-subr.sh |
| 24 | |
| 25 | child=testfile-backtrace-demangle |
| 26 | testfiles $child{,.core} |
| 27 | tempfiles $child.{bt,err} |
| 28 | |
| 29 | # Disable valgrind while dumping because of a bug unmapping libc.so. |
| 30 | # https://bugs.kde.org/show_bug.cgi?id=327427 |
| 31 | SAVED_VALGRIND_CMD="$VALGRIND_CMD" |
| 32 | unset VALGRIND_CMD |
| 33 | |
| 34 | # There can be more than 3 frames, but depending on the system/installed |
| 35 | # glibc we might not be able to unwind fully till the end. |
| 36 | # cxxfunc -> f -> main |
| 37 | # Expect to see the top two and a warning that there are more frames |
| 38 | # (exit code 1) |
| 39 | testrun ${abs_top_builddir}/src/stack -n 2 -e $child --core $child.core >$child.bt 2>$child.err || exitcode=$? |
| 40 | cat $child.{bt,err} |
| 41 | |
| 42 | if [ "x$SAVED_VALGRIND_CMD" != "x" ]; then |
| 43 | VALGRIND_CMD="$SAVED_VALGRIND_CMD" |
| 44 | export VALGRIND_CMD |
| 45 | fi |
| 46 | |
| 47 | if test $exitcode != 1 || ! grep "shown max number of frames" $child.err; then |
| 48 | echo >&2 $2: expected more than 2 frames |
| 49 | false |
| 50 | fi |
| 51 | if ! grep -w f $child.bt; then |
| 52 | echo >&2 $2: no f |
| 53 | false |
| 54 | fi |
| 55 | if ! grep ' cxxfunc(int)' $child.bt; then |
| 56 | echo >&2 $2: no cxxfunc |
| 57 | false |
| 58 | fi |