From 3642a94924510f7e7220aea6aefebc7372d59d8b Mon Sep 17 00:00:00 2001 From: Phil Edwards Date: Thu, 26 Dec 2002 21:14:19 +0000 Subject: [PATCH] eh_term_handler.cc: Add comment about embedded systems. 2002-12-26 Phil Edwards * libsupc++/eh_term_handler.cc: Add comment about embedded systems. * docs/html/debug.html: Cosmetic and HTML changes. Point to verb-term notes. * docs/html/documentation.html: Link to the FAQ. * docs/html/17_intro/howto.html: Mention use of isatty(3). * docs/html/19_diagnostics/howto.html: Update verb-term description. From-SVN: r60528 --- libstdc++-v3/ChangeLog | 9 +++ libstdc++-v3/docs/html/17_intro/howto.html | 3 + libstdc++-v3/docs/html/19_diagnostics/howto.html | 7 +++ libstdc++-v3/docs/html/debug.html | 80 +++++++++++------------- libstdc++-v3/docs/html/documentation.html | 2 + libstdc++-v3/libsupc++/eh_term_handler.cc | 6 ++ 6 files changed, 62 insertions(+), 45 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 62ce9436032..32ee235c4fc 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,12 @@ +2002-12-26 Phil Edwards + + * libsupc++/eh_term_handler.cc: Add comment about embedded systems. + * docs/html/debug.html: Cosmetic and HTML changes. Point to + verb-term notes. + * docs/html/documentation.html: Link to the FAQ. + * docs/html/17_intro/howto.html: Mention use of isatty(3). + * docs/html/19_diagnostics/howto.html: Update verb-term description. + 2002-12-25 Phil Edwards * src/vterminate.cc: Move to... diff --git a/libstdc++-v3/docs/html/17_intro/howto.html b/libstdc++-v3/docs/html/17_intro/howto.html index 9d10becfad4..9d9bbddb130 100644 --- a/libstdc++-v3/docs/html/17_intro/howto.html +++ b/libstdc++-v3/docs/html/17_intro/howto.html @@ -189,6 +189,9 @@

For each entry, we give the section number of the standard, when applicable. This list is probably incomplet and inkorrekt.

+

[1.9]/11 #3 If isatty(3) is true, then + interactive stream support is implied. +

[17.4.4.5] Non-reentrant functions are probably best discussed in the various sections on multithreading (see above).

diff --git a/libstdc++-v3/docs/html/19_diagnostics/howto.html b/libstdc++-v3/docs/html/19_diagnostics/howto.html index d1d759d5a43..dbfcc9cb054 100644 --- a/libstdc++-v3/docs/html/19_diagnostics/howto.html +++ b/libstdc++-v3/docs/html/19_diagnostics/howto.html @@ -169,6 +169,13 @@ %

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/debug.html b/libstdc++-v3/docs/html/debug.html index 73d592ffc25..ff20d249c36 100644 --- a/libstdc++-v3/docs/html/debug.html +++ b/libstdc++-v3/docs/html/debug.html @@ -28,16 +28,14 @@
-

- There are numerous things that can be done to improve the ease with +

There are numerous things that can be done to improve the ease with which C++ binaries are debugged when using the GNU C++ tool chain. Here are some things to keep in mind when debugging C++ code with GNU tools.

Compiler flags determine debug info

-

- The default optimizations and debug flags for a libstdc++ build are +

The default optimizations and debug flags for a libstdc++ build are -g -O2. However, both debug and optimization flags can be varied to change debugging characteristics. For instance, turning off all optimization via the -g -O0 flag will @@ -53,53 +51,45 @@ in the gcc sources.

-

- Many other options are available: please see +

Many other options are available: please see "Options for Debugging Your Program" in Using the GNU Compiler Collection (GCC) for a complete list.

Using special flags to make a debug binary

-

- There are two ways to build libstdc++ with debug flags. The first +

There are two ways to build libstdc++ with debug flags. The first is to run make from the toplevel in a freshly-configured tree with specialized debug CXXFLAGS, as in

make CXXFLAGS='-g3 -O0' all

-

- This quick and dirty approach is often sufficient for quick +

This quick and dirty approach is often sufficient for quick debugging tasks, but the lack of state can be confusing in the long term.

-

- A second approach is to use the configuration flags +

A second approach is to use the configuration flags

-
--enable-debug
+
--enable-debug
-

- and perhaps -

+

and perhaps

-
--enable-debug-flags
+
--enable-debug-flags='...'
-

- to create a separate debug build. Both the normal build and the +

