From 7f7fb4ef6afe59f0df474b27741fae51e358fd7c Mon Sep 17 00:00:00 2001 From: Benjamin Kosnik Date: Tue, 3 Feb 2004 01:26:12 +0000 Subject: [PATCH] howto.html: Move verbose terminate documentation... 2004-02-02 Benjamin Kosnik * docs/html/19_diagnostics/howto.html: Move verbose terminate documentation... * docs/html/18_support/howto.html: Here. * docs/html/documentation.html: Add reference here. From-SVN: r77150 --- libstdc++-v3/ChangeLog | 7 ++ libstdc++-v3/docs/html/18_support/howto.html | 83 +++++++++++++++++-- .../docs/html/19_diagnostics/howto.html | 70 ---------------- libstdc++-v3/docs/html/documentation.html | 6 +- 4 files changed, 86 insertions(+), 80 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index f59e01eda7a..751858f962b 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,10 @@ +2004-02-02 Benjamin Kosnik + + * docs/html/19_diagnostics/howto.html: Move verbose terminate + documentation... + * docs/html/18_support/howto.html: Here. + * docs/html/documentation.html: Add reference here. + 2004-02-02 Paolo Carlini * config/locale/gnu/c++locale_internal.h: Remove prototypes diff --git a/libstdc++-v3/docs/html/18_support/howto.html b/libstdc++-v3/docs/html/18_support/howto.html index 7344c95ebd2..35fd9305022 100644 --- a/libstdc++-v3/docs/html/18_support/howto.html +++ b/libstdc++-v3/docs/html/18_support/howto.html @@ -42,8 +42,9 @@
  • Types
  • Implementation properties
  • Start and Termination
  • -
  • Dynamic memory management
  • -
  • RTTI, the ABI, and demangling
  • +
  • Verbose terminate
  • +
  • Dynamic memory management
  • +
  • RTTI, the ABI, and demangling

  • @@ -216,10 +217,78 @@


    -

    Dynamic memory management

    -

    There are six flavors each of new and delete, so - make certain that you're using the right ones! Here are quickie - descriptions of new: +

    Verbose terminate

    +

    If you are having difficulty with uncaught exceptions and want a + little bit of help debugging the causes of the core dumps, you can + make use of a GNU extension in GCC 3.1 and later: +

    +
    +   #include <exception>
    +
    +   int main()
    +   {
    +       std::set_terminate(__gnu_cxx::__verbose_terminate_handler);
    +       ...
    +       throw anything;
    +   }
    +

    The __verbose_terminate_handler function obtains the name + of the current exception, attempts to demangle it, and prints it to + stderr. If the exception is derived from std::exception + then the output from what() will be included. +

    +

    Any replacement termination function is required to kill the program + without returning; this one calls abort. +

    +

    For example: +

    +
    +   #include <exception>
    +   #include <stdexcept>
    +
    +   struct argument_error : public std::runtime_error
    +   {  
    +     argument_error(const std::string& s): std::runtime_error(s) { }
    +   };
    +
    +   int main(int argc)
    +   {
    +     std::set_terminate(__gnu_cxx::__verbose_terminate_handler);
    +     if (argc > 5)
    +       throw argument_error("argc is greater than 5!");
    +     else
    +       throw argc;
    +   }
    +   
    +

    In GCC 3.1 and later, this gives +

    +
    +   % ./a.out
    +   terminate called after throwing a `int'
    +   Aborted
    +   % ./a.out f f f f f f f f f f f
    +   terminate called after throwing an instance of `argument_error'
    +   what(): argc is greater than 5!
    +   Aborted
    +   %
    +

    The 'Aborted' line comes from the call to abort(), of course. +

    +

    UPDATE: Starting with GCC 3.4, this is the default + termination handler; nothing need be done to use it. To go back to + the previous "silent death" method, simply include + <exception> and <cstdlib>, + and call +

    +
    +       std::set_terminate(std::abort);
    +

    Return to top of page or + to the FAQ. +

    + +
    +

    Dynamic memory management

    +

    There are six flavors each of new and + delete, so make certain that you're using the right + ones! Here are quickie descriptions of new:


    @@ -121,75 +120,6 @@ to the FAQ.

    -
    -

    Verbose terminate

    -

    If you are having difficulty with uncaught exceptions and want a - little bit of help debugging the causes of the core dumps, you can - make use of a GNU extension in GCC 3.1 and later: -

    -
    -   #include <exception>
    -
    -   int main()
    -   {
    -       std::set_terminate (__gnu_cxx::__verbose_terminate_handler);
    -       ...
    -       throw anything;
    -   }
    -

    The __verbose_terminate_handler function obtains the name - of the current exception, attempts to demangle it, and prints it to - stderr. If the exception is derived from std::exception - then the output from what() will be included. -

    -

    Any replacement termination function is required to kill the program - without returning; this one calls abort. -

    -

    For example: -

    -
    -   #include <exception>
    -   #include <stdexcept>
    -
    -   struct BLARGH : std::runtime_error
    -   {
    -       BLARGH (const string& whatarg)
    -           : std::runtime_error(whatarg) { }
    -   };
    -
    -   int main (int argc)
    -   {
    -       std::set_terminate (__gnu_cxx::__verbose_terminate_handler);
    -       if (argc > 5)
    -           throw BLARGH("argc is greater than 5!");
    -       else
    -           throw argc;
    -   }
    -

    In GCC 3.1 and later, this gives -

    -
    -   % ./a.out
    -   terminate called after throwing a `int'
    -   Aborted
    -   % ./a.out f f f f f f f f f f f
    -   terminate called after throwing a `BLARGH'
    -   what(): argc is greater than 5!
    -   Aborted
    -   %
    -

    The 'Aborted' line comes from the call to abort(), of course. -

    -

    UPDATE: Starting with GCC 3.4, this is the default - termination handler; nothing need be done to use it. To go back to - the previous "silent death" method, simply include - <exception> and <cstdlib>, - and call -

    -
    -       std::set_terminate (std::abort);
    -

    Return to top of page or - to the FAQ. -

    - -
    diff --git a/libstdc++-v3/docs/html/documentation.html b/libstdc++-v3/docs/html/documentation.html index a4be76ed453..ceb60764e10 100644 --- a/libstdc++-v3/docs/html/documentation.html +++ b/libstdc++-v3/docs/html/documentation.html @@ -125,8 +125,9 @@
  • Types
  • Implementation properties
  • Start and Termination
  • -
  • Dynamic memory management
  • -
  • RTTI, the ABI, and demangling
  • +
  • Verbose terminate
  • +
  • Dynamic memory management
  • +
  • RTTI, the ABI, and demangling
  • @@ -135,7 +136,6 @@
  • Adding data to exceptions
  • Exception class hierarchy diagram
  • Concept checkers -- new and improved!
  • -
  • Verbose terminate