summaryrefslogtreecommitdiff
path: root/libstdc++-v3
diff options
context:
space:
mode:
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>2004-02-21 20:59:26 +0000
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>2004-02-21 20:59:26 +0000
commit1989928eb25ddc973220f58fb3db143c57a3ec71 (patch)
tree6d61b2824699cd8de17a0d01e06990679f06a550 /libstdc++-v3
parent667bb867a61a819c6271b3b287efaca22e0f1512 (diff)
downloadgcc-1989928eb25ddc973220f58fb3db143c57a3ec71.tar.gz
* libsupc++/vterminate.cc
(__gnu_cxx::__verbose_terminate_handler): Guard against recursive calls to terminate. * src/demangle.cc (__cxa_demangle): Wrap in try-catch block. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@78235 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/ChangeLog10
-rw-r--r--libstdc++-v3/libsupc++/vterminate.cc10
-rw-r--r--libstdc++-v3/src/demangle.cc100
3 files changed, 72 insertions, 48 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index a98b01df820..e560c6c16bc 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,5 +1,15 @@
2004-02-21 Mark Mitchell <mark@codesourcery.com>
+ * libsupc++/vterminate.cc
+ (__gnu_cxx::__verbose_terminate_handler): Guard against recursive
+ calls to terminate.
+ * src/demangle.cc (__cxa_demangle): Wrap in try-catch block.
+
+ * testsuite/testsuite_hooks.cc (__gnu_test::set_memory_limits): Do
+ not set RLIMIT_AS on HP-UX.
+
+2004-02-21 Mark Mitchell <mark@codesourcery.com>
+
* testsuite/testsuite_hooks.cc (__gnu_test::set_memory_limits): Do
not set RLIMIT_AS on HP-UX.
diff --git a/libstdc++-v3/libsupc++/vterminate.cc b/libstdc++-v3/libsupc++/vterminate.cc
index 38f6f617868..0ec9f2ccfe4 100644
--- a/libstdc++-v3/libsupc++/vterminate.cc
+++ b/libstdc++-v3/libsupc++/vterminate.cc
@@ -51,6 +51,16 @@ namespace __gnu_cxx
stderr. */
void __verbose_terminate_handler()
{
+ static bool terminating;
+
+ if (terminating)
+ {
+ writestr ("terminate called recursively\n");
+ abort ();
+ }
+
+ terminating = true;
+
// Make sure there was an exception; terminate is also called for an
// attempt to rethrow when there is no suitable exception.
type_info *t = __cxa_current_exception_type();
diff --git a/libstdc++-v3/src/demangle.cc b/libstdc++-v3/src/demangle.cc
index 1221f4cb40b..779076d3554 100644
--- a/libstdc++-v3/src/demangle.cc
+++ b/libstdc++-v3/src/demangle.cc
@@ -106,63 +106,67 @@ namespace __cxxabiv1
__cxa_demangle(char const* mangled_name, char* buf, std::size_t* n,
int* status)
{
- using namespace __gnu_cxx;
- typedef demangler::session<std::allocator<char> > session_type;
+ try {
+ using namespace __gnu_cxx;
+ typedef demangler::session<std::allocator<char> > session_type;
- if (!mangled_name || (buf && !n))
- return failure(invalid_argument, status);
+ if (!mangled_name || (buf && !n))
+ return failure(invalid_argument, status);
- std::string result;
- if (mangled_name[0] == '_')
- {
- // External name?
- if (mangled_name[1] == 'Z')
- {
- // C++ name?
- int cnt = session_type::
- decode_encoding(result, mangled_name + 2, INT_MAX);
- if (cnt < 0 || mangled_name[cnt + 2] != 0)
- return failure(invalid_mangled_name, status);
- return finish(result.data(), result.size(), buf, n, status);
- }
- else if (mangled_name[1] == 'G')
+ std::string result;
+ if (mangled_name[0] == '_')
{
- // Possible _GLOBAL__ extension?
- if (!std::strncmp(mangled_name, "_GLOBAL__", 9)
- && (mangled_name[9] == 'D' || mangled_name[9] == 'I')
- && mangled_name[10] == '_')
+ // External name?
+ if (mangled_name[1] == 'Z')
{
- if (mangled_name[9] == 'D')
- result.assign("global destructors keyed to ", 28);
- else
- result.assign("global constructors keyed to ", 29);
- // Output the disambiguation part as-is.
- result += mangled_name + 11;
+ // C++ name?
+ int cnt = session_type::
+ decode_encoding(result, mangled_name + 2, INT_MAX);
+ if (cnt < 0 || mangled_name[cnt + 2] != 0)
+ return failure(invalid_mangled_name, status);
return finish(result.data(), result.size(), buf, n, status);
}
+ else if (mangled_name[1] == 'G')
+ {
+ // Possible _GLOBAL__ extension?
+ if (!std::strncmp(mangled_name, "_GLOBAL__", 9)
+ && (mangled_name[9] == 'D' || mangled_name[9] == 'I')
+ && mangled_name[10] == '_')
+ {
+ if (mangled_name[9] == 'D')
+ result.assign("global destructors keyed to ", 28);
+ else
+ result.assign("global constructors keyed to ", 29);
+ // Output the disambiguation part as-is.
+ result += mangled_name + 11;
+ return finish(result.data(), result.size(), buf, n, status);
+ }
+ }
}
- }
- // Ambiguities are possible between extern "C" object names and
- // internal built-in type names, e.g. "i" may be either an object
- // named "i" or the built-in "int" type. Such ambiguities should
- // be resolved to user names over built-in names. Builtin types
- // are any single lower case character. Any other single
- // character is not a mangled type so we can treat those the same
- // here.
- if (mangled_name[1] == 0)
- return finish(mangled_name, 1, buf, n, status);
-
- // Not a built-in type or external name, try to demangle input as
- // NTBS mangled type name.
- session_type demangler_session(mangled_name, INT_MAX);
- if (!demangler_session.decode_type(result)
- || demangler_session.remaining_input_characters())
- {
- // Failure to demangle, assume extern "C" name.
- result = mangled_name;
+ // Ambiguities are possible between extern "C" object names and
+ // internal built-in type names, e.g. "i" may be either an object
+ // named "i" or the built-in "int" type. Such ambiguities should
+ // be resolved to user names over built-in names. Builtin types
+ // are any single lower case character. Any other single
+ // character is not a mangled type so we can treat those the same
+ // here.
+ if (mangled_name[1] == 0)
+ return finish(mangled_name, 1, buf, n, status);
+
+ // Not a built-in type or external name, try to demangle input as
+ // NTBS mangled type name.
+ session_type demangler_session(mangled_name, INT_MAX);
+ if (!demangler_session.decode_type(result)
+ || demangler_session.remaining_input_characters())
+ {
+ // Failure to demangle, assume extern "C" name.
+ result = mangled_name;
+ }
+ return finish(result.data(), result.size(), buf, n, status);
+ } catch (std::bad_alloc&) {
+ return failure(memory_allocation_failure, status);
}
- return finish(result.data(), result.size(), buf, n, status);
}
} // namespace __cxxabiv1