to create a separate debug build. Both the normal build and the debug build will persist, without having to specify CXXFLAGS, and the debug library will be installed in a separate directory tree, in (prefix)/lib/debug. For more information, look at the configuration options document - here +here

Tips for memory leak hunting

-

- There are various third party memory tracing and debug utilities +

There are various third party memory tracing and debug utilities that can be used to provide detailed memory allocation information about C++ code. An exhaustive list of tools is not going to be attempted, but include mtrace, valgrind, @@ -108,8 +98,7 @@ forget right now.

-

- Regardless of the memory debugging tool being used, there is one +

Regardless of the memory debugging tool being used, there is one thing of great importance to keep in mind when debugging C++ code that uses new and delete: there are different kinds of allocation schemes that can be used by @@ -118,14 +107,13 @@ document and look specifically for GLIBCPP_FORCE_NEW.

-

- In a nutshell, the default allocator used by +

In a nutshell, the default allocator used by std::allocator is a high-performance pool allocator, and can give the mistaken impression that memory is being leaked, when in reality the memory is reclaimed after program termination.

-

For valgrind, there are some specific items to keep in mind. First +

For valgrind, there are some specific items to keep in mind. First of all, use a version of valgrind that will work with current GNU C++ tools: the first that can do this is valgrind 1.0.4, but later versions should work at least as well. Second of all, use a @@ -134,15 +122,14 @@ cluttering debug information.

-

- Fourth, it may be necessary to force deallocation in other +

Fourth, it may be necessary to force deallocation in other libraries as well, namely the "C" library. On linux, this can be accomplished with the appropriate use of the __cxa_atexit or atexit functions.

-   #include 
+   #include <cstdlib>
 
    extern "C" void __libc_freeres(void);
 
@@ -151,15 +138,13 @@
    int main()
    {
      atexit(__libc_freeres);
-     do_test();
+     do_something();
      return 0;
    }
 
-

- or, using __cxa_atexit: -

+

or, using __cxa_atexit:

    extern "C" void __libc_freeres(void);
@@ -171,14 +156,13 @@
    {
       extern void* __dso_handle __attribute__ ((__weak__));
       __cxa_atexit((void (*) (void *)) __libc_freeres, NULL, 
-	           &__dso_handle ? __dso_handle : NULL);
+                   &__dso_handle ? __dso_handle : NULL);
       do_test();
       return 0;
    }
 
-

- Suggested valgrind flags, given the suggestions above about setting +

Suggested valgrind flags, given the suggestions above about setting up the runtime environment, library, and test file, might be:

valgrind -v --num-callers=20 --leak-check=yes @@ -187,14 +171,13 @@

Some gdb strategies

-

- Many options are available for gdb itself: please see -"GDB features for C++" in the gdb documentation. Also -recommended: the other parts of this manual. -

-

- These settings can either be switched on in at the gdb command +

Many options are available for gdb itself: please see + "GDB features for C++" in the gdb documentation. Also + recommended: the other parts of this manual. +

+ +

These settings can either be switched on in at the gdb command line, or put into a .gdbint file to establish default debugging characteristics, like so:

@@ -209,6 +192,13 @@ recommended: the other parts of this manual. +

Tracking uncaught exceptions

+

The verbose termination handler + gives information about uncaught exceptions which are killing the + program. It is described in the linked-to page. +

+ +

Return to the top of the page or to the libstdc++ homepage.

diff --git a/libstdc++-v3/docs/html/documentation.html b/libstdc++-v3/docs/html/documentation.html index d805c66ea9e..c0e3cdb112d 100644 --- a/libstdc++-v3/docs/html/documentation.html +++ b/libstdc++-v3/docs/html/documentation.html @@ -39,6 +39,8 @@ - latest version info, recent changes and news
  • TODO - tasks yet undone
  • +
  • FAQ (HTML), + FAQ (text)

  • diff --git a/libstdc++-v3/libsupc++/eh_term_handler.cc b/libstdc++-v3/libsupc++/eh_term_handler.cc index ff7b7edd957..df2ccf989fd 100644 --- a/libstdc++-v3/libsupc++/eh_term_handler.cc +++ b/libstdc++-v3/libsupc++/eh_term_handler.cc @@ -29,6 +29,12 @@ #include "unwind-cxx.h" +/* We default to the talkative, informative handler. This pulls in the + demangler, the dyn-string utilities, and elements of the I/O library. + For a low-memory environment, you can return to the earlier "silent death" + handler by including , initializg to "std::abort", and rebuilding + the library. */ + /* The current installed user handler. */ std::terminate_handler __cxxabiv1::__terminate_handler = __gnu_cxx::__verbose_terminate_handler; -- 2.11.4.GIT