1 # Copyright (C) 2013 Red Hat, Inc.
2 # This file is part of elfutils.
4 # This file is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
9 # elfutils is distributed in the hope that it will be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 . $srcdir/test-subr.sh
19 # Verify one of the backtraced threads contains function 'main'.
22 if grep -w main $1; then
29 # Without proper ELF symbols resolution we could get inappropriate weak
30 # symbol "gsignal" with the same address as the correct symbol "raise".
31 # It was fixed by GIT commit 78dec228b3cfb2f9300cd0b682ebf416c9674c91 .
32 # [patch] Improve ELF symbols preference (global > weak)
33 # https://lists.fedorahosted.org/pipermail/elfutils-devel/2012-October/002624.html
36 if ! grep -w gsignal $1; then
39 echo >&2 $2: found gsignal
43 # Verify the STDERR output does not contain unexpected errors.
44 # In some cases we cannot reliably find out we got behind _start as some
45 # operating system do not properly terminate CFI by undefined PC.
46 # Ignore it here as it is a bug of OS, not a bug of elfutils.
49 if [ $(egrep -v <$1 'dwfl_thread_getframes: (No DWARF information found|no matching address range)$' \
55 echo >&2 $2: neither empty nor just out of DWARF
64 check_main $bt $testname
65 check_gsignal $bt $testname
66 check_err $err $testname
73 if grep -q ': Unwinding not supported for this architecture$' $err; then
74 echo >&2 $testname: arch not supported
79 check_native_unsupported()
83 check_unsupported $err $testname
85 # ARM is special. It is supported, but it doesn't use .eh_frame by default
86 # making the native tests fail unless debuginfo (for glibc) is installed
87 # and we can fall back on .debug_frame for the CFI.
90 if grep 'dwfl_thread_getframes: No DWARF information found' $err; then
91 echo >&2 $testname: arm needs debuginfo installed for all libraries
101 testfiles backtrace.$arch.{exec,core}
102 tempfiles backtrace.$arch.{bt,err}
103 echo ./backtrace ./backtrace.$arch.{exec,core}
104 testrun ${abs_builddir}/backtrace -e ./backtrace.$arch.exec --core=./backtrace.$arch.core 1>backtrace.$arch.bt 2>backtrace.$arch.err || true
105 cat backtrace.$arch.{bt,err}
106 check_unsupported backtrace.$arch.err backtrace.$arch.core
107 check_all backtrace.$arch.{bt,err} backtrace.$arch.core
110 # Backtrace live process.
111 # Do not abort on non-zero exit code due to some warnings of ./backtrace
112 # - see function check_err.
116 tempfiles $child.{bt,err}
117 (set +ex; testrun ${abs_builddir}/backtrace --backtrace-exec=${abs_builddir}/$child 1>$child.bt 2>$child.err; true)
119 check_native_unsupported $child.err $child
120 check_all $child.{bt,err} $child
123 # Backtrace core file.
128 # Disable valgrind while dumping core.
129 SAVED_VALGRIND_CMD="$VALGRIND_CMD"
132 # Skip the test if we cannot adjust core ulimit.
133 core="core.`ulimit -c unlimited || exit 77; set +ex; testrun ${abs_builddir}/$child --gencore; true`"
134 # see if /proc/sys/kernel/core_uses_pid is set to 0
138 if [ ! -f "$core" ]; then exit 77; fi
140 if [ "x$SAVED_VALGRIND_CMD" != "x" ]; then
141 VALGRIND_CMD="$SAVED_VALGRIND_CMD"
145 # Do not abort on non-zero exit code due to some warnings of ./backtrace
146 # - see function check_err.
147 tempfiles $core{,.{bt,err}}
148 (set +ex; testrun ${abs_builddir}/backtrace -e ${abs_builddir}/$child --core=$core 1>$core.bt 2>$core.err; true)
150 check_native_unsupported $core.err $child-$core
151 check_all $core.{bt,err} $child-$core