xref: /openbsd-src/gnu/gcc/libstdc++-v3/docs/html/debug.html (revision 404b540a9034ac75a6199ad1a32d1bbc7a0d4210)
1*404b540aSrobert<?xml version="1.0" encoding="ISO-8859-1"?>
2*404b540aSrobert<!DOCTYPE html
3*404b540aSrobert          PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4*404b540aSrobert          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5*404b540aSrobert
6*404b540aSrobert<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7*404b540aSrobert<head>
8*404b540aSrobert   <meta name="AUTHOR" content="bkoz@gcc.gnu.org (Benjamin Kosnik)" />
9*404b540aSrobert   <meta name="KEYWORDS" content="c++, libstdc++, gdb, g++, debug" />
10*404b540aSrobert   <meta name="DESCRIPTION" content="Debugging C++ binaries" />
11*404b540aSrobert   <meta name="GENERATOR" content="vi and ten fingers" />
12*404b540aSrobert   <title>Debugging schemes and strategies</title>
13*404b540aSrobert<link rel="StyleSheet" href="lib3styles.css" type="text/css" />
14*404b540aSrobert<link rel="Copyright" href="17_intro/license.html" type="text/html" />
15*404b540aSrobert</head>
16*404b540aSrobert<body>
17*404b540aSrobert
18*404b540aSrobert<h1 class="centered"><a name="top">Debugging schemes and strategies</a></h1>
19*404b540aSrobert
20*404b540aSrobert<p class="fineprint"><em>
21*404b540aSrobert   The latest version of this document is always available at
22*404b540aSrobert   <a href="http://gcc.gnu.org/onlinedocs/libstdc++/debug.html">
23*404b540aSrobert   http://gcc.gnu.org/onlinedocs/libstdc++/debug.html</a>.
24*404b540aSrobert</em></p>
25*404b540aSrobert
26*404b540aSrobert<p><em>
27*404b540aSrobert   To the <a href="http://gcc.gnu.org/libstdc++/">libstdc++-v3 homepage</a>.
28*404b540aSrobert</em></p>
29*404b540aSrobert
30*404b540aSrobert<!-- ####################################################### -->
31*404b540aSrobert<hr />
32*404b540aSrobert<p>There are numerous things that can be done to improve the ease with
33*404b540aSrobert   which C++ binaries are debugged when using the GNU
34*404b540aSrobert   tool chain. Here are some of them.
35*404b540aSrobert</p>
36*404b540aSrobert
37*404b540aSrobert<h3 class="left"><a name="gplusplus">Compiler flags determine debug info</a></h3>
38*404b540aSrobert<p>The default optimizations and debug flags for a libstdc++ build are
39*404b540aSrobert   <code>-g -O2</code>. However, both debug and optimization flags can
40*404b540aSrobert   be varied to change debugging characteristics. For instance,
41*404b540aSrobert   turning off all optimization via the <code>-g -O0</code> flag will
42*404b540aSrobert   disable inlining, so that stepping through all functions, including
43*404b540aSrobert   inlined constructors and destructors, is possible. In addition,
44*404b540aSrobert   <code>-fno-eliminate-unused-debug-types</code> can be used when
45*404b540aSrobert   additional debug information, such as nested class info, is desired.
46*404b540aSrobert</p>
47*404b540aSrobert
48*404b540aSrobert<p>Or, the debug format that the compiler and debugger use to communicate
49*404b540aSrobert   information about source constructs can be changed via <code>
50*404b540aSrobert   -gdwarf-2 </code> or <code> -gstabs </code> flags: some debugging
51*404b540aSrobert   formats permit more expressive type and scope information to be
52*404b540aSrobert   shown in gdb.  The default debug information for a particular
53*404b540aSrobert   platform can be identified via the value set by the
54*404b540aSrobert   PREFERRED_DEBUGGING_TYPE macro in the gcc sources.
55*404b540aSrobert</p>
56*404b540aSrobert
57*404b540aSrobert<p>Many other options are available: please see
58*404b540aSrobert<a href="http://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html#Debugging%20Options">"Options for Debugging Your Program"</a>
59*404b540aSrobert   in Using the GNU Compiler Collection (GCC) for a complete list.
60*404b540aSrobert</p>
61*404b540aSrobert
62*404b540aSrobert<h3 class="left"><a name="lib">Using special flags to make a debug binary</a></h3>
63*404b540aSrobert<p>If you would like debug symbols in libstdc++, there are two ways to
64*404b540aSrobert  build libstdc++ with debug flags. The first is to run make from the
65*404b540aSrobert  toplevel in a freshly-configured tree with
66*404b540aSrobert</p>
67*404b540aSrobert<pre>
68*404b540aSrobert     --enable-libstdcxx-debug
69*404b540aSrobert</pre>
70*404b540aSrobert<p>and perhaps</p>
71*404b540aSrobert<pre>
72*404b540aSrobert     --enable-libstdcxx-debug-flags='...'
73*404b540aSrobert</pre>
74*404b540aSrobert<p>to create a separate debug build. Both the normal build and the
75*404b540aSrobert   debug build will persist, without having to specify
76*404b540aSrobert   <code>CXXFLAGS</code>, and the debug library will be installed in a
77*404b540aSrobert   separate directory tree, in <code>(prefix)/lib/debug</code>. For
78*404b540aSrobert   more information, look at the <a href="configopts.html">configuration
79*404b540aSrobert   options</a> document.
80*404b540aSrobert</p>
81*404b540aSrobert
82*404b540aSrobert<p>A second approach is to use the configuration flags
83*404b540aSrobert</p>
84*404b540aSrobert<pre>
85*404b540aSrobert     make CXXFLAGS='-g3 -O0' all
86*404b540aSrobert</pre>
87*404b540aSrobert
88*404b540aSrobert<p>This quick and dirty approach is often sufficient for quick
89*404b540aSrobert  debugging tasks, when you cannot or don't want to recompile your
90*404b540aSrobert  application to use the <a href="#safe">debug mode</a>.</p>
91*404b540aSrobert
92*404b540aSrobert<h3 class="left"><a name="safe">The libstdc++ debug mode</a></h3>
93*404b540aSrobert<p>By default, libstdc++ is built with efficiency in mind, and
94*404b540aSrobert  therefore performs little or no error checking that is not required
95*404b540aSrobert  by the C++ standard. This means that programs that incorrectly use
96*404b540aSrobert  the C++ standard library will exhibit behavior that is not portable
97*404b540aSrobert  and may not even be predictable, because they tread into
98*404b540aSrobert  implementation-specific or undefined behavior. To detect some of
99*404b540aSrobert  these errors before they can become problematic, libstdc++ offers a
100*404b540aSrobert  debug mode that provides additional checking of library facilities,
101*404b540aSrobert  and will report errors in the use of libstdc++ as soon as they can
102*404b540aSrobert  be detected by emitting a description of the problem to standard
103*404b540aSrobert  error and aborting the program.  This debug mode is available with
104*404b540aSrobert  GCC 3.4.0 and later versions. </p>
105*404b540aSrobert
106*404b540aSrobert<p>The libstdc++ debug mode performs checking for many areas of the C++
107*404b540aSrobert  standard, but the focus is on checking interactions among standard
108*404b540aSrobert  iterators, containers, and algorithms, including:</p>
109*404b540aSrobert
110*404b540aSrobert  <ul>
111*404b540aSrobert    <li><em>Safe iterators</em>: Iterators keep track of the
112*404b540aSrobert    container whose elements they reference, so errors such as
113*404b540aSrobert    incrementing a past-the-end iterator or dereferencing an iterator
114*404b540aSrobert    that points to a container that has been destructed are diagnosed
115*404b540aSrobert    immediately.</li>
116*404b540aSrobert
117*404b540aSrobert    <li><em>Algorithm preconditions</em>: Algorithms attempt to
118*404b540aSrobert    validate their input parameters to detect errors as early as
119*404b540aSrobert    possible. For instance, the <code>set_intersection</code>
120*404b540aSrobert    algorithm requires that its iterator
121*404b540aSrobert    parameters <code>first1</code> and <code>last1</code> form a valid
122*404b540aSrobert    iterator range, and that the sequence
123*404b540aSrobert    [<code>first1</code>, <code>last1</code>) is sorted according to
124*404b540aSrobert    the same predicate that was passed
125*404b540aSrobert    to <code>set_intersection</code>; the libstdc++ debug mode will
126*404b540aSrobert    detect an error if the sequence is not sorted or was sorted by a
127*404b540aSrobert    different predicate.</li>
128*404b540aSrobert  </ul>
129*404b540aSrobert
130*404b540aSrobert<h4 class="left">Using the libstdc++ debug mode</h4>
131*404b540aSrobert<p>To use the libstdc++ debug mode, compile your application with the
132*404b540aSrobert  compiler flag <code>-D_GLIBCXX_DEBUG</code>. Note that this flag
133*404b540aSrobert  changes the sizes and behavior of standard class templates such
134*404b540aSrobert  as <code>std::vector</code>, and therefore you can only link code
135*404b540aSrobert  compiled with debug mode and code compiled without debug mode if no
136*404b540aSrobert  instantiation of a container is passed between the two translation
137*404b540aSrobert  units.</p>
138*404b540aSrobert
139*404b540aSrobert<p>For information about the design of the libstdc++ debug mode,
140*404b540aSrobert  please see the <a href="debug_mode.html">libstdc++ debug mode design
141*404b540aSrobert  document</a>.</p>
142*404b540aSrobert
143*404b540aSrobert<h4 class="left">Using the debugging containers without debug
144*404b540aSrobert  mode</h4>
145*404b540aSrobert<p>When it is not feasible to recompile your entire application, or
146*404b540aSrobert  only specific containers need checking, debugging containers are
147*404b540aSrobert  available as GNU extensions. These debugging containers are
148*404b540aSrobert  functionally equivalent to the standard drop-in containers used in
149*404b540aSrobert  debug mode, but they are available in a separate namespace as GNU
150*404b540aSrobert  extensions and may be used in programs compiled with either release
151*404b540aSrobert  mode or with debug mode. The
152*404b540aSrobert  following table provides the names and headers of the debugging
153*404b540aSrobert  containers:
154*404b540aSrobert</p>
155*404b540aSrobert
156*404b540aSrobert<table title="Debugging containers" border="1">
157*404b540aSrobert  <tr>
158*404b540aSrobert    <th>Container</th>
159*404b540aSrobert    <th>Header</th>
160*404b540aSrobert    <th>Debug container</th>
161*404b540aSrobert    <th>Debug header</th>
162*404b540aSrobert  </tr>
163*404b540aSrobert  <tr>
164*404b540aSrobert    <td>std::bitset</td>
165*404b540aSrobert    <td>&lt;bitset&gt;</td>
166*404b540aSrobert    <td>__gnu_debug::bitset</td>
167*404b540aSrobert    <td>&lt;debug/bitset&gt;</td>
168*404b540aSrobert  </tr>
169*404b540aSrobert  <tr>
170*404b540aSrobert    <td>std::deque</td>
171*404b540aSrobert    <td>&lt;deque&gt;</td>
172*404b540aSrobert    <td>__gnu_debug::deque</td>
173*404b540aSrobert    <td>&lt;debug/deque&gt;</td>
174*404b540aSrobert  </tr>
175*404b540aSrobert  <tr>
176*404b540aSrobert    <td>std::list</td>
177*404b540aSrobert    <td>&lt;list&gt;</td>
178*404b540aSrobert    <td>__gnu_debug::list</td>
179*404b540aSrobert    <td>&lt;debug/list&gt;</td>
180*404b540aSrobert  </tr>
181*404b540aSrobert  <tr>
182*404b540aSrobert    <td>std::map</td>
183*404b540aSrobert    <td>&lt;map&gt;</td>
184*404b540aSrobert    <td>__gnu_debug::map</td>
185*404b540aSrobert    <td>&lt;debug/map&gt;</td>
186*404b540aSrobert  </tr>
187*404b540aSrobert  <tr>
188*404b540aSrobert    <td>std::multimap</td>
189*404b540aSrobert    <td>&lt;map&gt;</td>
190*404b540aSrobert    <td>__gnu_debug::multimap</td>
191*404b540aSrobert    <td>&lt;debug/map&gt;</td>
192*404b540aSrobert  </tr>
193*404b540aSrobert  <tr>
194*404b540aSrobert    <td>std::multiset</td>
195*404b540aSrobert    <td>&lt;set&gt;</td>
196*404b540aSrobert    <td>__gnu_debug::multiset</td>
197*404b540aSrobert    <td>&lt;debug/set&gt;</td>
198*404b540aSrobert  </tr>
199*404b540aSrobert  <tr>
200*404b540aSrobert    <td>std::set</td>
201*404b540aSrobert    <td>&lt;set&gt;</td>
202*404b540aSrobert    <td>__gnu_debug::set</td>
203*404b540aSrobert    <td>&lt;debug/set&gt;</td>
204*404b540aSrobert  </tr>
205*404b540aSrobert  <tr>
206*404b540aSrobert    <td>std::string</td>
207*404b540aSrobert    <td>&lt;string&gt;</td>
208*404b540aSrobert    <td>__gnu_debug::string</td>
209*404b540aSrobert    <td>&lt;debug/string&gt;</td>
210*404b540aSrobert  </tr>
211*404b540aSrobert  <tr>
212*404b540aSrobert    <td>std::wstring</td>
213*404b540aSrobert    <td>&lt;string&gt;</td>
214*404b540aSrobert    <td>__gnu_debug::wstring</td>
215*404b540aSrobert    <td>&lt;debug/string&gt;</td>
216*404b540aSrobert  </tr>
217*404b540aSrobert  <tr>
218*404b540aSrobert    <td>std::basic_string</td>
219*404b540aSrobert    <td>&lt;string&gt;</td>
220*404b540aSrobert    <td>__gnu_debug::basic_string</td>
221*404b540aSrobert    <td>&lt;debug/string&gt;</td>
222*404b540aSrobert  </tr>
223*404b540aSrobert  <tr>
224*404b540aSrobert    <td>std::vector</td>
225*404b540aSrobert    <td>&lt;vector&gt;</td>
226*404b540aSrobert    <td>__gnu_debug::vector</td>
227*404b540aSrobert    <td>&lt;debug/vector&gt;</td>
228*404b540aSrobert  </tr>
229*404b540aSrobert  <tr>
230*404b540aSrobert    <td>__gnu_cxx::hash_map</td>
231*404b540aSrobert    <td>&lt;ext/hash_map&gt;</td>
232*404b540aSrobert    <td>__gnu_debug::hash_map</td>
233*404b540aSrobert    <td>&lt;debug/hash_map&gt;</td>
234*404b540aSrobert  </tr>
235*404b540aSrobert  <tr>
236*404b540aSrobert    <td>__gnu_cxx::hash_multimap</td>
237*404b540aSrobert    <td>&lt;ext/hash_map&gt;</td>
238*404b540aSrobert    <td>__gnu_debug::hash_multimap</td>
239*404b540aSrobert    <td>&lt;debug/hash_map&gt;</td>
240*404b540aSrobert  </tr>
241*404b540aSrobert  <tr>
242*404b540aSrobert    <td>__gnu_cxx::hash_set</td>
243*404b540aSrobert    <td>&lt;ext/hash_set&gt;</td>
244*404b540aSrobert    <td>__gnu_debug::hash_set</td>
245*404b540aSrobert    <td>&lt;debug/hash_set&gt;</td>
246*404b540aSrobert  </tr>
247*404b540aSrobert  <tr>
248*404b540aSrobert    <td>__gnu_cxx::hash_multiset</td>
249*404b540aSrobert    <td>&lt;ext/hash_set&gt;</td>
250*404b540aSrobert    <td>__gnu_debug::hash_multiset</td>
251*404b540aSrobert    <td>&lt;debug/hash_set&gt;</td>
252*404b540aSrobert  </tr>
253*404b540aSrobert</table>
254*404b540aSrobert
255*404b540aSrobert<h4 class="left">Debug mode semantics</h4>
256*404b540aSrobert<p>A program that uses the C++ standard library correctly
257*404b540aSrobert  will maintain the same semantics under debug mode as it had with
258*404b540aSrobert  the normal (release) library. All functional and exception-handling
259*404b540aSrobert  guarantees made by the normal library also hold for the debug mode
260*404b540aSrobert  library, with one exception: performance guarantees made by the
261*404b540aSrobert  normal library may not hold in the debug mode library. For
262*404b540aSrobert  instance, erasing an element in a <code>std::list</code> is a
263*404b540aSrobert  constant-time operation in normal library, but in debug mode it is
264*404b540aSrobert  linear in the number of iterators that reference that particular
265*404b540aSrobert  list. So while your (correct) program won't change its results, it
266*404b540aSrobert  is likely to execute more slowly.</p>
267*404b540aSrobert
268*404b540aSrobert<p>libstdc++ includes many extensions to the C++ standard library. In
269*404b540aSrobert  some cases the extensions are obvious, such as the hashed
270*404b540aSrobert  associative containers, whereas other extensions give predictable
271*404b540aSrobert  results to behavior that would otherwise be undefined, such as
272*404b540aSrobert  throwing an exception when a <code>std::basic_string</code> is
273*404b540aSrobert  constructed from a NULL character pointer. This latter category also
274*404b540aSrobert  includes implementation-defined and unspecified semantics, such as
275*404b540aSrobert  the growth rate of a vector. Use of these extensions is not
276*404b540aSrobert  considered incorrect, so code that relies on them will not be
277*404b540aSrobert  rejected by debug mode. However, use of these extensions may affect
278*404b540aSrobert  the portability of code to other implementations of the C++ standard
279*404b540aSrobert  library, and is therefore somewhat hazardous. For this reason, the
280*404b540aSrobert  libstdc++ debug mode offers a "pedantic" mode (similar to
281*404b540aSrobert  GCC's <code>-pedantic</code> compiler flag) that attempts to emulate
282*404b540aSrobert  the semantics guaranteed by the C++ standard. For
283*404b540aSrobert  instance, constructing a <code>std::basic_string</code> with a NULL
284*404b540aSrobert  character pointer would result in an exception under normal mode or
285*404b540aSrobert  non-pedantic debug mode (this is a libstdc++ extension), whereas
286*404b540aSrobert  under pedantic debug mode libstdc++ would signal an error. To enable
287*404b540aSrobert  the pedantic debug mode, compile your program with
288*404b540aSrobert  both <code>-D_GLIBCXX_DEBUG</code>
289*404b540aSrobert  and <code>-D_GLIBCXX_DEBUG_PEDANTIC</code> .
290*404b540aSrobert  (N.B. In GCC 3.4.x and 4.0.0, due to a bug,
291*404b540aSrobert  <code>-D_GLIBXX_DEBUG_PEDANTIC</code> was also needed. The problem has
292*404b540aSrobert  been fixed in GCC 4.0.1 and later versions.) </p>
293*404b540aSrobert
294*404b540aSrobert<p>The following library components provide extra debugging
295*404b540aSrobert  capabilities in debug mode:</p>
296*404b540aSrobert<ul>
297*404b540aSrobert  <li><code>std::basic_string</code> (no safe iterators)</li>
298*404b540aSrobert  <li><code>std::bitset</code></li>
299*404b540aSrobert  <li><code>std::deque</code></li>
300*404b540aSrobert  <li><code>std::list</code></li>
301*404b540aSrobert  <li><code>std::map</code></li>
302*404b540aSrobert  <li><code>std::multimap</code></li>
303*404b540aSrobert  <li><code>std::multiset</code></li>
304*404b540aSrobert  <li><code>std::set</code></li>
305*404b540aSrobert  <li><code>std::vector</code></li>
306*404b540aSrobert  <li><code>__gnu_cxx::hash_map</code></li>
307*404b540aSrobert  <li><code>__gnu_cxx::hash_multimap</code></li>
308*404b540aSrobert  <li><code>__gnu_cxx::hash_multiset</code></li>
309*404b540aSrobert  <li><code>__gnu_cxx::hash_set</code></li>
310*404b540aSrobert</ul>
311*404b540aSrobert
312*404b540aSrobert
313*404b540aSrobert<h3 class="left"><a name="mem">Tips for memory leak hunting</a></h3>
314*404b540aSrobert
315*404b540aSrobert<p>There are various third party memory tracing and debug utilities
316*404b540aSrobert   that can be used to provide detailed memory allocation information
317*404b540aSrobert   about C++ code. An exhaustive list of tools is not going to be
318*404b540aSrobert   attempted, but includes <code>mtrace</code>, <code>valgrind</code>,
319*404b540aSrobert   <code>mudflap</code>, and the non-free commercial product
320*404b540aSrobert   <code>purify</code>. In addition, <code>libcwd</code> has a
321*404b540aSrobert   replacement for the global new and delete operators that can track
322*404b540aSrobert   memory allocation and deallocation and provide useful memory
323*404b540aSrobert   statistics.
324*404b540aSrobert</p>
325*404b540aSrobert
326*404b540aSrobert<p>Regardless of the memory debugging tool being used, there is one
327*404b540aSrobert   thing of great importance to keep in mind when debugging C++ code
328*404b540aSrobert   that uses <code>new</code> and <code>delete</code>:
329*404b540aSrobert   there are different kinds of allocation schemes that can be used by
330*404b540aSrobert   <code> std::allocator </code>. For implementation details, see this
331*404b540aSrobert   <a href="ext/howto.html#3"> document</a> and look specifically for
332*404b540aSrobert   <code>GLIBCXX_FORCE_NEW</code>.
333*404b540aSrobert</p>
334*404b540aSrobert
335*404b540aSrobert<p>In a nutshell, the default allocator used by <code>
336*404b540aSrobert   std::allocator</code> is a high-performance pool allocator, and can
337*404b540aSrobert   give the mistaken impression that in a suspect executable, memory
338*404b540aSrobert   is being leaked, when in reality the memory "leak" is a pool being
339*404b540aSrobert   used by the library's allocator and is reclaimed after program
340*404b540aSrobert   termination.
341*404b540aSrobert</p>
342*404b540aSrobert
343*404b540aSrobert<p>For valgrind, there are some specific items to keep in mind. First
344*404b540aSrobert   of all, use a version of valgrind that will work with current GNU
345*404b540aSrobert   C++ tools: the first that can do this is valgrind 1.0.4, but later
346*404b540aSrobert   versions should work at least as well. Second of all, use a
347*404b540aSrobert   completely unoptimized build to avoid confusing valgrind. Third,
348*404b540aSrobert   use GLIBCXX_FORCE_NEW to keep extraneous pool allocation noise from
349*404b540aSrobert   cluttering debug information.
350*404b540aSrobert</p>
351*404b540aSrobert
352*404b540aSrobert<p>Fourth, it may be necessary to force deallocation in other
353*404b540aSrobert   libraries as well, namely the "C" library. On linux, this can be
354*404b540aSrobert   accomplished with the appropriate use of the
355*404b540aSrobert   <code>__cxa_atexit</code> or <code>atexit</code> functions.
356*404b540aSrobert</p>
357*404b540aSrobert
358*404b540aSrobert<pre>
359*404b540aSrobert   #include &lt;cstdlib&gt;
360*404b540aSrobert
361*404b540aSrobert   extern "C" void __libc_freeres(void);
362*404b540aSrobert
363*404b540aSrobert   void do_something() { }
364*404b540aSrobert
365*404b540aSrobert   int main()
366*404b540aSrobert   {
367*404b540aSrobert     atexit(__libc_freeres);
368*404b540aSrobert     do_something();
369*404b540aSrobert     return 0;
370*404b540aSrobert   }
371*404b540aSrobert</pre>
372*404b540aSrobert
373*404b540aSrobert
374*404b540aSrobert<p>or, using <code>__cxa_atexit</code>:</p>
375*404b540aSrobert
376*404b540aSrobert<pre>
377*404b540aSrobert   extern "C" void __libc_freeres(void);
378*404b540aSrobert   extern "C" int __cxa_atexit(void (*func) (void *), void *arg, void *d);
379*404b540aSrobert
380*404b540aSrobert   void do_something() { }
381*404b540aSrobert
382*404b540aSrobert   int main()
383*404b540aSrobert   {
384*404b540aSrobert      extern void* __dso_handle __attribute__ ((__weak__));
385*404b540aSrobert      __cxa_atexit((void (*) (void *)) __libc_freeres, NULL,
386*404b540aSrobert                   &amp;__dso_handle ? __dso_handle : NULL);
387*404b540aSrobert      do_test();
388*404b540aSrobert      return 0;
389*404b540aSrobert   }
390*404b540aSrobert</pre>
391*404b540aSrobert
392*404b540aSrobert<p>Suggested valgrind flags, given the suggestions above about setting
393*404b540aSrobert   up the runtime environment, library, and test file, might be:
394*404b540aSrobert</p>
395*404b540aSrobert<pre>
396*404b540aSrobert   valgrind -v --num-callers=20 --leak-check=yes --leak-resolution=high --show-reachable=yes a.out
397*404b540aSrobert</pre>
398*404b540aSrobert
399*404b540aSrobert
400*404b540aSrobert<h3 class="left"><a name="gdb">Some gdb strategies</a></h3>
401*404b540aSrobert<p>Many options are available for gdb itself: please see <a
402*404b540aSrobert   href="http://sources.redhat.com/gdb/current/onlinedocs/gdb_13.html#SEC109">
403*404b540aSrobert   "GDB features for C++" </a> in the gdb documentation. Also
404*404b540aSrobert   recommended: the other parts of this manual.
405*404b540aSrobert</p>
406*404b540aSrobert
407*404b540aSrobert<p>These settings can either be switched on in at the gdb command
408*404b540aSrobert   line, or put into a .gdbint file to establish default debugging
409*404b540aSrobert   characteristics, like so:
410*404b540aSrobert</p>
411*404b540aSrobert
412*404b540aSrobert<pre>
413*404b540aSrobert   set print pretty on
414*404b540aSrobert   set print object on
415*404b540aSrobert   set print static-members on
416*404b540aSrobert   set print vtbl on
417*404b540aSrobert   set print demangle on
418*404b540aSrobert   set demangle-style gnu-v3
419*404b540aSrobert</pre>
420*404b540aSrobert
421*404b540aSrobert
422*404b540aSrobert<h3 class="left"><a name="verbterm">Tracking uncaught exceptions</a></h3>
423*404b540aSrobert<p>The <a href="18_support/howto.html#4">verbose termination handler</a>
424*404b540aSrobert   gives information about uncaught exceptions which are killing the
425*404b540aSrobert   program.  It is described in the linked-to page.
426*404b540aSrobert</p>
427*404b540aSrobert
428*404b540aSrobert
429*404b540aSrobert<p>Return <a href="#top">to the top of the page</a> or
430*404b540aSrobert   <a href="http://gcc.gnu.org/libstdc++/">to the libstdc++ homepage</a>.
431*404b540aSrobert</p>
432*404b540aSrobert
433*404b540aSrobert
434*404b540aSrobert<!-- ####################################################### -->
435*404b540aSrobert
436*404b540aSrobert<hr />
437*404b540aSrobert<p class="fineprint"><em>
438*404b540aSrobertSee <a href="17_intro/license.html">license.html</a> for copying conditions.
439*404b540aSrobertComments and suggestions are welcome, and may be sent to
440*404b540aSrobert<a href="mailto:libstdc++@gcc.gnu.org">the libstdc++ mailing list</a>.
441*404b540aSrobert</em></p>
442*404b540aSrobert
443*404b540aSrobert
444*404b540aSrobert</body>
445*404b540aSrobert</html>
446