Show Table of Contents
Chapter 12. Valgrind
Valgrind is an instrumentation framework that ships with a number of tools for profiling applications. It can be used to detect various memory errors and memory-management problems, such as the use of uninitialized memory or an improper allocation and freeing of memory, or to identify the use of improper arguments in system calls. For a complete list of profiling tools that are distributed with the Red Hat Developer Toolset version of Valgrind, see Table 12.1, “Tools Distributed with Valgrind for Red Hat Developer Toolset”.
Valgrind profiles an application by rewriting it and instrumenting the rewritten binary. This allows you to profile your application without the need to recompile it, but it also makes Valgrind significantly slower than other profilers, especially when performing extremely detailed runs. It is therefore not suited to debugging time-specific issues, or kernel-space debugging.
Red Hat Developer Toolset is distributed with Valgrind 3.11.0. This version is more recent than the version included in the previous release of Red Hat Developer Toolset and provides numerous bug fixes and enhancements.
Table 12.1. Tools Distributed with Valgrind for Red Hat Developer Toolset
12.1. Installing Valgrind
In Red Hat Developer Toolset, Valgrind is provided by the devtoolset-4-valgrind package and is automatically installed with devtoolset-4-perftools. If you intend to use Valgrind to profile parallel programs that use the Message Passing Interface (MPI) protocol, also install the devtoolset-4-valgrind-openmpi package by typing the following at a shell prompt as
yum install devtoolset-4-valgrind-openmpi
For detailed instructions on how to install Red Hat Developer Toolset and related packages to your system, see Section 1.5, “Installing Red Hat Developer Toolset”.
Note that if you use Valgrind in combination with the GNU Debugger, it is recommended that you use the version of GDB that is included in Red Hat Developer Toolset to ensure that all features are fully supported.