Commit 6f94dea7 by Benjamin Kosnik Committed by Benjamin Kosnik

vterminate.cc (__gnu_cxx::__verbose_terminate_handler): Only use fputs, not write.


2004-02-23  Benjamin Kosnik  <bkoz@redhat.com>

	* libsupc++/vterminate.cc (__gnu_cxx::__verbose_terminate_handler):
	Only use fputs, not write.

From-SVN: r78327
parent e0740893
2004-02-23 Benjamin Kosnik <bkoz@redhat.com> 2004-02-23 Benjamin Kosnik <bkoz@redhat.com>
* libsupc++/vterminate.cc (__gnu_cxx::__verbose_terminate_handler):
Only use fputs, not write.
2004-02-23 Benjamin Kosnik <bkoz@redhat.com>
* include/ext/malloc_allocator.h: Add operators ==, !=. * include/ext/malloc_allocator.h: Add operators ==, !=.
* include/ext/new_allocator.h: Add operators ==, !=. * include/ext/new_allocator.h: Add operators ==, !=.
* include/ext/mt_allocator.h (__mt_alloc::tune): New. * include/ext/mt_allocator.h (__mt_alloc::tune): New.
......
// Verbose terminate_handler -*- C++ -*- // Verbose terminate_handler -*- C++ -*-
// Copyright (C) 2001, 2002 Free Software Foundation // Copyright (C) 2001, 2002, 2004 Free Software Foundation
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the // software; you can redistribute it and/or modify it under the
...@@ -32,33 +32,24 @@ ...@@ -32,33 +32,24 @@
#include <exception> #include <exception>
#include <exception_defines.h> #include <exception_defines.h>
#include <cxxabi.h> #include <cxxabi.h>
#ifdef _GLIBCXX_HAVE_UNISTD_H
# include <unistd.h>
# define writestr(str) write(2, str, __builtin_strlen(str))
#else
# include <cstdio> # include <cstdio>
# define writestr(str) std::fputs(str, stderr)
#endif
using namespace std; using namespace std;
using namespace abi; using namespace abi;
namespace __gnu_cxx namespace __gnu_cxx
{ {
/* A replacement for the standard terminate_handler which prints // A replacement for the standard terminate_handler which prints
more information about the terminating exception (if any) on // more information about the terminating exception (if any) on
stderr. */ // stderr.
void __verbose_terminate_handler() void __verbose_terminate_handler()
{ {
static bool terminating; static bool terminating;
if (terminating) if (terminating)
{ {
writestr ("terminate called recursively\n"); fputs("terminate called recursively\n", stderr);
abort (); abort ();
} }
terminating = true; terminating = true;
// Make sure there was an exception; terminate is also called for an // Make sure there was an exception; terminate is also called for an
...@@ -66,42 +57,41 @@ namespace __gnu_cxx ...@@ -66,42 +57,41 @@ namespace __gnu_cxx
type_info *t = __cxa_current_exception_type(); type_info *t = __cxa_current_exception_type();
if (t) if (t)
{ {
char const *name = t->name();
// Note that "name" is the mangled name. // Note that "name" is the mangled name.
char const *name = t->name();
{ {
int status = -1; int status = -1;
char *dem = 0; char *dem = 0;
dem = __cxa_demangle(name, 0, 0, &status); dem = __cxa_demangle(name, 0, 0, &status);
writestr("terminate called after throwing an instance of '"); fputs("terminate called after throwing an instance of '", stderr);
if (status == 0) if (status == 0)
writestr(dem); fputs(dem, stderr);
else else
writestr(name); fputs(name, stderr);
writestr("'\n"); fputs("'\n", stderr);
if (status == 0) if (status == 0)
free(dem); free(dem);
} }
// If the exception is derived from std::exception, we can give more // If the exception is derived from std::exception, we can
// information. // give more information.
try { __throw_exception_again; } try { __throw_exception_again; }
#ifdef __EXCEPTIONS #ifdef __EXCEPTIONS
catch (exception &exc) catch (exception &exc)
{ {
char const *w = exc.what(); char const *w = exc.what();
writestr(" what(): "); fputs(" what(): ", stderr);
writestr(w); fputs(w, stderr);
writestr("\n"); fputs("\n", stderr);
} }
#endif #endif
catch (...) { } catch (...) { }
} }
else else
writestr("terminate called without an active exception\n"); fputs("terminate called without an active exception\n", stderr);
abort(); abort();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment