• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#! /bin/sh
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/test-subr.sh
24
25# See run-stack-d-test.sh and run-stack-i-test.sh
26# Same tests, now with demangler support, no -r, and without -d.
27# Only change in output is an explit fu(int) instead of _Z2fui.
28
29testfiles testfiledwarfinlines testfiledwarfinlines.core
30
31# Depending on whether we are running make check or make installcheck
32# the actual binary name under test might be different. It is used in
33# the error message, which we also try to match.
34if test "$elfutils_testrun" = "installed"; then
35STACKCMD=${bindir}/`program_transform stack`
36else
37STACKCMD=${abs_top_builddir}/src/stack
38fi
39
40# Disable valgrind while dumping because of a bug unmapping libc.so.
41# https://bugs.kde.org/show_bug.cgi?id=327427
42SAVED_VALGRIND_CMD="$VALGRIND_CMD"
43unset VALGRIND_CMD
44
45# Without -d the top function comes out as fu.
46testrun_compare ${abs_top_builddir}/src/stack -n 2 -e testfiledwarfinlines --core testfiledwarfinlines.core<<EOF
47PID 13654 - core
48TID 13654:
49#0  0x00000000004006c8 fu(int)
50#1  0x00000000004004c5 main
51$STACKCMD: tid 13654: shown max number of frames (2, use -n 0 for unlimited)
52EOF
53
54# But when asking for source we see it is actually on line 6.
55# (Which is in function fubar, not fu).
56testrun_compare ${abs_top_builddir}/src/stack -n 2 -s -e testfiledwarfinlines --core testfiledwarfinlines.core<<EOF
57PID 13654 - core
58TID 13654:
59#0  0x00000000004006c8 fu(int)
60    /home/mark/src/tests/dwarfinlines.cpp:6
61#1  0x00000000004004c5 main
62    /home/mark/src/tests/dwarfinlines.cpp:39
63$STACKCMD: tid 13654: shown max number of frames (2, use -n 0 for unlimited)
64EOF
65
66# With --inlines we get all inlined calls. Note they share the same
67# address.
68testrun_compare ${abs_top_builddir}/src/stack -n 6 -i -e testfiledwarfinlines --core testfiledwarfinlines.core<<EOF
69PID 13654 - core
70TID 13654:
71#0  0x00000000004006c8 fubar
72#1  0x00000000004006c8 foobar
73#2  0x00000000004006c8 bar
74#3  0x00000000004006c8 foo
75#4  0x00000000004006c8 fu(int)
76#5  0x00000000004004c5 main
77$STACKCMD: tid 13654: shown max number of frames (6, use -n 0 for unlimited)
78EOF
79
80# With --source we can also see where in the source the inlined frames
81# where originally called from.
82testrun_compare ${abs_top_builddir}/src/stack -n 6 -s -i -e testfiledwarfinlines --core testfiledwarfinlines.core<<EOF
83PID 13654 - core
84TID 13654:
85#0  0x00000000004006c8 fubar
86    /home/mark/src/tests/dwarfinlines.cpp:6
87#1  0x00000000004006c8 foobar
88    /home/mark/src/tests/dwarfinlines.cpp:14
89#2  0x00000000004006c8 bar
90    /home/mark/src/tests/dwarfinlines.cpp:21
91#3  0x00000000004006c8 foo
92    /home/mark/src/tests/dwarfinlines.cpp:27
93#4  0x00000000004006c8 fu(int)
94    /home/mark/src/tests/dwarfinlines.cpp:33
95#5  0x00000000004004c5 main
96    /home/mark/src/tests/dwarfinlines.cpp:39
97$STACKCMD: tid 13654: shown max number of frames (6, use -n 0 for unlimited)
98EOF
99
100if [ "x$SAVED_VALGRIND_CMD" != "x" ]; then
101  VALGRIND_CMD="$SAVED_VALGRIND_CMD"
102  export VALGRIND_CMD
103fi
104
105exit 0
106