This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
[libstdc++] Make use of runtime demangler
- From: Phil Edwards <phil at jaj dot com>
- To: libstdc++ at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Fri, 29 Mar 2002 18:29:24 -0500
- Subject: [libstdc++] Make use of runtime demangler
This builds the new __cxa_demangle'r into the C++ support library.
We link to cp-demangle.c and dyn-string.c, then compile them locally into v3.
Two important notes:
1) Those two files do not build warning-free because in the v3 build,
-DHAVE_CONFIG_H is not passed (thus the headers for malloc and whatnot
are not included) because we can't give it the config.h from libiberty.
I played with building a symlink to libiberty's config.h but I don't
know the multilibs scenario well enough. Help is requested. For now,
we pass -Wno-error in the special build rules.
2) All the code to make the demangler part of the runtime lib is guarded
by IN_LIBGCC2. In v3-land, we could claim to be libgcc, but that
would be both (a) a confusing blatant lie, and (b) not enough, because
cp-demangle.c exports three functions, two of which we /must not/ allow
into the .o file, else they will collide with the ones in libiberty.a
whenever that's linked into a C++ program.
(The functions are is_gnu_v3_mangled_*, declared in demangle.h.
Marking them local in the symver map won't work because not all systems
use the symver map.)
So, we introduce a new guard macro, IN_GLIBCPP_V3, and use it alongside
IN_LIBGCC2. We also use it to /not/ compile the extra two functions.
Tested on i686-linux, trunk and branch, no regressions. Also tried the
sample code given in 19_diagnostics/howto.html on "how to use the verbose
terminate handler," which uses the demangler; it works on both trunk and
branch. Benjamin's already approved the v3 parts; I still need approval
on the include/libiberty change for trunk and branch.
include:
2002-03-29 Phil Edwards <pme@gcc.gnu.org>
* dyn-string.h: Also allow IN_GLIBCPP_V3 to redefine names.
libiberty:
2002-03-29 Phil Edwards <pme@gcc.gnu.org>
* cp-demangle.c (__cxa_demangle): Also protect with IN_GLIBCPP_V3.
(is_gnu_v3_mangled_ctor, is_gnu_v3_mangled_ctor): Conditionally
not compile if IN_GLIBCPP_V3 defined.
* dyn-string.c: Also allow IN_GLIBCPP_V3 to change allocation scheme.
libstdc++-v3:
2002-03-29 Phil Edwards <pme@gcc.gnu.org>
* config/linker-map.gnu: Export __verbose_terminate_handler.
* libsupc++/Makefile.am (sources): Add cxa_demangle.c, dyn-string.c.
Make new LTCOMPILE variable, use it in new special build rules.
* libsupc++/Makefile.in: Rebuild.
* src/vterminate.cc (__verbose_terminate_handler): Enable use of
runtime __cxa_demangle.
* docs/html/install.html: Update prereqs and instructions.
* docs/html/19_diagnostics/howto.html: Bring naming for
verbose_terminate_handler into line with reality.
Index: include/dyn-string.h
===================================================================
RCS file: /home/pme/Repositories/GCC/gcc/include/dyn-string.h,v
retrieving revision 1.5
diff -u -3 -p -r1.5 dyn-string.h
--- include/dyn-string.h 23 Aug 2001 12:07:58 -0000 1.5
+++ include/dyn-string.h 29 Mar 2002 22:57:12 -0000
@@ -1,5 +1,5 @@
/* An abstract string datatype.
- Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2000, 2002 Free Software Foundation, Inc.
Contributed by Mark Mitchell (mark@markmitchell.com).
This file is part of GCC.
@@ -45,7 +45,7 @@ typedef struct dyn_string
names in user programs, the functions that are used in the
demangler are given implementation-reserved names. */
-#ifdef IN_LIBGCC2
+#if defined(IN_LIBGCC2) || defined(IN_GLIBCPP_V3)
#define dyn_string_init __cxa_dyn_string_init
#define dyn_string_new __cxa_dyn_string_new
@@ -66,7 +66,7 @@ typedef struct dyn_string
#define dyn_string_substring __cxa_dyn_string_substring
#define dyn_string_eq __cxa_dyn_string_eq
-#endif /* IN_LIBGCC2 */
+#endif /* IN_LIBGCC2 || IN_GLIBCPP_V3 */
extern int dyn_string_init PARAMS ((struct dyn_string *, int));
Index: libiberty/cp-demangle.c
===================================================================
RCS file: /home/pme/Repositories/GCC/gcc/libiberty/cp-demangle.c,v
retrieving revision 1.39.2.1
diff -u -3 -p -r1.39.2.1 cp-demangle.c
--- libiberty/cp-demangle.c 12 Mar 2002 20:42:36 -0000 1.39.2.1
+++ libiberty/cp-demangle.c 29 Mar 2002 22:57:12 -0000
@@ -3577,7 +3577,7 @@ cp_demangle_type (type_name, result)
return status;
}
-#ifdef IN_LIBGCC2
+#if defined(IN_LIBGCC2) || defined(IN_GLIBCPP_V3)
extern char *__cxa_demangle PARAMS ((const char *, char *, size_t *, int *));
/* ia64 ABI-mandated entry point in the C++ runtime library for performing
@@ -3685,7 +3685,7 @@ __cxa_demangle (mangled_name, output_buf
}
}
-#else /* !IN_LIBGCC2 */
+#else /* ! (IN_LIBGCC2 || IN_GLIBCPP_V3) */
/* Variant entry point for integration with the existing cplus-dem
demangler. Attempts to demangle MANGLED. If the demangling
@@ -3850,7 +3850,7 @@ java_demangle_v3 (mangled)
return return_value;
}
-#endif /* IN_LIBGCC2 */
+#endif /* IN_LIBGCC2 || IN_GLIBCPP_V3 */
/* Demangle NAME in the G++ V3 ABI demangling style, and return either
@@ -3890,6 +3890,7 @@ demangle_v3_with_details (name)
}
+#ifndef IN_GLIBCPP_V3
/* Return non-zero iff NAME is the mangled form of a constructor name
in the G++ V3 ABI demangling style. Specifically, return:
- '1' if NAME is a complete object constructor,
@@ -3932,6 +3933,7 @@ is_gnu_v3_mangled_dtor (name)
else
return 0;
}
+#endif /* IN_GLIBCPP_V3 */
#ifdef STANDALONE_DEMANGLER
Index: libiberty/dyn-string.c
===================================================================
RCS file: /home/pme/Repositories/GCC/gcc/libiberty/dyn-string.c,v
retrieving revision 1.5.26.1
diff -u -3 -p -r1.5.26.1 dyn-string.c
--- libiberty/dyn-string.c 27 Mar 2002 18:25:32 -0000 1.5.26.1
+++ libiberty/dyn-string.c 29 Mar 2002 22:57:12 -0000
@@ -50,7 +50,7 @@ Boston, MA 02111-1307, USA. */
abort if an allocation fails. Instead, percolate an error code up
through the call chain. */
-#ifdef IN_LIBGCC2
+#if defined(IN_LIBGCC2) || defined(IN_GLIBCPP_V3)
#define RETURN_ON_ALLOCATION_FAILURE
#endif
Index: libstdc++-v3/config/linker-map.gnu
===================================================================
RCS file: /home/pme/Repositories/GCC/gcc/libstdc++-v3/config/linker-map.gnu,v
retrieving revision 1.5.2.2
diff -u -3 -p -r1.5.2.2 linker-map.gnu
--- libstdc++-v3/config/linker-map.gnu 8 Mar 2002 22:25:41 -0000 1.5.2.2
+++ libstdc++-v3/config/linker-map.gnu 29 Mar 2002 22:57:12 -0000
@@ -100,6 +100,9 @@ CXXABI_1 {
__gxx_personality_v0;
__dynamic_cast;
+ # __gnu_cxx::_verbose_terminate_handler()
+ _ZN9__gnu_cxx27__verbose_terminate_handlerEv;
+
local:
*;
};
Index: libstdc++-v3/docs/html/install.html
===================================================================
RCS file: /home/pme/Repositories/GCC/gcc/libstdc++-v3/docs/html/install.html,v
retrieving revision 1.12
diff -u -3 -p -r1.12 install.html
--- libstdc++-v3/docs/html/install.html 19 Dec 2001 21:36:32 -0000 1.12
+++ libstdc++-v3/docs/html/install.html 29 Mar 2002 22:57:12 -0000
@@ -75,6 +75,13 @@
well as releases) of binutils
<a href="ftp://sources.redhat.com/pub/binutils">here</a>.
</p>
+
+ <p>If you are using a 3.1-series libstdc++ snapshot, then the
+ requirements are slightly more stringent: the compiler sources must
+ also be 3.1 or later (for both technical and licensing reasons), and
+ your binutils must be 2.11.95 or later if you want to use symbol
+ versioning in shared libraries.
+ </p>
<!-- Commented until some system-specific requirements appear.
<p>Finally, a few system-specific requirements:
@@ -145,7 +152,8 @@
<h2><a name="config">Configuring</a></h2>
<p>If you have never done this before, you should read the basic
<a href="http://gcc.gnu.org/install/">GCC Installation
- Instructions</a> first. Read <em>all of them</em>. Twice.
+ Instructions</a> first. Read <em>all of them</em>.
+ <strong>Twice.</strong>
</p>
<p>When building libstdc++-v3 you'll have to configure
the entire <em>gccsrcdir</em> directory. The full list of libstdc++-v3
@@ -214,6 +222,10 @@
<em>cpu-vendor-os</em>/bits/
ext/</pre>
</p>
+ <p>If you used the version-specific-libs configure option, then most of
+ the headers and library files will be moved under
+ <code>lib/gcc-lib/</code> instead.
+ </p>
<p>You can check the status of the build without installing it using
<pre>
make check</pre>
@@ -254,7 +266,7 @@
<li>GNU ld (default on Linux):<code> -Wl,--rpath,<em>destdir</em>/lib</code>
<li>IRIX ld:<code> -Wl,-rpath,<em>destdir</em>/lib</code>
<li>Solaris ld:<code> -Wl,-R<em>destdir</em>/lib</code>
- <li>More...?
+ <li>More...? Let us know!
</ul>
</ul>
</p>
Index: libstdc++-v3/docs/html/19_diagnostics/howto.html
===================================================================
RCS file: /home/pme/Repositories/GCC/gcc/libstdc++-v3/docs/html/19_diagnostics/howto.html,v
retrieving revision 1.14.2.1
diff -u -3 -p -r1.14.2.1 howto.html
--- libstdc++-v3/docs/html/19_diagnostics/howto.html 27 Mar 2002 22:38:38 -0000 1.14.2.1
+++ libstdc++-v3/docs/html/19_diagnostics/howto.html 29 Mar 2002 22:57:12 -0000
@@ -119,12 +119,12 @@
int main()
{
- std::set_terminate (__gnu_cxx::verbose_terminate_handler);
+ std::set_terminate (__gnu_cxx::__verbose_terminate_handler);
...
throw <em>anything</em>;
}</pre>
</p>
- <p>The <code> verbose_terminate_handler </code> function obtains the name
+ <p>The <code> __verbose_terminate_handler </code> function obtains the name
of the current exception, attempts to demangle it, and prints it to
stderr. If the exception is derived from <code> std::exception </code>
then the output from <code>what()</code> will be included.
@@ -145,7 +145,7 @@
int main (int argc)
{
- std::set_terminate (__gnu_cxx::verbose_terminate_handler);
+ std::set_terminate (__gnu_cxx::__verbose_terminate_handler);
if (argc > 5)
throw BLARGH("argc is greater than 5!");
else
Index: libstdc++-v3/libsupc++/Makefile.am
===================================================================
RCS file: /home/pme/Repositories/GCC/gcc/libstdc++-v3/libsupc++/Makefile.am,v
retrieving revision 1.29
diff -u -3 -p -r1.29 Makefile.am
--- libstdc++-v3/libsupc++/Makefile.am 18 Nov 2001 02:09:23 -0000 1.29
+++ libstdc++-v3/libsupc++/Makefile.am 29 Mar 2002 22:57:12 -0000
@@ -1,6 +1,6 @@
## Makefile for the GNU C++ Support library.
##
-## Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+## Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
##
## Process this file with automake to produce Makefile.in.
##
@@ -27,6 +27,7 @@ MAINT_CHARSET = latin1
mkinstalldirs = $(SHELL) $(toplevel_srcdir)/mkinstalldirs
# Cross compiler and multilib support.
+CC = @CC@
CXX = @glibcpp_CXX@
toolexecdir = @glibcpp_toolexecdir@
toolexeclibdir = @glibcpp_toolexeclibdir@
@@ -66,10 +67,12 @@ headers = \
exception new typeinfo cxxabi.h exception_defines.h
sources = \
+ cxa_demangle.c \
del_op.cc \
del_opnt.cc \
del_opv.cc \
del_opvnt.cc \
+ dyn-string.c \
eh_alloc.cc \
eh_aux_runtime.cc \
eh_catch.cc \
@@ -96,6 +99,28 @@ glibcppinstalldir = @gxx_include_dir@
glibcppinstall_HEADERS = $(headers)
LIBSUPCXX_CXXFLAGS = $(LIBSUPCXX_PICFLAGS)
+
+# Use special rules for pulling things out of libiberty.
+cxa_demangle.c:
+ rm -f $@
+ $(LN_S) $(toplevel_srcdir)/libiberty/cp-demangle.c $@
+cxa_demangle.lo: cxa_demangle.c
+ $(LTCOMPILE) -DIN_GLIBCPP_V3 -Wno-error -c $<
+cxa_demangle.o: cxa_demangle.c
+ $(COMPILE) -DIN_GLIBCPP_V3 -Wno-error -c $<
+dyn-string.c:
+ rm -f $@
+ $(LN_S) $(toplevel_srcdir)/libiberty/dyn-string.c $@
+dyn-string.lo: dyn-string.c
+ $(LTCOMPILE) -DIN_GLIBCPP_V3 -Wno-error -c $<
+dyn-string.o: dyn-string.c
+ $(COMPILE) -DIN_GLIBCPP_V3 -Wno-error -c $<
+
+# LTCOMPILE is copied from LTCXXCOMPILE below.
+LTCOMPILE = $(LIBTOOL) --tag CC --tag disable-shared \
+ --mode=compile $(CC) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(AM_CXXFLAGS)
+
# AM_CXXFLAGS needs to be in each subdirectory so that it can be
# modified in a per-library or per-sub-library way. Need to manually
Index: libstdc++-v3/src/vterminate.cc
===================================================================
RCS file: /home/pme/Repositories/GCC/gcc/libstdc++-v3/src/vterminate.cc,v
retrieving revision 1.3.12.1
diff -u -3 -p -r1.3.12.1 vterminate.cc
--- libstdc++-v3/src/vterminate.cc 22 Mar 2002 20:31:23 -0000 1.3.12.1
+++ libstdc++-v3/src/vterminate.cc 29 Mar 2002 22:57:12 -0000
@@ -56,10 +56,8 @@ namespace __gnu_cxx
int status = -1;
char *dem = 0;
-#if 0
// Disabled until __cxa_demangle gets the runtime GPL exception.
dem = __cxa_demangle(name, 0, 0, &status);
-#endif
printf("terminate called after throwing a `%s'\n",
status == 0 ? dem : name);