1da0c48c4Sopenharmony_ci#! /bin/sh 2da0c48c4Sopenharmony_ci# Copyright (C) 2014, 2015 Red Hat, Inc. 3da0c48c4Sopenharmony_ci# This file is part of elfutils. 4da0c48c4Sopenharmony_ci# 5da0c48c4Sopenharmony_ci# This file is free software; you can redistribute it and/or modify 6da0c48c4Sopenharmony_ci# it under the terms of the GNU General Public License as published by 7da0c48c4Sopenharmony_ci# the Free Software Foundation; either version 3 of the License, or 8da0c48c4Sopenharmony_ci# (at your option) any later version. 9da0c48c4Sopenharmony_ci# 10da0c48c4Sopenharmony_ci# elfutils is distributed in the hope that it will be useful, but 11da0c48c4Sopenharmony_ci# WITHOUT ANY WARRANTY; without even the implied warranty of 12da0c48c4Sopenharmony_ci# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13da0c48c4Sopenharmony_ci# GNU General Public License for more details. 14da0c48c4Sopenharmony_ci# 15da0c48c4Sopenharmony_ci# You should have received a copy of the GNU General Public License 16da0c48c4Sopenharmony_ci# along with this program. If not, see <http://www.gnu.org/licenses/>. 17da0c48c4Sopenharmony_ci 18da0c48c4Sopenharmony_ci. $srcdir/test-subr.sh 19da0c48c4Sopenharmony_ci 20da0c48c4Sopenharmony_ci# See run-stack-d-test.sh for dwarfinlines.cpp source. 21da0c48c4Sopenharmony_citestfiles testfiledwarfinlines testfiledwarfinlines.core 22da0c48c4Sopenharmony_ci 23da0c48c4Sopenharmony_ci# Depending on whether we are running make check or make installcheck 24da0c48c4Sopenharmony_ci# the actual binary name under test might be different. It is used in 25da0c48c4Sopenharmony_ci# the error message, which we also try to match. 26da0c48c4Sopenharmony_ciif test "$elfutils_testrun" = "installed"; then 27da0c48c4Sopenharmony_ciSTACKCMD=${bindir}/`program_transform stack` 28da0c48c4Sopenharmony_cielse 29da0c48c4Sopenharmony_ciSTACKCMD=${abs_top_builddir}/src/stack 30da0c48c4Sopenharmony_cifi 31da0c48c4Sopenharmony_ci 32da0c48c4Sopenharmony_ci# Disable valgrind while dumping because of a bug unmapping libc.so. 33da0c48c4Sopenharmony_ci# https://bugs.kde.org/show_bug.cgi?id=327427 34da0c48c4Sopenharmony_ciSAVED_VALGRIND_CMD="$VALGRIND_CMD" 35da0c48c4Sopenharmony_ciunset VALGRIND_CMD 36da0c48c4Sopenharmony_ci 37da0c48c4Sopenharmony_ci# Compare with run-stack-d-test.sh to see the output without --inlines. 38da0c48c4Sopenharmony_ci# Only two call frames are visible (there is a jump from main to fu or 39da0c48c4Sopenharmony_ci# fubar). Explicitly use --raw so demangler support being configured in 40da0c48c4Sopenharmony_ci# doesn't change the results. 41da0c48c4Sopenharmony_ci 42da0c48c4Sopenharmony_ci# With --inlines we get all inlined calls. Note they share the same 43da0c48c4Sopenharmony_ci# address. 44da0c48c4Sopenharmony_citestrun_compare ${abs_top_builddir}/src/stack -r -n 6 -i -e testfiledwarfinlines --core testfiledwarfinlines.core<<EOF 45da0c48c4Sopenharmony_ciPID 13654 - core 46da0c48c4Sopenharmony_ciTID 13654: 47da0c48c4Sopenharmony_ci#0 0x00000000004006c8 fubar 48da0c48c4Sopenharmony_ci#1 0x00000000004006c8 foobar 49da0c48c4Sopenharmony_ci#2 0x00000000004006c8 bar 50da0c48c4Sopenharmony_ci#3 0x00000000004006c8 foo 51da0c48c4Sopenharmony_ci#4 0x00000000004006c8 _Z2fui 52da0c48c4Sopenharmony_ci#5 0x00000000004004c5 main 53da0c48c4Sopenharmony_ci$STACKCMD: tid 13654: shown max number of frames (6, use -n 0 for unlimited) 54da0c48c4Sopenharmony_ciEOF 55da0c48c4Sopenharmony_ci 56da0c48c4Sopenharmony_ci# With --source we can also see where in the source the inlined frames 57da0c48c4Sopenharmony_ci# where originally called from. 58da0c48c4Sopenharmony_citestrun_compare ${abs_top_builddir}/src/stack -r -n 6 -s -i -e testfiledwarfinlines --core testfiledwarfinlines.core<<EOF 59da0c48c4Sopenharmony_ciPID 13654 - core 60da0c48c4Sopenharmony_ciTID 13654: 61da0c48c4Sopenharmony_ci#0 0x00000000004006c8 fubar 62da0c48c4Sopenharmony_ci /home/mark/src/tests/dwarfinlines.cpp:6 63da0c48c4Sopenharmony_ci#1 0x00000000004006c8 foobar 64da0c48c4Sopenharmony_ci /home/mark/src/tests/dwarfinlines.cpp:14 65da0c48c4Sopenharmony_ci#2 0x00000000004006c8 bar 66da0c48c4Sopenharmony_ci /home/mark/src/tests/dwarfinlines.cpp:21 67da0c48c4Sopenharmony_ci#3 0x00000000004006c8 foo 68da0c48c4Sopenharmony_ci /home/mark/src/tests/dwarfinlines.cpp:27 69da0c48c4Sopenharmony_ci#4 0x00000000004006c8 _Z2fui 70da0c48c4Sopenharmony_ci /home/mark/src/tests/dwarfinlines.cpp:33 71da0c48c4Sopenharmony_ci#5 0x00000000004004c5 main 72da0c48c4Sopenharmony_ci /home/mark/src/tests/dwarfinlines.cpp:39 73da0c48c4Sopenharmony_ci$STACKCMD: tid 13654: shown max number of frames (6, use -n 0 for unlimited) 74da0c48c4Sopenharmony_ciEOF 75da0c48c4Sopenharmony_ci 76da0c48c4Sopenharmony_ciif [ "x$SAVED_VALGRIND_CMD" != "x" ]; then 77da0c48c4Sopenharmony_ci VALGRIND_CMD="$SAVED_VALGRIND_CMD" 78da0c48c4Sopenharmony_ci export VALGRIND_CMD 79da0c48c4Sopenharmony_cifi 80da0c48c4Sopenharmony_ci 81da0c48c4Sopenharmony_ciexit 0 82