From 531a30acbe175da1f71768e2ffb585c4d45e640b Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Mon, 20 Jan 2014 23:09:26 +0100 Subject: stack: Add -d, --debugname. Lookup DWARF debuginfo name for frame address. Includes test that shows -d matches the function name that corresponds to the actual source line we report with -s for a frame address. Signed-off-by: Mark Wielaard --- tests/ChangeLog | 9 +++ tests/Makefile.am | 6 +- tests/run-stack-d-test.sh | 112 ++++++++++++++++++++++++++++++++++++ tests/testfiledwarfinlines.bz2 | Bin 0 -> 4225 bytes tests/testfiledwarfinlines.core.bz2 | Bin 0 -> 39713 bytes 5 files changed, 125 insertions(+), 2 deletions(-) create mode 100755 tests/run-stack-d-test.sh create mode 100755 tests/testfiledwarfinlines.bz2 create mode 100644 tests/testfiledwarfinlines.core.bz2 (limited to 'tests') diff --git a/tests/ChangeLog b/tests/ChangeLog index 733d8e61..70b05510 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,12 @@ +2014-01-20 Mark Wielaard + + * Makefile.am (TESTS): Add run-stack-d-test.sh. + (EXTRA_DIST): Add run-stack-d-test.sh, testfiledwarfinlines.bz2 + testfiledwarfinlines.core.bz2. + * run-stack-d-test.sh: New test. + * testfiledwarfinlines.bz2: New test file. + * testfiledwarfinlines.core.bz2: Likewise. + 2014-01-16 Mark Wielaard * run-nm-self.sh: Don't use testrun_on_self_quiet but just testrun diff --git a/tests/Makefile.am b/tests/Makefile.am index 1253574d..35f6e87e 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -108,7 +108,7 @@ TESTS = run-arextract.sh run-arsymtest.sh newfile test-nlist \ run-backtrace-native-core-biarch.sh run-backtrace-core-x86_64.sh \ run-backtrace-core-i386.sh run-backtrace-core-ppc.sh \ run-backtrace-core-s390x.sh run-backtrace-core-s390.sh \ - run-backtrace-demangle.sh + run-backtrace-demangle.sh run-stack-d-test.sh if !BIARCH export ELFUTILS_DISABLE_BIARCH = 1 @@ -264,7 +264,9 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh \ run-backtrace-core-s390x.sh run-backtrace-core-s390.sh \ run-backtrace-demangle.sh testfile-backtrace-demangle.bz2 \ testfile-backtrace-demangle.cc \ - testfile-backtrace-demangle.core.bz2 + testfile-backtrace-demangle.core.bz2 \ + run-stack-d-test.sh \ + testfiledwarfinlines.bz2 testfiledwarfinlines.core.bz2 if USE_VALGRIND valgrind_cmd='valgrind -q --error-exitcode=1 --run-libc-freeres=no' diff --git a/tests/run-stack-d-test.sh b/tests/run-stack-d-test.sh new file mode 100755 index 00000000..040c2fa9 --- /dev/null +++ b/tests/run-stack-d-test.sh @@ -0,0 +1,112 @@ +#! /bin/sh +# Copyright (C) 2014 Red Hat, Inc. +# This file is part of elfutils. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# elfutils is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. $srcdir/test-subr.sh + +# // g++ dwarfinlines.cpp -g -o testfiledwarfinlines -O2 +# int +# fubar (int x) +# { +# __asm__ ( "nop" ::: ); +# return 42 / x - 2; +# } +# +# void foobar (int z1, int z2) +# { +# __asm__ ( "nop" ::: ); +# int x = z1 + z2; +# while (z1 + x + 1 != 42) +# x = fubar (z1 + z2 + x); +# } +# +# void bar (int z) +# { +# int a, b; +# a = b = z / 2; +# foobar(a, b); +# } +# +# void foo (int x) +# { +# if (x > 0) +# bar(x - 2); +# } +# +# void fu (int y) +# { +# __asm__ ( "nop" ::: ); +# foo (y + 1); +# } +# +# int +# main (int argc, char **argv) +# { +# fu (argc); +# } +testfiles testfiledwarfinlines testfiledwarfinlines.core + +# Depending on whether we are running make check or make installcheck +# the actual binary name under test might be different. It is used in +# the error message, which we also try to match. +if test "$elfutils_testrun" = "installed"; then +STACKCMD=${bindir}/`program_transform stack` +else +STACKCMD=${abs_top_builddir}/src/stack +fi + +# Without -d the top function comes out as fu. +testrun_compare ${abs_top_builddir}/src/stack -n 2 -e testfiledwarfinlines --core testfiledwarfinlines.core<