Look for __cxa_demangle in libstdc++ as well, fix test case

- Resolves: #827422
This commit is contained in:
Petr Machata 2012-06-01 20:10:08 +02:00
parent aa961fbb7f
commit 9bde653069
3 changed files with 99 additions and 5 deletions

View File

@ -385,8 +385,8 @@ index 7fffa76..959715a 100644
#include "proc.h"
+#include "forward.h"
#if defined HAVE_LIBIBERTY || defined HAVE_LIBSUPC__
# define USE_DEMANGLE
#if defined HAVE_LIBSUPC__ || defined HAVE_LIBSTDC__
# define USE_CXA_DEMANGLE
@@ -24,93 +47,13 @@ extern char * command;
extern int exiting; /* =1 if we have to exit ASAP */

View File

@ -0,0 +1,86 @@
diff --git a/Makefile.am b/Makefile.am
index 256c940..593e943 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -35,6 +35,7 @@ libltrace_la_LIBADD = \
$(libelf_LIBS) \
$(liberty_LIBS) \
$(libsupcxx_LIBS) \
+ $(libstdcxx_LIBS) \
$(libunwind_LIBS) \
$(libunwind_ptrace_LIBS) \
$(libunwind_arch_LIBS) \
diff --git a/common.h b/common.h
index 7fffa76..b84a5d1 100644
--- a/common.h
+++ b/common.h
@@ -16,7 +16,10 @@
#include "read_config_file.h"
#include "proc.h"
-#if defined HAVE_LIBIBERTY || defined HAVE_LIBSUPC__
+#if defined HAVE_LIBSUPC__ || defined HAVE_LIBSTDC__
+# define USE_CXA_DEMANGLE
+#endif
+#if defined HAVE_LIBIBERTY || defined USE_CXA_DEMANGLE
# define USE_DEMANGLE
#endif
diff --git a/configure.ac b/configure.ac
index 707f8c5..1ec7242 100644
--- a/configure.ac
+++ b/configure.ac
@@ -82,6 +82,14 @@ AC_CHECK_LIB([supc++], [__cxa_demangle], [
AC_SUBST(libsupcxx_LIBS)
+# HAVE_LIBSTDC__
+AC_CHECK_LIB([stdc++], [__cxa_demangle], [
+ AC_DEFINE([HAVE_LIBSTDC__], [1], [we have libstdc++])
+ libstdcxx_LIBS="-lstdc++"], [
+ libstdcxx_LIBS=""])
+AC_SUBST(libstdcxx_LIBS)
+
+
dnl Check security_get_boolean_active availability.
AC_CHECK_HEADERS(selinux/selinux.h)
AC_CHECK_LIB(selinux, security_get_boolean_active)
diff --git a/demangle.c b/demangle.c
index 5825e28..26a5c7a 100644
--- a/demangle.c
+++ b/demangle.c
@@ -15,9 +15,8 @@ static Dict *d = NULL;
const char *
my_demangle(const char *function_name) {
const char *tmp, *fn_copy;
-#if !defined HAVE_LIBIBERTY && defined HAVE_LIBSUPC__
+#ifdef USE_CXA_DEMANGLE
extern char *__cxa_demangle(const char *, char *, size_t *, int *);
- int status = 0;
#endif
debug(DEBUG_FUNCTION, "my_demangle(name=%s)", function_name);
@@ -30,7 +29,8 @@ my_demangle(const char *function_name) {
fn_copy = strdup(function_name);
#ifdef HAVE_LIBIBERTY
tmp = cplus_demangle(function_name, DMGL_ANSI | DMGL_PARAMS);
-#elif defined HAVE_LIBSUPC__
+#elif defined USE_CXA_DEMANGLE
+ int status = 0;
tmp = __cxa_demangle(function_name, NULL, NULL, &status);
#endif
if (!tmp)
diff --git a/testsuite/ltrace.minor/demangle.exp b/testsuite/ltrace.minor/demangle.exp
index c2d3aeb..9dd7694 100644
--- a/testsuite/ltrace.minor/demangle.exp
+++ b/testsuite/ltrace.minor/demangle.exp
@@ -32,6 +32,9 @@ if [regexp {ELF from incompatible architecture} $exec_output] {
} elseif [ regexp {Couldn't get .hash data} $exec_output ] {
fail "Couldn't get .hash data!"
return
+} elseif [ regexp {invalid option} $exec_output ] {
+ unsupported "Demangle support not compiled in."
+ return
}
# read function declarations from demangle.cpp and verify them in demangle.ltrace.

View File

@ -1,7 +1,7 @@
Summary: Tracks runtime library calls from dynamically linked executables
Name: ltrace
Version: 0.6.0
Release: 15%{?dist}
Release: 16%{?dist}
URL: http://ltrace.alioth.debian.org/
License: GPLv2+
Group: Development/Debuggers
@ -33,8 +33,9 @@ Patch17: ltrace-0.6.0-ppc-lwarx.patch
Patch18: ltrace-0.6.0-libs.patch
Patch19: ltrace-0.6.0-libs-fixes-1.patch
Patch20: ltrace-0.6.0-dash-n.patch
Patch21: ltrace-0.6.0-abi.patch
Patch22: ltrace-0.6.0-abi-s390.patch
Patch21: ltrace-0.6.0-demangle.patch
Patch22: ltrace-0.6.0-abi.patch
Patch23: ltrace-0.6.0-abi-s390.patch
%description
Ltrace is a debugging program which runs a specified command until the
@ -68,6 +69,7 @@ execution of processes.
%patch20 -p1
%patch21 -p1
%patch22 -p1
%patch23 -p1
%build
# This ugly hack is necessary to build and link files for correct
@ -95,6 +97,12 @@ echo ====================TESTING END=====================
%config(noreplace) %{_sysconfdir}/ltrace.conf
%changelog
* Fri Jun 1 2012 Petr Machata <pmachata@redhat.com> - 0.6.0-16
- Look for __cxa_demangle in libstdc++ as well
- Demangle test case should report it's unsupported if demangling
support isn't compiled in (ltrace-0.6.0-demangle.patch)
- Resolves: #827422
* Thu May 31 2012 Petr Machata <pmachata@redhat.com> - 0.6.0-15
- Add upstream patches for parameter passing. Apart from a couple of
fixes, this brings in s390 support (ltrace-0.6.0-abi-s390.patch)