This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
RFC: Initial patch to use runtime demangler
- From: Phil Edwards <phil at jaj dot com>
- To: libstdc++ at gcc dot gnu dot org
- Date: Thu, 28 Mar 2002 21:23:43 -0500
- Subject: RFC: Initial patch to use runtime demangler
This is diff'd against the trunk, no changelog, no testcases. Yet.
We need pieces of libiberty. We also need pieces of those pieces to
be conditionally compiled (or not). The result is one object file that
exports exactly one function, __cxa_demangle, and another object file that
exports the dyn-string functions (renamed to __cxa_* functions).
This builds and runs the library testsuite with no regressions.
Sugestions?
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 01:58:59 -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: 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 01:27:24 -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.40
diff -u -3 -p -r1.40 cp-demangle.c
--- libiberty/cp-demangle.c 12 Mar 2002 20:34:15 -0000 1.40
+++ libiberty/cp-demangle.c 29 Mar 2002 00:24:11 -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.6
diff -u -3 -p -r1.6 dyn-string.c
--- libiberty/dyn-string.c 27 Mar 2002 18:26:18 -0000 1.6
+++ libiberty/dyn-string.c 29 Mar 2002 01:33:43 -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/src/vterminate.cc
===================================================================
RCS file: /home/pme/Repositories/GCC/gcc/libstdc++-v3/src/vterminate.cc,v
retrieving revision 1.4
diff -u -3 -p -r1.4 vterminate.cc
--- libstdc++-v3/src/vterminate.cc 22 Mar 2002 20:13:43 -0000 1.4
+++ libstdc++-v3/src/vterminate.cc 28 Mar 2002 23:30:54 -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);