summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/ChangeLog14
-rw-r--r--tests/Makefile.am14
-rwxr-xr-xtests/run-backtrace-demangle.sh37
-rw-r--r--tests/testfile-backtrace-demangle.bz2bin0 -> 2610 bytes
-rw-r--r--tests/testfile-backtrace-demangle.cc47
-rw-r--r--tests/testfile-backtrace-demangle.core.bz2bin0 -> 40629 bytes
6 files changed, 109 insertions, 3 deletions
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 7e9dcf4b..1b84f3a1 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,17 @@
+2014-01-15 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ Fix corruption of non-C++ symbols by the demangler.
+ * Makefile.am (TESTS): Add run-backtrace-demangle.sh.
+ <!DEMANGLE>: Add ELFUTILS_DISABLE_DEMANGLE export.
+ (EXTRA_DIST): Add run-backtrace-demangle.sh,
+ testfile-backtrace-demangle.bz2, testfile-backtrace-demangle.cc,
+ testfile-backtrace-demangle.core.bz2.
+ * backtrace-demangle.cc: New file.
+ * run-backtrace-demangle.sh: New file.
+ * testfile-backtrace-demangle.bz2: New file.
+ * testfile-backtrace-demangle.cc: New file.
+ * testfile-backtrace-demangle.core.bz2: New file.
+
2014-01-07 Matthias Klose <doko@ubuntu.com>
* backtrace-subr.sh (check_native_core): Check to see if core file
diff --git a/tests/Makefile.am b/tests/Makefile.am
index eae64a83..1253574d 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,6 +1,6 @@
## Process this file with automake to create Makefile.in
##
-## Copyright (C) 1996-2013 Red Hat, Inc.
+## Copyright (C) 1996-2014 Red Hat, Inc.
## This file is part of elfutils.
##
## This file is free software; you can redistribute it and/or modify
@@ -107,12 +107,17 @@ TESTS = run-arextract.sh run-arsymtest.sh newfile test-nlist \
run-backtrace-native-biarch.sh run-backtrace-native-core.sh \
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-core-s390x.sh run-backtrace-core-s390.sh \
+ run-backtrace-demangle.sh
if !BIARCH
export ELFUTILS_DISABLE_BIARCH = 1
endif
+if !DEMANGLE
+export ELFUTILS_DISABLE_DEMANGLE = 1
+endif
+
if !STANDALONE
check_PROGRAMS += msg_tst md5-sha1-test
TESTS += msg_tst md5-sha1-test
@@ -256,7 +261,10 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh \
run-backtrace-core-ppc.sh testfile66.bz2 testfile66.core.bz2 \
backtrace.s390x.core.bz2 backtrace.s390x.exec.bz2 \
backtrace.s390.core.bz2 backtrace.s390.exec.bz2 \
- run-backtrace-core-s390x.sh run-backtrace-core-s390.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
if USE_VALGRIND
valgrind_cmd='valgrind -q --error-exitcode=1 --run-libc-freeres=no'
diff --git a/tests/run-backtrace-demangle.sh b/tests/run-backtrace-demangle.sh
new file mode 100755
index 00000000..b5bddeb3
--- /dev/null
+++ b/tests/run-backtrace-demangle.sh
@@ -0,0 +1,37 @@
+#! /bin/bash
+# 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 <http://www.gnu.org/licenses/>.
+
+if test -n "$ELFUTILS_DISABLE_DEMANGLE"; then
+ exit 77
+fi
+
+. $srcdir/backtrace-subr.sh
+set -x
+
+child=testfile-backtrace-demangle
+testfiles $child{,.core}
+tempfiles $child.{bt,err}
+testrun ${abs_top_builddir}/src/stack -e $child --core $child.core >$child.bt 2>$child.err
+cat $child.{bt,err}
+if ! grep -w f $child.bt; then
+ echo >&2 $2: no f
+ false
+fi
+if ! grep ' cxxfunc(int)' $child.bt; then
+ echo >&2 $2: no cxxfunc
+ false
+fi
diff --git a/tests/testfile-backtrace-demangle.bz2 b/tests/testfile-backtrace-demangle.bz2
new file mode 100644
index 00000000..c3156e89
--- /dev/null
+++ b/tests/testfile-backtrace-demangle.bz2
Binary files differ
diff --git a/tests/testfile-backtrace-demangle.cc b/tests/testfile-backtrace-demangle.cc
new file mode 100644
index 00000000..6daa4297
--- /dev/null
+++ b/tests/testfile-backtrace-demangle.cc
@@ -0,0 +1,47 @@
+/* Test program for C++ demangled unwinding.
+ 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 <http://www.gnu.org/licenses/>. */
+
+#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
+#define NOINLINE_NOCLONE __attribute__ ((noinline, noclone))
+#else
+#define NOINLINE_NOCLONE __attribute__ ((noinline))
+#endif
+
+static void NOINLINE_NOCLONE
+cxxfunc (int i)
+{
+ *(volatile int *)0=0;
+ // Avoid tail call optimization.
+ asm volatile ("");
+}
+
+extern "C"
+{
+ static void NOINLINE_NOCLONE
+ f (void)
+ {
+ cxxfunc(1);
+ // Avoid tail call optimization.
+ asm volatile ("");
+ }
+}
+
+int
+main()
+{
+ f();
+}
diff --git a/tests/testfile-backtrace-demangle.core.bz2 b/tests/testfile-backtrace-demangle.core.bz2
new file mode 100644
index 00000000..c68edce1
--- /dev/null
+++ b/tests/testfile-backtrace-demangle.core.bz2
Binary files differ