Home | History | Annotate | Download | only in tests
      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 
     18 if test -n "$ELFUTILS_DISABLE_DEMANGLE"; then
     19   echo "demangler unsupported"
     20   exit 77
     21 fi
     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 
     29 testfiles 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.
     34 if test "$elfutils_testrun" = "installed"; then
     35 STACKCMD=${bindir}/`program_transform stack`
     36 else
     37 STACKCMD=${abs_top_builddir}/src/stack
     38 fi
     39 
     40 # Disable valgrind while dumping because of a bug unmapping libc.so.
     41 # https://bugs.kde.org/show_bug.cgi?id=327427
     42 SAVED_VALGRIND_CMD="$VALGRIND_CMD"
     43 unset VALGRIND_CMD
     44 
     45 # Without -d the top function comes out as fu.
     46 testrun_compare ${abs_top_builddir}/src/stack -n 2 -e testfiledwarfinlines --core testfiledwarfinlines.core<<EOF
     47 PID 13654 - core
     48 TID 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)
     52 EOF
     53 
     54 # But when asking for source we see it is actually on line 6.
     55 # (Which is in function fubar, not fu).
     56 testrun_compare ${abs_top_builddir}/src/stack -n 2 -s -e testfiledwarfinlines --core testfiledwarfinlines.core<<EOF
     57 PID 13654 - core
     58 TID 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)
     64 EOF
     65 
     66 # With --inlines we get all inlined calls. Note they share the same
     67 # address.
     68 testrun_compare ${abs_top_builddir}/src/stack -n 6 -i -e testfiledwarfinlines --core testfiledwarfinlines.core<<EOF
     69 PID 13654 - core
     70 TID 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)
     78 EOF
     79 
     80 # With --source we can also see where in the source the inlined frames
     81 # where originally called from.
     82 testrun_compare ${abs_top_builddir}/src/stack -n 6 -s -i -e testfiledwarfinlines --core testfiledwarfinlines.core<<EOF
     83 PID 13654 - core
     84 TID 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)
     98 EOF
     99 
    100 if [ "x$SAVED_VALGRIND_CMD" != "x" ]; then
    101   VALGRIND_CMD="$SAVED_VALGRIND_CMD"
    102   export VALGRIND_CMD
    103 fi
    104 
    105 exit 0
    106