|
Packit |
032894 |
#! /bin/sh
|
|
Packit |
032894 |
# Copyright (C) 2014, 2015 Red Hat, Inc.
|
|
Packit |
032894 |
# This file is part of elfutils.
|
|
Packit |
032894 |
#
|
|
Packit |
032894 |
# This file is free software; you can redistribute it and/or modify
|
|
Packit |
032894 |
# it under the terms of the GNU General Public License as published by
|
|
Packit |
032894 |
# the Free Software Foundation; either version 3 of the License, or
|
|
Packit |
032894 |
# (at your option) any later version.
|
|
Packit |
032894 |
#
|
|
Packit |
032894 |
# elfutils is distributed in the hope that it will be useful, but
|
|
Packit |
032894 |
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
032894 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit |
032894 |
# GNU General Public License for more details.
|
|
Packit |
032894 |
#
|
|
Packit |
032894 |
# You should have received a copy of the GNU General Public License
|
|
Packit |
032894 |
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
Packit |
032894 |
|
|
Packit |
032894 |
. $srcdir/test-subr.sh
|
|
Packit |
032894 |
|
|
Packit |
032894 |
# // g++ dwarfinlines.cpp -g -o testfiledwarfinlines -O2
|
|
Packit |
032894 |
# int
|
|
Packit |
032894 |
# fubar (int x)
|
|
Packit |
032894 |
# {
|
|
Packit |
032894 |
# __asm__ ( "nop" ::: );
|
|
Packit |
032894 |
# return 42 / x - 2;
|
|
Packit |
032894 |
# }
|
|
Packit |
032894 |
#
|
|
Packit |
032894 |
# void foobar (int z1, int z2)
|
|
Packit |
032894 |
# {
|
|
Packit |
032894 |
# __asm__ ( "nop" ::: );
|
|
Packit |
032894 |
# int x = z1 + z2;
|
|
Packit |
032894 |
# while (z1 + x + 1 != 42)
|
|
Packit |
032894 |
# x = fubar (z1 + z2 + x);
|
|
Packit |
032894 |
# }
|
|
Packit |
032894 |
#
|
|
Packit |
032894 |
# void bar (int z)
|
|
Packit |
032894 |
# {
|
|
Packit |
032894 |
# int a, b;
|
|
Packit |
032894 |
# a = b = z / 2;
|
|
Packit |
032894 |
# foobar(a, b);
|
|
Packit |
032894 |
# }
|
|
Packit |
032894 |
#
|
|
Packit |
032894 |
# void foo (int x)
|
|
Packit |
032894 |
# {
|
|
Packit |
032894 |
# if (x > 0)
|
|
Packit |
032894 |
# bar(x - 2);
|
|
Packit |
032894 |
# }
|
|
Packit |
032894 |
#
|
|
Packit |
032894 |
# void fu (int y)
|
|
Packit |
032894 |
# {
|
|
Packit |
032894 |
# __asm__ ( "nop" ::: );
|
|
Packit |
032894 |
# foo (y + 1);
|
|
Packit |
032894 |
# }
|
|
Packit |
032894 |
#
|
|
Packit |
032894 |
# int
|
|
Packit |
032894 |
# main (int argc, char **argv)
|
|
Packit |
032894 |
# {
|
|
Packit |
032894 |
# fu (argc);
|
|
Packit |
032894 |
# }
|
|
Packit |
032894 |
testfiles testfiledwarfinlines testfiledwarfinlines.core
|
|
Packit |
032894 |
|
|
Packit |
032894 |
# Depending on whether we are running make check or make installcheck
|
|
Packit |
032894 |
# the actual binary name under test might be different. It is used in
|
|
Packit |
032894 |
# the error message, which we also try to match.
|
|
Packit |
032894 |
if test "$elfutils_testrun" = "installed"; then
|
|
Packit |
032894 |
STACKCMD=${bindir}/`program_transform stack`
|
|
Packit |
032894 |
else
|
|
Packit |
032894 |
STACKCMD=${abs_top_builddir}/src/stack
|
|
Packit |
032894 |
fi
|
|
Packit |
032894 |
|
|
Packit |
032894 |
# Disable valgrind while dumping because of a bug unmapping libc.so.
|
|
Packit |
032894 |
# https://bugs.kde.org/show_bug.cgi?id=327427
|
|
Packit |
032894 |
SAVED_VALGRIND_CMD="$VALGRIND_CMD"
|
|
Packit |
032894 |
unset VALGRIND_CMD
|
|
Packit |
032894 |
|
|
Packit |
032894 |
# Without -d the top function comes out as fu. Use --raw to not demangle.
|
|
Packit |
032894 |
testrun_compare ${abs_top_builddir}/src/stack -r -n 2 -e testfiledwarfinlines --core testfiledwarfinlines.core<
|
|
Packit |
032894 |
PID 13654 - core
|
|
Packit |
032894 |
TID 13654:
|
|
Packit |
032894 |
#0 0x00000000004006c8 _Z2fui
|
|
Packit |
032894 |
#1 0x00000000004004c5 main
|
|
Packit |
032894 |
$STACKCMD: tid 13654: shown max number of frames (2, use -n 0 for unlimited)
|
|
Packit |
032894 |
EOF
|
|
Packit |
032894 |
|
|
Packit |
032894 |
# But when asking for source we see it is actually on line 6.
|
|
Packit |
032894 |
# (Which is in function fubar, not fu). Use --raw to not demangle.
|
|
Packit |
032894 |
testrun_compare ${abs_top_builddir}/src/stack -r -n 2 -s -e testfiledwarfinlines --core testfiledwarfinlines.core<
|
|
Packit |
032894 |
PID 13654 - core
|
|
Packit |
032894 |
TID 13654:
|
|
Packit |
032894 |
#0 0x00000000004006c8 _Z2fui
|
|
Packit |
032894 |
/home/mark/src/tests/dwarfinlines.cpp:6
|
|
Packit |
032894 |
#1 0x00000000004004c5 main
|
|
Packit |
032894 |
/home/mark/src/tests/dwarfinlines.cpp:39
|
|
Packit |
032894 |
$STACKCMD: tid 13654: shown max number of frames (2, use -n 0 for unlimited)
|
|
Packit |
032894 |
EOF
|
|
Packit |
032894 |
|
|
Packit |
032894 |
# So with --debugname we get the function correct as fubar.
|
|
Packit |
032894 |
testrun_compare ${abs_top_builddir}/src/stack -n 2 -d -e testfiledwarfinlines --core testfiledwarfinlines.core<
|
|
Packit |
032894 |
PID 13654 - core
|
|
Packit |
032894 |
TID 13654:
|
|
Packit |
032894 |
#0 0x00000000004006c8 fubar
|
|
Packit |
032894 |
#1 0x00000000004004c5 main
|
|
Packit |
032894 |
$STACKCMD: tid 13654: shown max number of frames (2, use -n 0 for unlimited)
|
|
Packit |
032894 |
EOF
|
|
Packit |
032894 |
|
|
Packit |
032894 |
# Which now matches the source line (again 6 of course).
|
|
Packit |
032894 |
testrun_compare ${abs_top_builddir}/src/stack -n 2 -s -d -e testfiledwarfinlines --core testfiledwarfinlines.core<
|
|
Packit |
032894 |
PID 13654 - core
|
|
Packit |
032894 |
TID 13654:
|
|
Packit |
032894 |
#0 0x00000000004006c8 fubar
|
|
Packit |
032894 |
/home/mark/src/tests/dwarfinlines.cpp:6
|
|
Packit |
032894 |
#1 0x00000000004004c5 main
|
|
Packit |
032894 |
/home/mark/src/tests/dwarfinlines.cpp:39
|
|
Packit |
032894 |
$STACKCMD: tid 13654: shown max number of frames (2, use -n 0 for unlimited)
|
|
Packit |
032894 |
EOF
|
|
Packit |
032894 |
|
|
Packit |
032894 |
if [ "x$SAVED_VALGRIND_CMD" != "x" ]; then
|
|
Packit |
032894 |
VALGRIND_CMD="$SAVED_VALGRIND_CMD"
|
|
Packit |
032894 |
export VALGRIND_CMD
|
|
Packit |
032894 |
fi
|
|
Packit |
032894 |
|
|
Packit |
032894 |
exit 0
|