howto.html: Move verbose terminate documentation...

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

        * 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
This commit is contained in:
Benjamin Kosnik 2004-02-03 01:26:12 +00:00 committed by Benjamin Kosnik
parent 040333a7ca
commit 7f7fb4ef6a
4 changed files with 86 additions and 80 deletions

View File

@ -1,3 +1,10 @@
2004-02-02 Benjamin Kosnik <bkoz@redhat.com>
* 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 <pcarlini@suse.de>
* config/locale/gnu/c++locale_internal.h: Remove prototypes

View File

@ -42,8 +42,9 @@
<li><a href="#1">Types</a></li>
<li><a href="#2">Implementation properties</a></li>
<li><a href="#3">Start and Termination</a></li>
<li><a href="#4">Dynamic memory management</a></li>
<li><a href="#5">RTTI, the ABI, and demangling</a></li>
<li><a href="#4">Verbose <code>terminate</code></a></li>
<li><a href="#5">Dynamic memory management</a></li>
<li><a href="#6">RTTI, the ABI, and demangling</a></li>
</ul>
<hr />
@ -216,10 +217,78 @@
</p>
<hr />
<h2><a name="4">Dynamic memory management</a></h2>
<p>There are six flavors each of <code>new</code> and <code>delete</code>, so
make certain that you're using the right ones! Here are quickie
descriptions of <code>new</code>:
<h2><a name="4">Verbose <code>terminate</code></a></h2>
<p>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:
</p>
<pre>
#include &lt;exception&gt;
int main()
{
std::set_terminate(__gnu_cxx::__verbose_terminate_handler);
...
throw <em>anything</em>;
}</pre>
<p>The <code> __verbose_terminate_handler </code> function obtains the name
of the current exception, attempts to demangle it, and prints it to
stderr. If the exception is derived from <code> std::exception </code>
then the output from <code>what()</code> will be included.
</p>
<p>Any replacement termination function is required to kill the program
without returning; this one calls abort.
</p>
<p>For example:
</p>
<pre>
#include &lt;exception&gt;
#include &lt;stdexcept&gt;
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 &gt; 5)
throw argument_error(&quot;argc is greater than 5!&quot;);
else
throw argc;
}
</pre>
<p>In GCC 3.1 and later, this gives
</p>
<pre>
% ./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
%</pre>
<p>The 'Aborted' line comes from the call to abort(), of course.
</p>
<p><strong>UPDATE:</strong> Starting with GCC 3.4, this is the default
termination handler; nothing need be done to use it. To go back to
the previous &quot;silent death&quot; method, simply include
<code>&lt;exception&gt;</code> and <code>&lt;cstdlib&gt;</code>,
and call
</p>
<pre>
std::set_terminate(std::abort);</pre>
<p>Return <a href="#top">to top of page</a> or
<a href="../faq/index.html">to the FAQ</a>.
</p>
<hr />
<h2><a name="5">Dynamic memory management</a></h2>
<p>There are six flavors each of <code>new</code> and
<code>delete</code>, so make certain that you're using the right
ones! Here are quickie descriptions of <code>new</code>:
</p>
<ul>
<li>single object form, throwing a <code>bad_alloc</code> on errors;
@ -277,7 +346,7 @@
</p>
<hr />
<h2><a name="5">RTTI, the ABI, and demangling</a></h2>
<h2><a name="6">RTTI, the ABI, and demangling</a></h2>
<p>If you have read the <a href="../documentation.html#4">source
documentation</a> for <code> namespace abi </code> then you are aware
of the cross-vendor C++ ABI which we use. One of the exposed

View File

@ -38,7 +38,6 @@
<li><a href="#1">Adding data to exceptions</a></li>
<li><a href="#2">Exception class hierarchy diagram</a></li>
<li><a href="#3">Concept checkers -- <strong>new and improved!</strong></a></li>
<li><a href="#4">Verbose <code>terminate</code></a></li>
</ul>
<hr />
@ -121,75 +120,6 @@
<a href="../faq/index.html">to the FAQ</a>.
</p>
<hr />
<h2><a name="4">Verbose <code>terminate</code></a></h2>
<p>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:
</p>
<pre>
#include &lt;exception&gt;
int main()
{
std::set_terminate (__gnu_cxx::__verbose_terminate_handler);
...
throw <em>anything</em>;
}</pre>
<p>The <code> __verbose_terminate_handler </code> function obtains the name
of the current exception, attempts to demangle it, and prints it to
stderr. If the exception is derived from <code> std::exception </code>
then the output from <code>what()</code> will be included.
</p>
<p>Any replacement termination function is required to kill the program
without returning; this one calls abort.
</p>
<p>For example:
</p>
<pre>
#include &lt;exception&gt;
#include &lt;stdexcept&gt;
struct BLARGH : std::runtime_error
{
BLARGH (const string&amp; whatarg)
: std::runtime_error(whatarg) { }
};
int main (int argc)
{
std::set_terminate (__gnu_cxx::__verbose_terminate_handler);
if (argc &gt; 5)
throw BLARGH(&quot;argc is greater than 5!&quot;);
else
throw argc;
}</pre>
<p>In GCC 3.1 and later, this gives
</p>
<pre>
% ./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
%</pre>
<p>The 'Aborted' line comes from the call to abort(), of course.
</p>
<p><strong>UPDATE:</strong> Starting with GCC 3.4, this is the default
termination handler; nothing need be done to use it. To go back to
the previous &quot;silent death&quot; method, simply include
<code>&lt;exception&gt;</code> and <code>&lt;cstdlib&gt;</code>,
and call
</p>
<pre>
std::set_terminate (std::abort);</pre>
<p>Return <a href="#top">to top of page</a> or
<a href="../faq/index.html">to the FAQ</a>.
</p>
<!-- ####################################################### -->
<hr />

View File

@ -125,8 +125,9 @@
<li><a href="18_support/howto.html#1">Types</a></li>
<li><a href="18_support/howto.html#2">Implementation properties</a></li>
<li><a href="18_support/howto.html#3">Start and Termination</a></li>
<li><a href="18_support/howto.html#4">Dynamic memory management</a></li>
<li><a href="18_support/howto.html#5">RTTI, the ABI, and demangling</a></li>
<li><a href="18_support/howto.html#4">Verbose <code>terminate</code></a></li>
<li><a href="18_support/howto.html#6">Dynamic memory management</a></li>
<li><a href="18_support/howto.html#7">RTTI, the ABI, and demangling</a></li>
</ul>
</li>
@ -135,7 +136,6 @@
<li><a href="19_diagnostics/howto.html#1">Adding data to exceptions</a></li>
<li><a href="19_diagnostics/howto.html#2">Exception class hierarchy diagram</a></li>
<li><a href="19_diagnostics/howto.html#3">Concept checkers -- <strong>new and improved!</strong></a></li>
<li><a href="19_diagnostics/howto.html#4">Verbose <code>terminate</code></a></li>
</ul>
</li>