1*7304104dSAndroid Build Coastguard Worker#! /bin/sh 2*7304104dSAndroid Build Coastguard Worker# Copyright (C) 2014, 2015 Red Hat, Inc. 3*7304104dSAndroid Build Coastguard Worker# This file is part of elfutils. 4*7304104dSAndroid Build Coastguard Worker# 5*7304104dSAndroid Build Coastguard Worker# This file is free software; you can redistribute it and/or modify 6*7304104dSAndroid Build Coastguard Worker# it under the terms of the GNU General Public License as published by 7*7304104dSAndroid Build Coastguard Worker# the Free Software Foundation; either version 3 of the License, or 8*7304104dSAndroid Build Coastguard Worker# (at your option) any later version. 9*7304104dSAndroid Build Coastguard Worker# 10*7304104dSAndroid Build Coastguard Worker# elfutils is distributed in the hope that it will be useful, but 11*7304104dSAndroid Build Coastguard Worker# WITHOUT ANY WARRANTY; without even the implied warranty of 12*7304104dSAndroid Build Coastguard Worker# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13*7304104dSAndroid Build Coastguard Worker# GNU General Public License for more details. 14*7304104dSAndroid Build Coastguard Worker# 15*7304104dSAndroid Build Coastguard Worker# You should have received a copy of the GNU General Public License 16*7304104dSAndroid Build Coastguard Worker# along with this program. If not, see <http://www.gnu.org/licenses/>. 17*7304104dSAndroid Build Coastguard Worker 18*7304104dSAndroid Build Coastguard Workerif test -n "$ELFUTILS_DISABLE_DEMANGLE"; then 19*7304104dSAndroid Build Coastguard Worker echo "demangler unsupported" 20*7304104dSAndroid Build Coastguard Worker exit 77 21*7304104dSAndroid Build Coastguard Workerfi 22*7304104dSAndroid Build Coastguard Worker 23*7304104dSAndroid Build Coastguard Worker. $srcdir/test-subr.sh 24*7304104dSAndroid Build Coastguard Worker 25*7304104dSAndroid Build Coastguard Worker# See run-stack-d-test.sh and run-stack-i-test.sh 26*7304104dSAndroid Build Coastguard Worker# Same tests, now with demangler support, no -r, and without -d. 27*7304104dSAndroid Build Coastguard Worker# Only change in output is an explicit fu(int) instead of _Z2fui. 28*7304104dSAndroid Build Coastguard Worker 29*7304104dSAndroid Build Coastguard Workertestfiles testfiledwarfinlines testfiledwarfinlines.core 30*7304104dSAndroid Build Coastguard Worker 31*7304104dSAndroid Build Coastguard Worker# Depending on whether we are running make check or make installcheck 32*7304104dSAndroid Build Coastguard Worker# the actual binary name under test might be different. It is used in 33*7304104dSAndroid Build Coastguard Worker# the error message, which we also try to match. 34*7304104dSAndroid Build Coastguard Workerif test "$elfutils_testrun" = "installed"; then 35*7304104dSAndroid Build Coastguard WorkerSTACKCMD=${bindir}/`program_transform stack` 36*7304104dSAndroid Build Coastguard Workerelse 37*7304104dSAndroid Build Coastguard WorkerSTACKCMD=${abs_top_builddir}/src/stack 38*7304104dSAndroid Build Coastguard Workerfi 39*7304104dSAndroid Build Coastguard Worker 40*7304104dSAndroid Build Coastguard Worker# Disable valgrind while dumping because of a bug unmapping libc.so. 41*7304104dSAndroid Build Coastguard Worker# https://bugs.kde.org/show_bug.cgi?id=327427 42*7304104dSAndroid Build Coastguard WorkerSAVED_VALGRIND_CMD="$VALGRIND_CMD" 43*7304104dSAndroid Build Coastguard Workerunset VALGRIND_CMD 44*7304104dSAndroid Build Coastguard Worker 45*7304104dSAndroid Build Coastguard Worker# Without -d the top function comes out as fu. 46*7304104dSAndroid Build Coastguard Workertestrun_compare ${abs_top_builddir}/src/stack -n 2 -e testfiledwarfinlines --core testfiledwarfinlines.core<<EOF 47*7304104dSAndroid Build Coastguard WorkerPID 13654 - core 48*7304104dSAndroid Build Coastguard WorkerTID 13654: 49*7304104dSAndroid Build Coastguard Worker#0 0x00000000004006c8 fu(int) 50*7304104dSAndroid Build Coastguard Worker#1 0x00000000004004c5 main 51*7304104dSAndroid Build Coastguard Worker$STACKCMD: tid 13654: shown max number of frames (2, use -n 0 for unlimited) 52*7304104dSAndroid Build Coastguard WorkerEOF 53*7304104dSAndroid Build Coastguard Worker 54*7304104dSAndroid Build Coastguard Worker# But when asking for source we see it is actually on line 6. 55*7304104dSAndroid Build Coastguard Worker# (Which is in function fubar, not fu). 56*7304104dSAndroid Build Coastguard Workertestrun_compare ${abs_top_builddir}/src/stack -n 2 -s -e testfiledwarfinlines --core testfiledwarfinlines.core<<EOF 57*7304104dSAndroid Build Coastguard WorkerPID 13654 - core 58*7304104dSAndroid Build Coastguard WorkerTID 13654: 59*7304104dSAndroid Build Coastguard Worker#0 0x00000000004006c8 fu(int) 60*7304104dSAndroid Build Coastguard Worker /home/mark/src/tests/dwarfinlines.cpp:6 61*7304104dSAndroid Build Coastguard Worker#1 0x00000000004004c5 main 62*7304104dSAndroid Build Coastguard Worker /home/mark/src/tests/dwarfinlines.cpp:39 63*7304104dSAndroid Build Coastguard Worker$STACKCMD: tid 13654: shown max number of frames (2, use -n 0 for unlimited) 64*7304104dSAndroid Build Coastguard WorkerEOF 65*7304104dSAndroid Build Coastguard Worker 66*7304104dSAndroid Build Coastguard Worker# With --inlines we get all inlined calls. Note they share the same 67*7304104dSAndroid Build Coastguard Worker# address. 68*7304104dSAndroid Build Coastguard Workertestrun_compare ${abs_top_builddir}/src/stack -n 6 -i -e testfiledwarfinlines --core testfiledwarfinlines.core<<EOF 69*7304104dSAndroid Build Coastguard WorkerPID 13654 - core 70*7304104dSAndroid Build Coastguard WorkerTID 13654: 71*7304104dSAndroid Build Coastguard Worker#0 0x00000000004006c8 fubar 72*7304104dSAndroid Build Coastguard Worker#1 0x00000000004006c8 foobar 73*7304104dSAndroid Build Coastguard Worker#2 0x00000000004006c8 bar 74*7304104dSAndroid Build Coastguard Worker#3 0x00000000004006c8 foo 75*7304104dSAndroid Build Coastguard Worker#4 0x00000000004006c8 fu(int) 76*7304104dSAndroid Build Coastguard Worker#5 0x00000000004004c5 main 77*7304104dSAndroid Build Coastguard Worker$STACKCMD: tid 13654: shown max number of frames (6, use -n 0 for unlimited) 78*7304104dSAndroid Build Coastguard WorkerEOF 79*7304104dSAndroid Build Coastguard Worker 80*7304104dSAndroid Build Coastguard Worker# With --source we can also see where in the source the inlined frames 81*7304104dSAndroid Build Coastguard Worker# where originally called from. 82*7304104dSAndroid Build Coastguard Workertestrun_compare ${abs_top_builddir}/src/stack -n 6 -s -i -e testfiledwarfinlines --core testfiledwarfinlines.core<<EOF 83*7304104dSAndroid Build Coastguard WorkerPID 13654 - core 84*7304104dSAndroid Build Coastguard WorkerTID 13654: 85*7304104dSAndroid Build Coastguard Worker#0 0x00000000004006c8 fubar 86*7304104dSAndroid Build Coastguard Worker /home/mark/src/tests/dwarfinlines.cpp:6 87*7304104dSAndroid Build Coastguard Worker#1 0x00000000004006c8 foobar 88*7304104dSAndroid Build Coastguard Worker /home/mark/src/tests/dwarfinlines.cpp:14 89*7304104dSAndroid Build Coastguard Worker#2 0x00000000004006c8 bar 90*7304104dSAndroid Build Coastguard Worker /home/mark/src/tests/dwarfinlines.cpp:21 91*7304104dSAndroid Build Coastguard Worker#3 0x00000000004006c8 foo 92*7304104dSAndroid Build Coastguard Worker /home/mark/src/tests/dwarfinlines.cpp:27 93*7304104dSAndroid Build Coastguard Worker#4 0x00000000004006c8 fu(int) 94*7304104dSAndroid Build Coastguard Worker /home/mark/src/tests/dwarfinlines.cpp:33 95*7304104dSAndroid Build Coastguard Worker#5 0x00000000004004c5 main 96*7304104dSAndroid Build Coastguard Worker /home/mark/src/tests/dwarfinlines.cpp:39 97*7304104dSAndroid Build Coastguard Worker$STACKCMD: tid 13654: shown max number of frames (6, use -n 0 for unlimited) 98*7304104dSAndroid Build Coastguard WorkerEOF 99*7304104dSAndroid Build Coastguard Worker 100*7304104dSAndroid Build Coastguard Workerif [ "x$SAVED_VALGRIND_CMD" != "x" ]; then 101*7304104dSAndroid Build Coastguard Worker VALGRIND_CMD="$SAVED_VALGRIND_CMD" 102*7304104dSAndroid Build Coastguard Worker export VALGRIND_CMD 103*7304104dSAndroid Build Coastguard Workerfi 104*7304104dSAndroid Build Coastguard Worker 105*7304104dSAndroid Build Coastguard Workerexit 0 106