+2014-01-15 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ Fix corruption of non-C++ symbols by the demangler.
+ * nm.c (show_symbols_sysv, show_symbols_bsd, show_symbols_posix)
+ (show_symbols): Check for _Z.
+ * stack.c (print_frames) <USE_DEMANGLE>: Check for _Z.
+
2014-01-02 Mark Wielaard <mjw@redhat.com>
* stack.c (show_raw): Declare unconditionally.
symstrbuf, sizeof symstrbuf);
#ifdef USE_DEMANGLE
- /* Demangle if necessary. */
- if (demangle)
+ /* Demangle if necessary. Require GNU v3 ABI by the "_Z" prefix. */
+ if (demangle && symstr[0] == '_' && symstr[1] == 'Z')
{
int status = -1;
char *dmsymstr = __cxa_demangle (symstr, demangle_buffer,
continue;
#ifdef USE_DEMANGLE
- /* Demangle if necessary. */
- if (demangle)
+ /* Demangle if necessary. Require GNU v3 ABI by the "_Z" prefix. */
+ if (demangle && symstr[0] == '_' && symstr[1] == 'Z')
{
int status = -1;
char *dmsymstr = __cxa_demangle (symstr, demangle_buffer,
continue;
#ifdef USE_DEMANGLE
- /* Demangle if necessary. */
- if (demangle)
+ /* Demangle if necessary. Require GNU v3 ABI by the "_Z" prefix. */
+ if (demangle && symstr[0] == '_' && symstr[1] == 'Z')
{
int status = -1;
char *dmsymstr = __cxa_demangle (symstr, demangle_buffer,
continue;
#ifdef USE_DEMANGLE
- /* Demangle if necessary. */
- if (demangle)
+ /* Demangle if necessary. Require GNU v3 ABI by the "_Z" prefix. */
+ if (demangle && symstr[0] == '_' && symstr[1] == 'Z')
{
int status = -1;
char *dmsymstr = __cxa_demangle (symstr, demangle_buffer,
/* Unwinding of frames like gstack/pstack.
- Copyright (C) 2013 Red Hat, Inc.
+ Copyright (C) 2013-2014 Red Hat, Inc.
This file is part of elfutils.
This file is free software; you can redistribute it and/or modify
if (symname != NULL)
{
#ifdef USE_DEMANGLE
- if (! show_raw)
+ // Require GNU v3 ABI by the "_Z" prefix.
+ if (! show_raw && symname[0] == '_' && symname[1] == 'Z')
{
int status = -1;
char *dsymname = __cxa_demangle (symname, demangle_buffer,
+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
## 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
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
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'
--- /dev/null
+#! /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
--- /dev/null
+/* 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();
+}