svn commit: r316356 - in stable/9: contrib/libcxxrt lib/libcxxrt

Dimitry Andric dim at FreeBSD.org
Sat Apr 1 12:27:04 UTC 2017


Author: dim
Date: Sat Apr  1 12:27:02 2017
New Revision: 316356
URL: https://svnweb.freebsd.org/changeset/base/316356

Log:
  Synchronize libcxxrt in stable/9 with stable/{10,11} and head.
  
  MFC r284549 (by emaste):
  
  Import libcxxrt master e64e93fe5bba67a6d52cbe5a97f8770c054bfa65
  
  This includes a number of fixes to the C++ demangler (obtained from
  upstream ELF Tool Chain).
  
  MFC r284551 (by emaste):
  
  Import libcxxrt master e64e93fe5bba67a6d52cbe5a97f8770c054bfa65.
  
  This includes a number of demangler fixes obtained from upstream
  ELF Tool Chain.
  
  PR:		200913
  Sponsored by:	The FreeBSD Foundation
  
  MFC r284553 (by emaste):
  
  Update libcxxrt upgrade instructions
  
  The typeinfo file no longer exists upstream.
  
  MFC r288830:
  
  Add std::uncaught_exceptions() to libcxxrt (C++17, see N4152 and N4259).
  This has also been submitted upstream.
  
  MFC r288830:
  
  Add std::uncaught_exceptions() to libcxxrt (C++17, see N4152 and N4259).
  This has also been submitted upstream.
  
  MFC r297299:
  
  Compile libcxxrt as C++11, since it is only really used in combination
  with libc++, which is also C++11.  Also change one _Static_assert (which
  is really C11) back into static_assert, like upstream.
  
  This should help when compiling libcxxrt with newer versions of gcc,
  which refuse to recognize any form of static assertions, if not
  compiling for C++11 or higher.
  
  While here, add -nostdinc++ to CFLAGS, to prevent picking up any C++
  headers outside the source tree.
  
  MFC r299144:
  
  Import libcxxrt master 516a65c109eb0a01e5e95fbef455eb3215135cef.
  
  Interesting fixes:
  3adaa2e Fix _Unwind_Exception cleanup functions
  286776c Check exception cleanup function ptr before calling
  edda626 Correct exception specifications on new and delete operators
  
  MFC r303157 (by emaste):
  
  libcxxrt: add padding in __cxa_allocate_* to fix alignment
  
  The addition of the referenceCount to __cxa_allocate_exception put the
  unwindHeader at offset 0x58 in __cxa_exception, but it requires 16-byte
  alignment. In order to avoid changing the current __cxa_exception ABI
  (and thus breaking its consumers), add explicit padding in the
  allocation routines (and account for it when freeing).
  
  This is intended as a lower-risk change for FreeBSD 11. A "more correct"
  fix should be prepared for upstream and -CURRENT.
  
  Reviewed by:	dim
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D7271
  
  MFC r303400 (by emaste):
  
  libcxxrt: fix demangling of wchar_t
  
  'wchar_t' is 7 characters long, not 6. r303297 fixed this in libelftc,
  but not the second copy of this file that we have in libcxxrt.
  
  PR:		208661
  Submitted by:	Daniel McRobb
  Obtained from:	ELF Tool Chain r3480
  
  MFC r305396:
  
  Add _US_ACTION_MASK to libcxxrt's arm-specific unwind header.  This
  value is used in newer versions of compiler-rt.
  
  MFC r315947 | dim | 2017-03-25 14:17:48 +0100 (Sat, 25 Mar 2017) | 8 lines
  
  Import libcxxrt master 8a853717e61d5d55cbdf74d9d0a7545da5d5ff92.
  
  Interesting fixes which were not already merged:
  0c7c611 Merge C++ demangler bug fixes from ELF Tool Chain (#40)
  2b208d9 __cxa_demangle_gnu3: demangle 'z' as '...', not 'ellipsis' (#41)

Modified:
  stable/9/contrib/libcxxrt/FREEBSD-upgrade
  stable/9/contrib/libcxxrt/exception.cc
  stable/9/contrib/libcxxrt/guard.cc
  stable/9/contrib/libcxxrt/libelftc_dem_gnu3.c
  stable/9/contrib/libcxxrt/memory.cc
  stable/9/contrib/libcxxrt/unwind-arm.h
  stable/9/lib/libcxxrt/Makefile
  stable/9/lib/libcxxrt/Version.map
Directory Properties:
  stable/9/   (props changed)
  stable/9/contrib/   (props changed)
  stable/9/contrib/libcxxrt/   (props changed)
  stable/9/lib/   (props changed)
  stable/9/lib/libcxxrt/   (props changed)

Modified: stable/9/contrib/libcxxrt/FREEBSD-upgrade
==============================================================================
--- stable/9/contrib/libcxxrt/FREEBSD-upgrade	Sat Apr  1 12:22:34 2017	(r316355)
+++ stable/9/contrib/libcxxrt/FREEBSD-upgrade	Sat Apr  1 12:27:02 2017	(r316356)
@@ -3,4 +3,4 @@ $FreeBSD$
 This is the FreeBSD copy of libcxxrt.  It contains the src directory from the 
 upstream repository.
 
-When updating, copy *.{c,cc,h} and typeinfo from the upstream src/.
+When updating, copy *.{c,cc,h} from the upstream src/.

Modified: stable/9/contrib/libcxxrt/exception.cc
==============================================================================
--- stable/9/contrib/libcxxrt/exception.cc	Sat Apr  1 12:22:34 2017	(r316355)
+++ stable/9/contrib/libcxxrt/exception.cc	Sat Apr  1 12:27:02 2017	(r316356)
@@ -304,13 +304,17 @@ static pthread_key_t eh_key;
 static void exception_cleanup(_Unwind_Reason_Code reason, 
                               struct _Unwind_Exception *ex)
 {
-	__cxa_free_exception(static_cast<void*>(ex));
+	// Exception layout:
+	// [__cxa_exception [_Unwind_Exception]] [exception object]
+	//
+	// __cxa_free_exception expects a pointer to the exception object
+	__cxa_free_exception(static_cast<void*>(ex + 1));
 }
 static void dependent_exception_cleanup(_Unwind_Reason_Code reason, 
                               struct _Unwind_Exception *ex)
 {
 
-	__cxa_free_dependent_exception(static_cast<void*>(ex));
+	__cxa_free_dependent_exception(static_cast<void*>(ex + 1));
 }
 
 /**
@@ -340,7 +344,8 @@ static void thread_cleanup(void* thread_
 		if (info->foreign_exception_state != __cxa_thread_info::none)
 		{
 			_Unwind_Exception *e = reinterpret_cast<_Unwind_Exception*>(info->globals.caughtExceptions);
-			e->exception_cleanup(_URC_FOREIGN_EXCEPTION_CAUGHT, e);
+			if (e->exception_cleanup)
+				e->exception_cleanup(_URC_FOREIGN_EXCEPTION_CAUGHT, e);
 		}
 		else
 		{
@@ -567,6 +572,19 @@ static void free_exception(char *e)
 	}
 }
 
+#ifdef __LP64__
+/**
+ * There's an ABI bug in __cxa_exception: unwindHeader requires 16-byte
+ * alignment but it was broken by the addition of the referenceCount.
+ * The unwindHeader is at offset 0x58 in __cxa_exception.  In order to keep
+ * compatibility with consumers of the broken __cxa_exception, explicitly add
+ * padding on allocation (and account for it on free).
+ */
+static const int exception_alignment_padding = 8;
+#else
+static const int exception_alignment_padding = 0;
+#endif
+
 /**
  * Allocates an exception structure.  Returns a pointer to the space that can
  * be used to store an object of thrown_size bytes.  This function will use an
@@ -575,16 +593,19 @@ static void free_exception(char *e)
  */
 extern "C" void *__cxa_allocate_exception(size_t thrown_size)
 {
-	size_t size = thrown_size + sizeof(__cxa_exception);
+	size_t size = exception_alignment_padding + sizeof(__cxa_exception) +
+	    thrown_size;
 	char *buffer = alloc_or_die(size);
-	return buffer+sizeof(__cxa_exception);
+	return buffer + exception_alignment_padding + sizeof(__cxa_exception);
 }
 
 extern "C" void *__cxa_allocate_dependent_exception(void)
 {
-	size_t size = sizeof(__cxa_dependent_exception);
+	size_t size = exception_alignment_padding +
+	    sizeof(__cxa_dependent_exception);
 	char *buffer = alloc_or_die(size);
-	return buffer+sizeof(__cxa_dependent_exception);
+	return buffer + exception_alignment_padding +
+	    sizeof(__cxa_dependent_exception);
 }
 
 /**
@@ -612,7 +633,8 @@ extern "C" void __cxa_free_exception(voi
 		}
 	}
 
-	free_exception(reinterpret_cast<char*>(ex));
+	free_exception(reinterpret_cast<char*>(ex) -
+	    exception_alignment_padding);
 }
 
 static void releaseException(__cxa_exception *exception)
@@ -639,7 +661,8 @@ void __cxa_free_dependent_exception(void
 	{
 		releaseException(realExceptionFromException(reinterpret_cast<__cxa_exception*>(ex)));
 	}
-	free_exception(reinterpret_cast<char*>(ex));
+	free_exception(reinterpret_cast<char*>(ex) -
+	    exception_alignment_padding);
 }
 
 /**
@@ -1282,12 +1305,13 @@ extern "C" void __cxa_end_catch()
 	
 	if (ti->foreign_exception_state != __cxa_thread_info::none)
 	{
-		globals->caughtExceptions = 0;
 		if (ti->foreign_exception_state != __cxa_thread_info::rethrown)
 		{
 			_Unwind_Exception *e = reinterpret_cast<_Unwind_Exception*>(ti->globals.caughtExceptions);
-			e->exception_cleanup(_URC_FOREIGN_EXCEPTION_CAUGHT, e);
+			if (e->exception_cleanup)
+				e->exception_cleanup(_URC_FOREIGN_EXCEPTION_CAUGHT, e);
 		}
+		globals->caughtExceptions = 0;
 		ti->foreign_exception_state = __cxa_thread_info::none;
 		return;
 	}
@@ -1474,6 +1498,15 @@ namespace std
 		return info->globals.uncaughtExceptions != 0;
 	}
 	/**
+	 * Returns the number of exceptions currently being thrown that have not
+	 * been caught.  This can occur inside a nested catch statement.
+	 */
+	int uncaught_exceptions() throw()
+	{
+		__cxa_thread_info *info = thread_info();
+		return info->globals.uncaughtExceptions;
+	}
+	/**
 	 * Returns the current unexpected handler.
 	 */
 	unexpected_handler get_unexpected() throw()

Modified: stable/9/contrib/libcxxrt/guard.cc
==============================================================================
--- stable/9/contrib/libcxxrt/guard.cc	Sat Apr  1 12:22:34 2017	(r316355)
+++ stable/9/contrib/libcxxrt/guard.cc	Sat Apr  1 12:27:02 2017	(r316356)
@@ -101,7 +101,7 @@ typedef struct {
 	uint32_t init_half;
 	uint32_t lock_half;
 } guard_t;
-_Static_assert(sizeof(guard_t) == sizeof(uint64_t), "");
+static_assert(sizeof(guard_t) == sizeof(uint64_t), "");
 static const uint32_t LOCKED = 1;
 static const uint32_t INITIALISED = static_cast<guard_lock_t>(1) << 24;
 #	endif

Modified: stable/9/contrib/libcxxrt/libelftc_dem_gnu3.c
==============================================================================
--- stable/9/contrib/libcxxrt/libelftc_dem_gnu3.c	Sat Apr  1 12:22:34 2017	(r316355)
+++ stable/9/contrib/libcxxrt/libelftc_dem_gnu3.c	Sat Apr  1 12:27:02 2017	(r316356)
@@ -59,7 +59,7 @@ struct vector_str {
 
 enum type_qualifier {
 	TYPE_PTR, TYPE_REF, TYPE_CMX, TYPE_IMG, TYPE_EXT, TYPE_RST, TYPE_VAT,
-	TYPE_CST
+	TYPE_CST, TYPE_VEC
 };
 
 struct vector_type_qualifier {
@@ -397,6 +397,8 @@ static int	cpp_demangle_read_array(struc
 static int	cpp_demangle_read_encoding(struct cpp_demangle_data *);
 static int	cpp_demangle_read_expr_primary(struct cpp_demangle_data *);
 static int	cpp_demangle_read_expression(struct cpp_demangle_data *);
+static int	cpp_demangle_read_expression_flat(struct cpp_demangle_data *,
+		    char **);
 static int	cpp_demangle_read_expression_binary(struct cpp_demangle_data *,
 		    const char *, size_t);
 static int	cpp_demangle_read_expression_unary(struct cpp_demangle_data *,
@@ -408,8 +410,12 @@ static int	cpp_demangle_read_function(st
 static int	cpp_demangle_local_source_name(struct cpp_demangle_data *ddata);
 static int	cpp_demangle_read_local_name(struct cpp_demangle_data *);
 static int	cpp_demangle_read_name(struct cpp_demangle_data *);
+static int	cpp_demangle_read_name_flat(struct cpp_demangle_data *,
+		    char**);
 static int	cpp_demangle_read_nested_name(struct cpp_demangle_data *);
 static int	cpp_demangle_read_number(struct cpp_demangle_data *, long *);
+static int	cpp_demangle_read_number_as_string(struct cpp_demangle_data *,
+		    char **);
 static int	cpp_demangle_read_nv_offset(struct cpp_demangle_data *);
 static int	cpp_demangle_read_offset(struct cpp_demangle_data *);
 static int	cpp_demangle_read_offset_number(struct cpp_demangle_data *);
@@ -423,6 +429,8 @@ static int	cpp_demangle_read_tmpl_arg(st
 static int	cpp_demangle_read_tmpl_args(struct cpp_demangle_data *);
 static int	cpp_demangle_read_tmpl_param(struct cpp_demangle_data *);
 static int	cpp_demangle_read_type(struct cpp_demangle_data *, int);
+static int	cpp_demangle_read_type_flat(struct cpp_demangle_data *,
+		    char **);
 static int	cpp_demangle_read_uqname(struct cpp_demangle_data *);
 static int	cpp_demangle_read_v_offset(struct cpp_demangle_data *);
 static char	*decode_fp_to_double(const char *, size_t);
@@ -601,17 +609,18 @@ cpp_demangle_push_fp(struct cpp_demangle
 	fp = ddata->cur;
 	while (*ddata->cur != 'E')
 		++ddata->cur;
-	++ddata->cur;
 
 	if ((f = decoder(fp, ddata->cur - fp)) == NULL)
 		return (0);
 
 	rtn = 0;
 	if ((len = strlen(f)) > 0)
-		rtn = cpp_demangle_push_str(ddata, f, len); 
+		rtn = cpp_demangle_push_str(ddata, f, len);
 
 	free(f);
 
+	++ddata->cur;
+
 	return (rtn);
 }
 
@@ -695,7 +704,8 @@ cpp_demangle_push_type_qualifier(struct 
 			if (type_str != NULL) {
 				if (!vector_str_push(&subst_v, "*", 1))
 					goto clean;
-				if (!cpp_demangle_push_subst_v(ddata, &subst_v))
+				if (!cpp_demangle_push_subst_v(ddata,
+				    &subst_v))
 					goto clean;
 			}
 			break;
@@ -706,7 +716,8 @@ cpp_demangle_push_type_qualifier(struct 
 			if (type_str != NULL) {
 				if (!vector_str_push(&subst_v, "&", 1))
 					goto clean;
-				if (!cpp_demangle_push_subst_v(ddata, &subst_v))
+				if (!cpp_demangle_push_subst_v(ddata,
+				    &subst_v))
 					goto clean;
 			}
 			break;
@@ -717,7 +728,8 @@ cpp_demangle_push_type_qualifier(struct 
 			if (type_str != NULL) {
 				if (!vector_str_push(&subst_v, " complex", 8))
 					goto clean;
-				if (!cpp_demangle_push_subst_v(ddata, &subst_v))
+				if (!cpp_demangle_push_subst_v(ddata,
+				    &subst_v))
 					goto clean;
 			}
 			break;
@@ -726,23 +738,26 @@ cpp_demangle_push_type_qualifier(struct 
 			if (!cpp_demangle_push_str(ddata, " imaginary", 10))
 				goto clean;
 			if (type_str != NULL) {
-				if (!vector_str_push(&subst_v, " imaginary", 10))
+				if (!vector_str_push(&subst_v, " imaginary",
+				    10))
 					goto clean;
-				if (!cpp_demangle_push_subst_v(ddata, &subst_v))
+				if (!cpp_demangle_push_subst_v(ddata,
+				    &subst_v))
 					goto clean;
 			}
 			break;
 
 		case TYPE_EXT:
-			if (e_idx > v->ext_name.size - 1)
+			if (v->ext_name.size == 0 ||
+			    e_idx > v->ext_name.size - 1)
 				goto clean;
-			if ((e_len = strlen(v->ext_name.container[e_idx])) == 0)
+			if ((e_len = strlen(v->ext_name.container[e_idx])) ==
+			    0)
 				goto clean;
-			if ((buf = malloc(sizeof(char) * (e_len + 1))) == NULL)
+			if ((buf = malloc(e_len + 2)) == NULL)
 				goto clean;
-
-			memcpy(buf, " ", 1);
-			memcpy(buf + 1, v->ext_name.container[e_idx], e_len);
+			snprintf(buf, e_len + 2, " %s",
+			    v->ext_name.container[e_idx]);
 
 			if (!cpp_demangle_push_str(ddata, buf, e_len + 1)) {
 				free(buf);
@@ -755,7 +770,8 @@ cpp_demangle_push_type_qualifier(struct 
 					free(buf);
 					goto clean;
 				}
-				if (!cpp_demangle_push_subst_v(ddata, &subst_v)) {
+				if (!cpp_demangle_push_subst_v(ddata,
+				    &subst_v)) {
 					free(buf);
 					goto clean;
 				}
@@ -770,7 +786,8 @@ cpp_demangle_push_type_qualifier(struct 
 			if (type_str != NULL) {
 				if (!vector_str_push(&subst_v, " restrict", 9))
 					goto clean;
-				if (!cpp_demangle_push_subst_v(ddata, &subst_v))
+				if (!cpp_demangle_push_subst_v(ddata,
+				    &subst_v))
 					goto clean;
 			}
 			break;
@@ -781,7 +798,8 @@ cpp_demangle_push_type_qualifier(struct 
 			if (type_str != NULL) {
 				if (!vector_str_push(&subst_v, " volatile", 9))
 					goto clean;
-				if (!cpp_demangle_push_subst_v(ddata, &subst_v))
+				if (!cpp_demangle_push_subst_v(ddata,
+				    &subst_v))
 					goto clean;
 			}
 			break;
@@ -792,12 +810,43 @@ cpp_demangle_push_type_qualifier(struct 
 			if (type_str != NULL) {
 				if (!vector_str_push(&subst_v, " const", 6))
 					goto clean;
-				if (!cpp_demangle_push_subst_v(ddata, &subst_v))
+				if (!cpp_demangle_push_subst_v(ddata,
+				    &subst_v))
 					goto clean;
 			}
 			break;
 
-		};
+		case TYPE_VEC:
+			if (v->ext_name.size == 0 ||
+			    e_idx > v->ext_name.size - 1)
+				goto clean;
+			if ((e_len = strlen(v->ext_name.container[e_idx])) ==
+			    0)
+				goto clean;
+			if ((buf = malloc(e_len + 12)) == NULL)
+				goto clean;
+			snprintf(buf, e_len + 12, " __vector(%s)",
+			    v->ext_name.container[e_idx]);
+			if (!cpp_demangle_push_str(ddata, buf, e_len + 11)) {
+				free(buf);
+				goto clean;
+			}
+			if (type_str != NULL) {
+				if (!vector_str_push(&subst_v, buf,
+				    e_len + 11)) {
+					free(buf);
+					goto clean;
+				}
+				if (!cpp_demangle_push_subst_v(ddata,
+				    &subst_v)) {
+					free(buf);
+					goto clean;
+				}
+			}
+			free(buf);
+			++e_idx;
+			break;
+		}
 		--idx;
 	}
 
@@ -947,14 +996,18 @@ cpp_demangle_read_expr_primary(struct cp
 
 	switch (*ddata->cur) {
 	case 'b':
+		if (*(ddata->cur + 2) != 'E')
+			return (0);
 		switch (*(++ddata->cur)) {
 		case '0':
+			ddata->cur += 2;
 			return (cpp_demangle_push_str(ddata, "false", 5));
 		case '1':
+			ddata->cur += 2;
 			return (cpp_demangle_push_str(ddata, "true", 4));
 		default:
 			return (0);
-		};
+		}
 
 	case 'd':
 		++ddata->cur;
@@ -999,11 +1052,12 @@ cpp_demangle_read_expr_primary(struct cp
 			++ddata->cur;
 		}
 		++ddata->cur;
-		return (cpp_demangle_push_str(ddata, num, ddata->cur - num));
+		return (cpp_demangle_push_str(ddata, num,
+		    ddata->cur - num - 1));
 
 	default:
 		return (0);
-	};
+	}
 }
 
 static int
@@ -1278,19 +1332,51 @@ cpp_demangle_read_expression(struct cpp_
 		/* operator sizeof */
 		ddata->cur += 2;
 		return (cpp_demangle_read_expression_unary(ddata, "sizeof", 6));
-	};
+	}
 
 	switch (*ddata->cur) {
 	case 'L':
 		return (cpp_demangle_read_expr_primary(ddata));
 	case 'T':
 		return (cpp_demangle_read_tmpl_param(ddata));
-	};
+	}
 
 	return (0);
 }
 
 static int
+cpp_demangle_read_expression_flat(struct cpp_demangle_data *ddata, char **str)
+{
+	struct vector_str *output;
+	size_t i, p_idx, idx, exp_len;
+	char *exp;
+
+	output = ddata->push_head > 0 ? &ddata->output_tmp :
+	    &ddata->output;
+
+	p_idx = output->size;
+
+	if (!cpp_demangle_read_expression(ddata))
+		return (0);
+
+	if ((exp = vector_str_substr(output, p_idx, output->size - 1,
+	    &exp_len)) == NULL)
+		return (0);
+
+	idx = output->size;
+	for (i = p_idx; i < idx; ++i) {
+		if (!vector_str_pop(output)) {
+			free(exp);
+			return (0);
+		}
+	}
+
+	*str = exp;
+
+	return (1);
+}
+
+static int
 cpp_demangle_read_expression_binary(struct cpp_demangle_data *ddata,
     const char *name, size_t len)
 {
@@ -1419,12 +1505,67 @@ cpp_demangle_read_function(struct cpp_de
 static int
 cpp_demangle_read_encoding(struct cpp_demangle_data *ddata)
 {
+	char *name, *type, *num_str;
+	long offset;
+	int rtn;
 
 	if (ddata == NULL || *ddata->cur == '\0')
 		return (0);
 
 	/* special name */
 	switch (SIMPLE_HASH(*ddata->cur, *(ddata->cur + 1))) {
+	case SIMPLE_HASH('G', 'A'):
+		if (!cpp_demangle_push_str(ddata, "hidden alias for ", 17))
+			return (0);
+		ddata->cur += 2;
+		if (*ddata->cur == '\0')
+			return (0);
+		return (cpp_demangle_read_encoding(ddata));
+
+	case SIMPLE_HASH('G', 'R'):
+		if (!cpp_demangle_push_str(ddata, "reference temporary #", 21))
+			return (0);
+		ddata->cur += 2;
+		if (*ddata->cur == '\0')
+			return (0);
+		if (!cpp_demangle_read_name_flat(ddata, &name))
+			return (0);
+		rtn = 0;
+		if (!cpp_demangle_read_number_as_string(ddata, &num_str))
+			goto clean1;
+		if (!cpp_demangle_push_str(ddata, num_str, strlen(num_str)))
+			goto clean2;
+		if (!cpp_demangle_push_str(ddata, " for ", 5))
+			goto clean2;
+		if (!cpp_demangle_push_str(ddata, name, strlen(name)))
+			goto clean2;
+		rtn = 1;
+	clean2:
+		free(num_str);
+	clean1:
+		free(name);
+		return (rtn);
+
+	case SIMPLE_HASH('G', 'T'):
+		ddata->cur += 2;
+		if (*ddata->cur == '\0')
+			return (0);
+		switch (*ddata->cur) {
+		case 'n':
+			if (!cpp_demangle_push_str(ddata,
+			    "non-transaction clone for ", 26))
+				return (0);
+			break;
+		case 't':
+		default:
+			if (!cpp_demangle_push_str(ddata,
+			    "transaction clone for ", 22))
+				return (0);
+			break;
+		}
+		++ddata->cur;
+		return (cpp_demangle_read_encoding(ddata));
+
 	case SIMPLE_HASH('G', 'V'):
 		/* sentry object for 1 time init */
 		if (!cpp_demangle_push_str(ddata, "guard variable for ", 20))
@@ -1446,14 +1587,49 @@ cpp_demangle_read_encoding(struct cpp_de
 			return (0);
 		return (cpp_demangle_read_encoding(ddata));
 
+	case SIMPLE_HASH('T', 'C'):
+		/* construction vtable */
+		if (!cpp_demangle_push_str(ddata, "construction vtable for ",
+		    24))
+			return (0);
+		ddata->cur += 2;
+		if (*ddata->cur == '\0')
+			return (0);
+		if (!cpp_demangle_read_type_flat(ddata, &type))
+			return (0);
+		rtn = 0;
+		if (!cpp_demangle_read_number(ddata, &offset))
+			goto clean3;
+		if (*ddata->cur++ != '_')
+			goto clean3;
+		if (!cpp_demangle_read_type(ddata, 0))
+			goto clean3;
+		if (!cpp_demangle_push_str(ddata, "-in-", 4))
+			goto clean3;
+		if (!cpp_demangle_push_str(ddata, type, strlen(type)))
+			goto clean3;
+		rtn = 1;
+	clean3:
+		free(type);
+		return (rtn);
+
 	case SIMPLE_HASH('T', 'D'):
 		/* typeinfo common proxy */
 		break;
 
+	case SIMPLE_HASH('T', 'F'):
+		/* typeinfo fn */
+		if (!cpp_demangle_push_str(ddata, "typeinfo fn for ", 16))
+			return (0);
+		ddata->cur += 2;
+		if (*ddata->cur == '\0')
+			return (0);
+		return (cpp_demangle_read_type(ddata, 0));
+
 	case SIMPLE_HASH('T', 'h'):
 		/* virtual function non-virtual override thunk */
-		if (cpp_demangle_push_str(ddata,
-		    "virtual function non-virtual override ", 38) == 0)
+		if (!cpp_demangle_push_str(ddata,
+		    "virtual function non-virtual override ", 38))
 			return (0);
 		ddata->cur += 2;
 		if (*ddata->cur == '\0')
@@ -1462,24 +1638,51 @@ cpp_demangle_read_encoding(struct cpp_de
 			return (0);
 		return (cpp_demangle_read_encoding(ddata));
 
+	case SIMPLE_HASH('T', 'H'):
+		/* TLS init function */
+		if (!cpp_demangle_push_str(ddata, "TLS init function for ",
+		    22))
+			return (0);
+		ddata->cur += 2;
+		if (*ddata->cur == '\0')
+			return (0);
+		break;
+
 	case SIMPLE_HASH('T', 'I'):
 		/* typeinfo structure */
-		/* FALLTHROUGH */
+		if (!cpp_demangle_push_str(ddata, "typeinfo for ", 13))
+			return (0);
+		ddata->cur += 2;
+		if (*ddata->cur == '\0')
+			return (0);
+		return (cpp_demangle_read_type(ddata, 0));
+
+	case SIMPLE_HASH('T', 'J'):
+		/* java class */
+		if (!cpp_demangle_push_str(ddata, "java Class for ", 15))
+			return (0);
+		ddata->cur += 2;
+		if (*ddata->cur == '\0')
+			return (0);
+		return (cpp_demangle_read_type(ddata, 0));
+
 	case SIMPLE_HASH('T', 'S'):
 		/* RTTI name (NTBS) */
-		if (!cpp_demangle_push_str(ddata, "typeinfo for ", 14))
+		if (!cpp_demangle_push_str(ddata, "typeinfo name for ", 18))
 			return (0);
 		ddata->cur += 2;
 		if (*ddata->cur == '\0')
 			return (0);
-		return (cpp_demangle_read_type(ddata, 1));
+		return (cpp_demangle_read_type(ddata, 0));
 
 	case SIMPLE_HASH('T', 'T'):
 		/* VTT table */
 		if (!cpp_demangle_push_str(ddata, "VTT for ", 8))
 			return (0);
 		ddata->cur += 2;
-		return (cpp_demangle_read_type(ddata, 1));
+		if (*ddata->cur == '\0')
+			return (0);
+		return (cpp_demangle_read_type(ddata, 0));
 
 	case SIMPLE_HASH('T', 'v'):
 		/* virtual function virtual override thunk */
@@ -1500,8 +1703,18 @@ cpp_demangle_read_encoding(struct cpp_de
 		ddata->cur += 2;
 		if (*ddata->cur == '\0')
 			return (0);
-		return (cpp_demangle_read_type(ddata, 1));
-	};
+		return (cpp_demangle_read_type(ddata, 0));
+
+	case SIMPLE_HASH('T', 'W'):
+		/* TLS wrapper function */
+		if (!cpp_demangle_push_str(ddata, "TLS wrapper function for ",
+		    25))
+			return (0);
+		ddata->cur += 2;
+		if (*ddata->cur == '\0')
+			return (0);
+		break;
+	}
 
 	return (cpp_demangle_read_name(ddata));
 }
@@ -1573,7 +1786,7 @@ cpp_demangle_read_name(struct cpp_demang
 		return (cpp_demangle_read_nested_name(ddata));
 	case 'Z':
 		return (cpp_demangle_read_local_name(ddata));
-	};
+	}
 
 	if (!vector_str_init(&v))
 		return (0);
@@ -1618,6 +1831,38 @@ clean:
 }
 
 static int
+cpp_demangle_read_name_flat(struct cpp_demangle_data *ddata, char **str)
+{
+	struct vector_str *output;
+	size_t i, p_idx, idx, name_len;
+	char *name;
+
+	output = ddata->push_head > 0 ? &ddata->output_tmp :
+	    &ddata->output;
+
+	p_idx = output->size;
+
+	if (!cpp_demangle_read_name(ddata))
+		return (0);
+
+	if ((name = vector_str_substr(output, p_idx, output->size - 1,
+	    &name_len)) == NULL)
+		return (0);
+
+	idx = output->size;
+	for (i = p_idx; i < idx; ++i) {
+		if (!vector_str_pop(output)) {
+			free(name);
+			return (0);
+		}
+	}
+
+	*str = name;
+
+	return (1);
+}
+
+static int
 cpp_demangle_read_nested_name(struct cpp_demangle_data *ddata)
 {
 	struct vector_str *output, v;
@@ -1642,7 +1887,7 @@ cpp_demangle_read_nested_name(struct cpp
 		case 'K':
 			ddata->mem_cst = true;
 			break;
-		};
+		}
 		++ddata->cur;
 	}
 
@@ -1670,7 +1915,7 @@ cpp_demangle_read_nested_name(struct cpp
 		default:
 			if (!cpp_demangle_read_uqname(ddata))
 				goto clean;
-		};
+		}
 
 		if ((subst_str = vector_str_substr(output, p_idx,
 		    output->size - 1, &subst_str_len)) == NULL)
@@ -1743,6 +1988,24 @@ cpp_demangle_read_number(struct cpp_dema
 }
 
 static int
+cpp_demangle_read_number_as_string(struct cpp_demangle_data *ddata, char **str)
+{
+	long n;
+
+	if (!cpp_demangle_read_number(ddata, &n)) {
+		*str = NULL;
+		return (0);
+	}
+
+	if (asprintf(str, "%ld", n) < 0) {
+		*str = NULL;
+		return (0);
+	}
+
+	return (1);
+}
+
+static int
 cpp_demangle_read_nv_offset(struct cpp_demangle_data *ddata)
 {
 
@@ -1877,11 +2140,11 @@ cpp_demangle_read_sname(struct cpp_deman
 	    len <= 0)
 		return (0);
 
- 	if (len == 12 && (memcmp("_GLOBAL__N_1", ddata->cur, 12) == 0))
+	if (len == 12 && (memcmp("_GLOBAL__N_1", ddata->cur, 12) == 0))
 		err = cpp_demangle_push_str(ddata, "(anonymous namespace)", 21);
 	else
 		err = cpp_demangle_push_str(ddata, ddata->cur, len);
-	
+
 	if (err == 0)
 		return (0);
 
@@ -1927,35 +2190,35 @@ cpp_demangle_read_subst(struct cpp_deman
 
 	case SIMPLE_HASH('S', 'd'):
 		/* std::basic_iostream<char, std::char_traits<char> > */
-		if (!cpp_demangle_push_str(ddata, "std::iostream", 19))
+		if (!cpp_demangle_push_str(ddata, "std::basic_iostream", 19))
 			return (0);
-		ddata->last_sname = "iostream";
+		ddata->last_sname = "basic_iostream";
 		ddata->cur += 2;
 		if (*ddata->cur == 'I')
 			return (cpp_demangle_read_subst_stdtmpl(ddata,
-			    "std::iostream", 19));
+			    "std::basic_iostream", 19));
 		return (1);
 
 	case SIMPLE_HASH('S', 'i'):
 		/* std::basic_istream<char, std::char_traits<char> > */
-		if (!cpp_demangle_push_str(ddata, "std::istream", 18))
+		if (!cpp_demangle_push_str(ddata, "std::basic_istream", 18))
 			return (0);
-		ddata->last_sname = "istream";
+		ddata->last_sname = "basic_istream";
 		ddata->cur += 2;
 		if (*ddata->cur == 'I')
 			return (cpp_demangle_read_subst_stdtmpl(ddata,
-			    "std::istream", 18));
+			    "std::basic_istream", 18));
 		return (1);
 
 	case SIMPLE_HASH('S', 'o'):
 		/* std::basic_ostream<char, std::char_traits<char> > */
-		if (!cpp_demangle_push_str(ddata, "std::ostream", 18))
+		if (!cpp_demangle_push_str(ddata, "std::basic_ostream", 18))
 			return (0);
-		ddata->last_sname = "istream";
+		ddata->last_sname = "basic_ostream";
 		ddata->cur += 2;
 		if (*ddata->cur == 'I')
 			return (cpp_demangle_read_subst_stdtmpl(ddata,
-			    "std::ostream", 18));
+			    "std::basic_ostream", 18));
 		return (1);
 
 	case SIMPLE_HASH('S', 's'):
@@ -1977,7 +2240,7 @@ cpp_demangle_read_subst(struct cpp_deman
 	case SIMPLE_HASH('S', 't'):
 		/* std:: */
 		return (cpp_demangle_read_subst_std(ddata));
-	};
+	}
 
 	if (*(++ddata->cur) == '\0')
 		return (0);
@@ -2125,7 +2388,7 @@ cpp_demangle_read_tmpl_arg(struct cpp_de
 		return (cpp_demangle_read_expr_primary(ddata));
 	case 'X':
 		return (cpp_demangle_read_expression(ddata));
-	};
+	}
 
 	return (cpp_demangle_read_type(ddata, 0));
 }
@@ -2232,7 +2495,7 @@ cpp_demangle_read_type(struct cpp_demang
 	size_t p_idx, type_str_len;
 	int extern_c, is_builtin;
 	long len;
-	char *type_str;
+	char *type_str, *exp_str, *num_str;
 
 	if (ddata == NULL)
 		return (0);
@@ -2274,7 +2537,7 @@ cpp_demangle_read_type(struct cpp_demang
 	extern_c = 0;
 	is_builtin = 1;
 	p_idx = output->size;
-	type_str = NULL;
+	type_str = exp_str = num_str = NULL;
 again:
 	/* builtin type */
 	switch (*ddata->cur) {
@@ -2320,6 +2583,82 @@ again:
 		++ddata->cur;
 		goto rtn;
 
+	case 'D':
+		++ddata->cur;
+		switch (*ddata->cur) {
+		case 'd':
+			/* IEEE 754r decimal floating point (64 bits) */
+			if (!cpp_demangle_push_str(ddata, "decimal64", 9))
+				goto clean;
+			++ddata->cur;
+			break;
+		case 'e':
+			/* IEEE 754r decimal floating point (128 bits) */
+			if (!cpp_demangle_push_str(ddata, "decimal128", 10))
+				goto clean;
+			++ddata->cur;
+			break;
+		case 'f':
+			/* IEEE 754r decimal floating point (32 bits) */
+			if (!cpp_demangle_push_str(ddata, "decimal32", 9))
+				goto clean;
+			++ddata->cur;
+			break;
+		case 'h':
+			/* IEEE 754r half-precision floating point (16 bits) */
+			if (!cpp_demangle_push_str(ddata, "half", 4))
+				goto clean;
+			++ddata->cur;
+			break;
+		case 'i':
+			/* char32_t */
+			if (!cpp_demangle_push_str(ddata, "char32_t", 8))
+				goto clean;
+			++ddata->cur;
+			break;
+		case 'n':
+			/* std::nullptr_t (i.e., decltype(nullptr)) */
+			if (!cpp_demangle_push_str(ddata, "decltype(nullptr)",
+			    17))
+				goto clean;
+			++ddata->cur;
+			break;
+		case 's':
+			/* char16_t */
+			if (!cpp_demangle_push_str(ddata, "char16_t", 8))
+				goto clean;
+			++ddata->cur;
+			break;
+		case 'v':
+			/* gcc vector_size extension. */
+			++ddata->cur;
+			if (*ddata->cur == '_') {
+				++ddata->cur;
+				if (!cpp_demangle_read_expression_flat(ddata,
+				    &exp_str))
+					goto clean;
+				if (!vector_str_push(&v.ext_name, exp_str,
+				    strlen(exp_str)))
+					goto clean;
+			} else {
+				if (!cpp_demangle_read_number_as_string(ddata,
+				    &num_str))
+					goto clean;
+				if (!vector_str_push(&v.ext_name, num_str,
+				    strlen(num_str)))
+					goto clean;
+			}
+			if (*ddata->cur != '_')
+				goto clean;
+			++ddata->cur;
+			if (!vector_type_qualifier_push(&v, TYPE_VEC))
+				goto clean;
+			goto again;
+		default:
+			goto clean;
+		}
+		goto rtn;
+
 	case 'e':
 		/* long double */
 		if (!cpp_demangle_push_str(ddata, "long double", 11))
@@ -2414,7 +2753,7 @@ again:
 
 	case 'o':
 		/* unsigned __int128 */
-		if (!cpp_demangle_push_str(ddata, "unsigned _;int128", 17))
+		if (!cpp_demangle_push_str(ddata, "unsigned __int128", 17))
 			goto clean;
 		++ddata->cur;
 		goto rtn;
@@ -2485,6 +2824,8 @@ again:
 		if (!vector_str_push(&v.ext_name, ddata->cur, len))
 			return (0);
 		ddata->cur += len;
+		if (!vector_type_qualifier_push(&v, TYPE_EXT))
+			goto clean;
 		goto again;
 
 	case 'v':
@@ -2503,7 +2844,7 @@ again:
 
 	case 'w':
 		/* wchar_t */
-		if (!cpp_demangle_push_str(ddata, "wchar_t", 6))
+		if (!cpp_demangle_push_str(ddata, "wchar_t", 7))
 			goto clean;
 		++ddata->cur;
 		goto rtn;
@@ -2524,11 +2865,11 @@ again:
 
 	case 'z':
 		/* ellipsis */
-		if (!cpp_demangle_push_str(ddata, "ellipsis", 8))
+		if (!cpp_demangle_push_str(ddata, "...", 3))
 			goto clean;
 		++ddata->cur;
 		goto rtn;
-	};
+	}
 
 	if (!cpp_demangle_read_name(ddata))
 		goto clean;
@@ -2549,6 +2890,8 @@ rtn:
 		goto clean;
 
 	free(type_str);
+	free(exp_str);
+	free(num_str);
 	vector_type_qualifier_dest(&v);
 
 	if (ddata->push_head > 0) {
@@ -2580,11 +2923,45 @@ rtn:
 	return (1);
 clean:
 	free(type_str);
+	free(exp_str);
+	free(num_str);
 	vector_type_qualifier_dest(&v);
 
 	return (0);
 }
 
+static int
+cpp_demangle_read_type_flat(struct cpp_demangle_data *ddata, char **str)
+{
+	struct vector_str *output;
+	size_t i, p_idx, idx, type_len;
+	char *type;
+
+	output = ddata->push_head > 0 ? &ddata->output_tmp :
+	    &ddata->output;
+
+	p_idx = output->size;
+
+	if (!cpp_demangle_read_type(ddata, 0))
+		return (0);
+
+	if ((type = vector_str_substr(output, p_idx, output->size - 1,
+	    &type_len)) == NULL)
+		return (0);
+
+	idx = output->size;
+	for (i = p_idx; i < idx; ++i) {
+		if (!vector_str_pop(output)) {
+			free(type);
+			return (0);
+		}
+	}
+
+	*str = type;
+
+	return (1);
+}
+
 /*

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***


More information about the svn-src-stable-9 mailing list