• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#! /usr/bin/env 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
18if test -n "$ELFUTILS_DISABLE_DEMANGLE"; then
19  echo "demangler unsupported"
20  exit 77
21fi
22
23. $srcdir/backtrace-subr.sh
24
25child=testfile-backtrace-demangle
26testfiles $child{,.core}
27tempfiles $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
31SAVED_VALGRIND_CMD="$VALGRIND_CMD"
32unset 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)
39testrun ${abs_top_builddir}/src/stack -n 2 -e $child --core $child.core >$child.bt 2>$child.err || exitcode=$?
40cat $child.{bt,err}
41
42if [ "x$SAVED_VALGRIND_CMD" != "x" ]; then
43  VALGRIND_CMD="$SAVED_VALGRIND_CMD"
44  export VALGRIND_CMD
45fi
46
47if test $exitcode != 1 || ! grep "shown max number of frames" $child.err; then
48  echo >&2 $2: expected more than 2 frames
49  false
50fi
51if ! grep -w f $child.bt; then
52  echo >&2 $2: no f
53  false
54fi
55if ! grep ' cxxfunc(int)' $child.bt; then
56  echo >&2 $2: no cxxfunc
57  false
58fi
59